示例#1
0
 public function getPropertyValue($object, PropertyInterface $node)
 {
     if (isset($object[$node->getIdentifier()])) {
         return $object[$node->getIdentifier()];
     }
     return null;
 }
示例#2
0
 /**
  * {@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);
 }
示例#5
0
 /**
  * Get property from this object
  *
  * @param mixed $object
  * @param PropertyInterface $node
  *
  * @return mixed
  */
 public function getPropertyValue($object, PropertyInterface $node)
 {
     return $object->getProperty($node->getIdentifier());
 }
示例#6
0
 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;
 }