Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 public function getValue($entity, FieldMetadata $metadata)
 {
     if ($metadata->has('activity') && $metadata->has('type') && $metadata->get('activity') === true) {
         return $this->getActivity($entity, $metadata->get('type'));
     }
     return parent::getValue($entity, $metadata);
 }
 /**
  * @param object $relatedEntity
  * @param FieldMetadata $metadata
  * @param object $value
  */
 protected function setRelatedEntityValue($relatedEntity, FieldMetadata $metadata, $value)
 {
     if ($metadata->has('setter')) {
         $setter = $metadata->get('setter');
         $relatedEntity->{$setter}($value);
     } else {
         try {
             $this->getPropertyAccessor()->setValue($relatedEntity, $metadata->getDoctrineMetadata()->getFieldName(), $value);
         } catch (NoSuchPropertyException $e) {
             // If setter is not exist
             $reflection = new \ReflectionProperty(ClassUtils::getClass($relatedEntity), $metadata->getDoctrineMetadata()->getFieldName());
             $reflection->setAccessible(true);
             $reflection->setValue($relatedEntity, $value);
         }
     }
 }
Esempio n. 3
0
 /**
  * @param FieldMetadata $fieldMetadata
  * @return array
  */
 protected function initFieldMetadataDefaultLabel(FieldMetadata $fieldMetadata)
 {
     if ($fieldMetadata->has('label')) {
         return;
     }
     $labelCode = 'label';
     $className = $fieldMetadata->getSourceClassName();
     $fieldName = $fieldMetadata->getSourceFieldName();
     if (!$fieldMetadata->isDefinedBySourceEntity()) {
         $fieldName = null;
         if ($fieldMetadata->isCollection()) {
             $labelCode = 'plural_label';
         }
     }
     $entityConfig = $this->entityConfigHelper->getConfig(self::CONFIG_ENTITY_SCOPE, $className, $fieldName);
     if ($entityConfig) {
         $fieldMetadata->set('label', $entityConfig->get($labelCode));
     }
 }
Esempio n. 4
0
 /**
  * @param FieldMetadata $metadata
  * @return string
  */
 protected function getPropertyPath(FieldMetadata $metadata)
 {
     return $metadata->has('property_path') ? $metadata->get('property_path') : $metadata->getFieldName();
 }