Example #1
0
 /**
  * Prepare metadata field.
  *
  * @param FieldMetadata $fieldMetadata
  */
 public function prepareFieldMetadataPropertyPath(FieldMetadata $fieldMetadata)
 {
     $className = $fieldMetadata->getSourceClassName();
     $fieldName = $fieldMetadata->getSourceFieldName();
     if ($this->isExtendField($className, $fieldName)) {
         $fieldMetadata->set('property_path', $fieldName);
         $fieldMetadata->set('is_extend', true);
     }
 }
 /**
  * Prepare metadata field.
  *
  * @param FieldMetadata $fieldMetadata
  */
 public function prepareFieldMetadataPropertyPath(FieldMetadata $fieldMetadata)
 {
     $className = $fieldMetadata->getSourceClassName();
     $fieldName = $fieldMetadata->getSourceFieldName();
     $extendConfig = $this->getFieldExtendConfig($className, $fieldName);
     if ($extendConfig && $extendConfig->is('is_extend')) {
         $fieldMetadata->set('property_path', $fieldName);
         $fieldMetadata->set('display', true);
     }
 }
 public function testIsCollectionTrueWhenManyToOneDefinedBySourceEntity()
 {
     $className = 'Foo\\Entity';
     $sourceClassName = 'Bar\\Entity';
     $this->entityMetadata->expects($this->once())->method('getClassName')->will($this->returnValue($className));
     $this->fieldMetadata->setEntityMetadata($this->entityMetadata);
     $this->fieldMetadata->set('source_class_name', $sourceClassName);
     $this->doctrineMetadata->expects($this->once())->method('isAssociation')->will($this->returnValue(true));
     $this->doctrineMetadata->expects($this->once())->method('isManyToMany')->will($this->returnValue(false));
     $this->doctrineMetadata->expects($this->once())->method('isManyToOne')->will($this->returnValue(true));
     $this->assertTrue($this->fieldMetadata->isCollection());
 }
 /**
  * @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));
     }
 }