/**
  * {@inheritdoc}
  */
 public function doExecute(LoggerInterface $logger, $dryRun = false)
 {
     $getSql = 'SELECT id, class_name FROM oro_entity_config';
     $this->logQuery($logger, $getSql);
     $configs = $this->connection->fetchAll($getSql);
     $indexes = $this->getIndexes($logger);
     $insertSql = 'INSERT INTO oro_entity_config_index_value ' . '(entity_id, scope, code, value) ' . 'VALUES (:entity_id, :scope, :code, :value)';
     foreach ($configs as $config) {
         $id = (int) $config['id'];
         $className = $config['class_name'];
         list($moduleName, $entityName) = ConfigHelper::getModuleAndEntityNames($className);
         if (!isset($indexes[$id]['module_name'])) {
             $params = ['entity_id' => $id, 'scope' => 'entity_config', 'code' => 'module_name', 'value' => $moduleName];
             $types = ['entity_id' => 'integer', 'scope' => 'string', 'code' => 'string', 'value' => 'string'];
             $this->logQuery($logger, $insertSql, $params, $types);
             if (!$dryRun) {
                 $this->connection->executeUpdate($insertSql, $params, $types);
             }
         }
         if (!isset($indexes[$id]['entity_name'])) {
             $params = ['entity_id' => $id, 'scope' => 'entity_config', 'code' => 'entity_name', 'value' => $entityName];
             $types = ['entity_id' => 'integer', 'scope' => 'string', 'code' => 'string', 'value' => 'string'];
             $this->logQuery($logger, $insertSql, $params, $types);
             if (!$dryRun) {
                 $this->connection->executeUpdate($insertSql, $params, $types);
             }
         }
     }
 }
示例#2
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;
 }
示例#3
0
 /**
  * @param string $className
  * @return $this
  */
 public function setClassName($className)
 {
     $this->className = $className;
     list($moduleName, $entityName) = ConfigHelper::getModuleAndEntityNames($className);
     $this->addToIndex('entity_config', 'module_name', $moduleName);
     $this->addToIndex('entity_config', 'entity_name', $entityName);
     return $this;
 }
示例#4
0
 /**
  * @Route("/widget/info/{id}", name="oro_entityconfig_widget_info")
  * @Template
  *
  * @param EntityConfigModel $entity
  *
  * @return array
  */
 public function infoAction(EntityConfigModel $entity)
 {
     list($moduleName, $entityName) = ConfigHelper::getModuleAndEntityNames($entity->getClassName());
     /** @var ConfigProvider $entityConfigProvider */
     $entityConfigProvider = $this->get('oro_entity_config.provider.entity');
     /** @var ConfigProvider $extendConfigProvider */
     $extendConfigProvider = $this->get('oro_entity_config.provider.extend');
     $extendConfig = $extendConfigProvider->getConfig($entity->getClassName());
     /** @var ConfigProvider $securityConfigProvider */
     $securityConfigProvider = $this->get('oro_entity_config.provider.security');
     $securityConfig = $securityConfigProvider->getConfig($entity->getClassName());
     /** @var ConfigProvider $ownershipConfigProvider */
     $ownershipConfigProvider = $this->get('oro_entity_config.provider.ownership');
     $ownerTypes = $this->get('oro_organization.form.type.ownership_type')->getOwnershipsArray();
     $ownerType = $ownershipConfigProvider->getConfig($entity->getClassName())->get('owner_type');
     $ownerType = $ownerTypes[empty($ownerType) ? 'NONE' : $ownerType];
     return ['entity' => $entity, 'entity_config' => $entityConfigProvider->getConfig($entity->getClassName()), 'entity_extend' => $extendConfig, 'entity_owner_type' => $ownerType, 'entity_name' => $entityName, 'module_name' => $moduleName, 'security_config' => $securityConfig];
 }
示例#5
0
 /**
  * @dataProvider getModuleAndEntityNamesProvider
  */
 public function testGetModuleAndEntityNames($className, $expectedModuleName, $expectedEntityName)
 {
     list($moduleName, $entityName) = ConfigHelper::getModuleAndEntityNames($className);
     $this->assertEquals($expectedModuleName, $moduleName);
     $this->assertEquals($expectedEntityName, $entityName);
 }