/**
  * {@inheritdoc}
  */
 public function getEntityAlias($entityClass)
 {
     $model = $this->configManager->getConfigEntityModel($entityClass);
     if ($model) {
         // check for enums
         $enumCode = $this->configManager->getProvider('enum')->getConfig($entityClass)->get('code');
         if ($enumCode) {
             $entityAlias = $this->getEntityAliasFromConfig($entityClass);
             if (null !== $entityAlias) {
                 return $entityAlias;
             }
             return $this->createEntityAlias(str_replace('_', '', $enumCode));
         }
         // check for dictionaries
         $groups = $this->configManager->getProvider('grouping')->getConfig($entityClass)->get('groups');
         if (!empty($groups) && in_array(GroupingScope::GROUP_DICTIONARY, $groups, true)) {
             // delegate aliases generation to default provider
             return null;
         }
         // exclude hidden entities
         if ($model->getMode() === ConfigModelManager::MODE_HIDDEN) {
             return false;
         }
         // check for custom entities
         if (ExtendHelper::isCustomEntity($entityClass)) {
             $entityAlias = $this->getEntityAliasFromConfig($entityClass);
             if (null !== $entityAlias) {
                 return $entityAlias;
             }
             return $this->createEntityAlias('Extend' . ExtendHelper::getShortClassName($entityClass));
         }
     }
     return null;
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function getEntitiesMetadata()
 {
     $result = [];
     foreach ($this->getChannelEntities() as $entityName) {
         $entityConfig = $this->entityProvider->getEntity($entityName, true);
         $extendConfig = $this->configManager->getProvider('extend')->getConfig($entityName);
         $configEntityModel = $this->configManager->getConfigEntityModel($entityName);
         if ($configEntityModel instanceof EntityConfigModel) {
             $entityConfig = array_merge($entityConfig, $this->getEntityLinks($configEntityModel));
         }
         $result[$entityName] = array_merge($entityConfig, ['type' => $extendConfig->get('owner')]);
     }
     return $result;
 }
Exemplo n.º 3
0
 public function testGetConfigEntityModel()
 {
     $model = $this->createEntityConfigModel(self::ENTITY_CLASS);
     $this->modelManager->expects($this->once())->method('findEntityModel')->with(self::ENTITY_CLASS)->willReturn($model);
     $result = $this->configManager->getConfigEntityModel(self::ENTITY_CLASS);
     $this->assertSame($model, $result);
 }
Exemplo n.º 4
0
 /**
  * @param string $className
  * @param string $mode      Can be the value of one of ConfigModel::MODE_* constants
  */
 protected function changeEntityMode($className, $mode)
 {
     if ($this->configManager->getConfigEntityModel($className)->getMode() !== $mode) {
         $this->logger->info(sprintf('Update a mode to "%s". Entity: %s.', $mode, $className));
         $this->configManager->changeEntityMode($className, $mode);
     }
 }