public function getPropertyValue($object, PropertyInterface $node) { if (isset($object[$node->getIdentifier()])) { return $object[$node->getIdentifier()]; } return null; }
/** * {@inheritDoc} */ public function setPropertyValue($object, PropertyInterface $property, $value) { $class = new \ReflectionClass($object); $name = $property->getIdentifier(); $method = 'set' . ucfirst($name); if ($class->hasMethod($method)) { $object->{$method}($value); } elseif ($class->hasProperty($name)) { $object->{$name} = $value; } else { throw new \Exception('Unknown property ' . $property->getIdentifier()); } return $object; }
public function getPropertyValueCallback($object, PropertyInterface $property) { $name = $property->getIdentifier(); if (method_exists($object, 'getObject')) { $object = $object->getObject(); } $method = 'get' . ucfirst($name); if (method_exists($object, $method)) { return $object->{$method}(); } throw new \Exception('Invalid call to getPropertyValue'); }
/** * {@inheritDoc} */ public function setPropertyValue($object, PropertyInterface $property, $value) { $config = $property->getConfig(); if (isset($config['doctrine:reference'])) { $value = $this->getBySubject($value); } return parent::setPropertyValue($object, $property, $value); }
/** * Get property from this object * * @param mixed $object * @param PropertyInterface $node * * @return mixed */ public function getPropertyValue($object, PropertyInterface $node) { return $object->getProperty($node->getIdentifier()); }
private function _get_fieldname($object, PropertyInterface $node) { $config = $node->getConfig(); if (!array_key_exists('dba_name', $config)) { $fieldname = $node->getIdentifier(); } else { $fieldname = $config['dba_name']; } if (!\midcom::get('dbfactory')->property_exists($object, $fieldname)) { throw new \midcom_error('Could not find property mapping for ' . $fieldname); } return $fieldname; }