public function testIsDefinedBySourceEntityFalse()
 {
     $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->assertFalse($this->fieldMetadata->isDefinedBySourceEntity());
 }
 /**
  * @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));
     }
 }
Exemple #3
0
 /**
  * Checks if this class supports accessing entity
  *
  * @param string        $entity
  * @param FieldMetadata $metadata
  * @return string
  */
 public function supports($entity, FieldMetadata $metadata)
 {
     return $metadata->isDefinedBySourceEntity();
 }
 /**
  * Checks if this class supports accessing entity
  *
  * @param string        $entity
  * @param FieldMetadata $metadata
  * @return string
  */
 public function supports($entity, FieldMetadata $metadata)
 {
     return !$metadata->isDefinedBySourceEntity() && $metadata->hasDoctrineMetadata() && $this->isAssociationTypeToOne($metadata->getDoctrineMetadata());
 }