Esempio n. 1
0
 protected function getEntityChoiceList($entityClassName, $relationType)
 {
     $configManager = $this->configProvider->getConfigManager();
     $choices = array();
     if ($this->targetEntity) {
         $entityIds = array($this->configProvider->getId($this->targetEntity));
     } else {
         $entityIds = $configManager->getIds('extend');
     }
     if (in_array($relationType, array('oneToMany', 'manyToMany'))) {
         $entityIds = array_filter($entityIds, function (EntityConfigId $configId) use($configManager) {
             $config = $configManager->getConfig($configId);
             return $config->is('is_extend');
         });
     }
     $entityIds = array_filter($entityIds, function (EntityConfigId $configId) use($configManager) {
         $config = $configManager->getConfig($configId);
         return $config->is('is_extend', false) || !$config->is('state', ExtendScope::STATE_NEW);
     });
     foreach ($entityIds as $entityId) {
         $className = $entityId->getClassName();
         if ($className != $entityClassName) {
             list($moduleName, $entityName) = ConfigHelper::getModuleAndEntityNames($className);
             $choices[$className] = $moduleName . ':' . $entityName;
         }
     }
     return $choices;
 }
Esempio n. 2
0
 public function testConfig()
 {
     $this->assertEquals($this->configManager, $this->configProvider->getConfigManager());
     $this->assertEquals(true, $this->configProvider->hasConfig(DemoEntity::ENTITY_NAME));
     $this->assertEquals($this->entityConfig, $this->configProvider->getConfig(DemoEntity::ENTITY_NAME));
     $this->assertEquals('testScope', $this->configProvider->getScope());
     $entityConfigId = new EntityConfigId('testScope', DemoEntity::ENTITY_NAME);
     $fieldConfigId = new FieldConfigId('testScope', DemoEntity::ENTITY_NAME, 'testField', 'string');
     $this->assertEquals($entityConfigId, $this->configProvider->getId(DemoEntity::ENTITY_NAME));
     $this->assertEquals($fieldConfigId, $this->configProvider->getId(DemoEntity::ENTITY_NAME, 'testField', 'string'));
     $entityConfigIdWithOtherScope = new EntityConfigId('otherScope', DemoEntity::ENTITY_NAME);
     $this->assertEquals($this->entityConfig, $this->configProvider->getConfigById($entityConfigIdWithOtherScope));
 }
 protected function getEntityChoiceList($entityClassName, $relationType)
 {
     $configManager = $this->configProvider->getConfigManager();
     $choices = array();
     if ($this->targetEntity) {
         $entityIds = array($this->configProvider->getId($this->targetEntity));
     } else {
         $entityIds = $configManager->getIds('extend');
     }
     if (in_array($relationType, array('oneToMany', 'manyToMany'))) {
         $entityIds = array_filter($entityIds, function (EntityConfigId $configId) use($configManager) {
             $config = $configManager->getConfig($configId);
             return $config->is('is_extend');
         });
     }
     $entityIds = array_filter($entityIds, function (EntityConfigId $configId) use($configManager) {
         $config = $configManager->getConfig($configId);
         return $config->is('is_extend', false) || !$config->is('state', ExtendManager::STATE_NEW);
     });
     foreach ($entityIds as $entityId) {
         $entityName = $moduleName = '';
         if ($entityId->getClassName() != $entityClassName) {
             $className = explode('\\', $entityId->getClassName());
             if (count($className) > 1) {
                 foreach ($className as $i => $name) {
                     if (count($className) - 1 == $i) {
                         $entityName = $name;
                     } elseif (!in_array($name, array('Bundle', 'Entity'))) {
                         $moduleName .= $name;
                     }
                 }
             }
             $choices[$entityId->getClassName()] = $moduleName . ':' . $entityName;
         }
     }
     return $choices;
 }