Exemplo n.º 1
0
 /**
  * @param FieldMetadata $fieldMetadata
  * @return array
  */
 protected function initMergeModes(FieldMetadata $fieldMetadata)
 {
     $fieldMetadata->addMergeMode(MergeModes::REPLACE);
     if ($fieldMetadata->isCollection()) {
         $fieldMetadata->addMergeMode(MergeModes::UNITE);
     }
 }
Exemplo n.º 2
0
 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());
 }
Exemplo 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));
     }
 }