当前位置: 首页>>代码示例>>PHP>>正文


PHP ConfigManager::getEntityManager方法代码示例

本文整理汇总了PHP中Oro\Bundle\EntityConfigBundle\Config\ConfigManager::getEntityManager方法的典型用法代码示例。如果您正苦于以下问题:PHP ConfigManager::getEntityManager方法的具体用法?PHP ConfigManager::getEntityManager怎么用?PHP ConfigManager::getEntityManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Oro\Bundle\EntityConfigBundle\Config\ConfigManager的用法示例。


在下文中一共展示了ConfigManager::getEntityManager方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: generateProxies

 /**
  * Generate doctrine proxy classes for extended entities
  */
 public function generateProxies()
 {
     $em = $this->configManager->getEntityManager();
     $isAutoGenerated = $em->getConfiguration()->getAutoGenerateProxyClasses();
     if (!$isAutoGenerated) {
         $proxyDir = $em->getConfiguration()->getProxyDir();
         if (!empty($this->cacheDir) && $this->kernelCacheDir !== $this->cacheDir && strpos($proxyDir, $this->kernelCacheDir) === 0) {
             $proxyDir = $this->cacheDir . substr($proxyDir, strlen($this->kernelCacheDir));
         }
         $extendConfigProvider = $this->configManager->getProvider('extend');
         $extendConfigs = $extendConfigProvider->getConfigs(null, true);
         $metadataFactory = $em->getMetadataFactory();
         $proxyFactory = $em->getProxyFactory();
         foreach ($extendConfigs as $extendConfig) {
             if (!$extendConfig->is('is_extend')) {
                 continue;
             }
             if ($extendConfig->in('state', [ExtendScope::STATE_NEW])) {
                 continue;
             }
             $entityClass = $extendConfig->getId()->getClassName();
             $proxyFileName = $proxyDir . DIRECTORY_SEPARATOR . '__CG__' . str_replace('\\', '', $entityClass) . '.php';
             $metadata = $metadataFactory->getMetadataFor($entityClass);
             $proxyFactory->generateProxyClasses([$metadata], $proxyDir);
             clearstatcache(true, $proxyFileName);
         }
     }
 }
开发者ID:northdakota,项目名称:platform,代码行数:31,代码来源:EntityProxyGenerator.php

示例2: __construct

 /**
  * @param ConfigManager $configManager
  */
 public function __construct(ConfigManager $configManager)
 {
     $this->configManager = $configManager;
     $this->em = $this->configManager->getEntityManager();
     $this->options = $this->em->getRepository(OptionSet::ENTITY_NAME);
     $this->relations = $this->em->getRepository(OptionSetRelation::ENTITY_NAME);
 }
开发者ID:xamin123,项目名称:platform,代码行数:10,代码来源:OptionSelectType.php

示例3: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $configModel = $options['config_model'];
     $data = array();
     if ($configModel instanceof FieldConfigModel) {
         $className = $configModel->getEntity()->getClassName();
         $fieldName = $configModel->getFieldName();
         $fieldType = $configModel->getType();
         $configType = PropertyConfigContainer::TYPE_FIELD;
     } else {
         $className = $configModel->getClassName();
         $fieldName = null;
         $fieldType = null;
         $configType = PropertyConfigContainer::TYPE_ENTITY;
     }
     foreach ($this->configManager->getProviders() as $provider) {
         if ($provider->getPropertyConfig()->hasForm($configType, $fieldType)) {
             $config = $provider->getConfig($className, $fieldName);
             $builder->add($provider->getScope(), new ConfigScopeType($provider->getPropertyConfig()->getFormItems($configType, $fieldType), $config, $this->configManager, $configModel), array('block_config' => (array) $provider->getPropertyConfig()->getFormBlockConfig($configType)));
             $data[$provider->getScope()] = $config->all();
         }
     }
     if ($fieldType == 'optionSet') {
         $data['extend']['set_options'] = $this->configManager->getEntityManager()->getRepository(OptionSet::ENTITY_NAME)->findOptionsByField($configModel->getId());
     }
     $builder->setData($data);
     $builder->addEventSubscriber(new ConfigSubscriber($this->configManager));
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:31,代码来源:ConfigType.php

示例4: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $configModel = $options['config_model'];
     $data = array();
     if ($configModel instanceof FieldConfigModel) {
         $className = $configModel->getEntity()->getClassName();
         $fieldName = $configModel->getFieldName();
         $fieldType = $configModel->getType();
         $configType = PropertyConfigContainer::TYPE_FIELD;
         /**
          * Add read only field name and field type
          */
         $builder->add('fieldName', 'text', array('label' => 'oro.entity_config.form.name.label', 'block' => 'general', 'disabled' => true, 'data' => $fieldName));
         $builder->add('type', 'choice', array('label' => 'oro.entity_config.form.type.label', 'choices' => [], 'block' => 'general', 'disabled' => true, 'empty_value' => 'oro.entity_extend.form.data_type.' . $fieldType));
     } else {
         $className = $configModel->getClassName();
         $fieldName = null;
         $fieldType = null;
         $configType = PropertyConfigContainer::TYPE_ENTITY;
     }
     foreach ($this->configManager->getProviders() as $provider) {
         if ($provider->getPropertyConfig()->hasForm($configType, $fieldType)) {
             $config = $this->configManager->getConfig($provider->getId($className, $fieldName, $fieldType));
             $builder->add($provider->getScope(), new ConfigScopeType($provider->getPropertyConfig()->getFormItems($configType, $fieldType), $config, $this->configManager, $configModel), array('block_config' => $this->getFormBlockConfig($provider, $configType)));
             $data[$provider->getScope()] = $config->all();
         }
     }
     /** @deprecated since 1.4, will be removed in 2.0 */
     if ($fieldType == 'optionSet') {
         $data['extend']['set_options'] = $this->configManager->getEntityManager()->getRepository(OptionSet::ENTITY_NAME)->findOptionsByField($configModel->getId());
     }
     $builder->setData($data);
     $builder->addEventSubscriber(new ConfigSubscriber($this->configManager, $this->translator, $this->dbTranslationMetadataCache));
 }
开发者ID:xamin123,项目名称:platform,代码行数:37,代码来源:ConfigType.php

示例5: getObjectName

 /**
  *
  * @param  string $scope
  * @return array
  */
 protected function getObjectName($scope = 'name')
 {
     if (empty($this->filterChoices[$scope])) {
         $alias = 'ce';
         $qb = $this->configManager->getEntityManager()->createQueryBuilder();
         $qb->select($alias)->from(EntityConfigModel::ENTITY_NAME, $alias)->add('select', $alias . '.className')->distinct($alias . '.className');
         $result = $qb->getQuery()->getArrayResult();
         $options = ['name' => [], 'module' => []];
         foreach ((array) $result as $value) {
             $className = explode('\\', $value['className']);
             $options['name'][$value['className']] = '';
             $options['module'][$value['className']] = '';
             if (strpos($value['className'], 'Extend\\Entity') === false) {
                 foreach ($className as $index => $name) {
                     if (count($className) - 1 == $index) {
                         $options['name'][$value['className']] = $name;
                     } elseif (!in_array($name, array('Bundle', 'Entity'))) {
                         $options['module'][$value['className']] .= $name;
                     }
                 }
             } else {
                 $options['name'][$value['className']] = str_replace('Extend\\Entity\\', '', $value['className']);
                 $options['module'][$value['className']] = 'System';
             }
         }
         $this->filterChoices = $options;
     }
     return $this->filterChoices[$scope];
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:34,代码来源:EntityConfigGridListener.php

示例6: getPrimaryKeyColumnNames

 /**
  * @param string $entityClass
  *
  * @return string[]
  */
 protected function getPrimaryKeyColumnNames($entityClass)
 {
     try {
         return $this->configManager->getEntityManager()->getClassMetadata($entityClass)->getIdentifierColumnNames();
     } catch (\ReflectionException $e) {
         // ignore entity not found exception
         return ['id'];
     } catch (ORMMappingException $e) {
         return ['id'];
     } catch (PersistenceMappingException $e) {
         return ['id'];
     }
 }
开发者ID:xamin123,项目名称:platform,代码行数:18,代码来源:AssociationBuilder.php

示例7: loadConfigurableFields

 /**
  * @param array $classMap [class_name => entity_config_id, ...]
  *
  * @return array [entity_config_id => [field_name => is_configurable, ...], ...]
  */
 protected function loadConfigurableFields(array $classMap)
 {
     $connection = $this->configManager->getEntityManager()->getConnection();
     $fieldRows = $connection->executeQuery('SELECT id, entity_id, field_name, type, mode, data FROM oro_entity_config_field');
     $configurable = [];
     $fields = [];
     foreach ($fieldRows as $row) {
         $fieldId = (int) $row['id'];
         $entityId = (int) $row['entity_id'];
         if (!isset($classMap[$entityId])) {
             continue;
         }
         $className = $classMap[$entityId];
         $fieldName = $row['field_name'];
         $fieldType = $row['type'];
         $isHidden = $row['mode'] === ConfigModel::MODE_HIDDEN;
         $data = array_merge($this->getEmptyData(), $connection->convertToPHPValue($row['data'], 'array'));
         $configurable[$entityId][$fieldName] = true;
         $fields[$className][$fieldName] = ['i' => $fieldId, 'h' => $isHidden, 't' => $fieldType];
         $this->cache->saveFieldConfigValues($data, $className, $fieldName, $fieldType);
     }
     foreach ($fields as $className => $values) {
         $this->cache->saveFields($className, $values);
     }
     return $configurable;
 }
开发者ID:Maksold,项目名称:platform,代码行数:31,代码来源:ConfigCacheWarmer.php

示例8: __construct

 /**
  * @param ConfigManager                   $configManager
  * @param Translator                      $translator
  * @param DynamicTranslationMetadataCache $dbTranslationMetadataCache
  */
 public function __construct(ConfigManager $configManager, Translator $translator, DynamicTranslationMetadataCache $dbTranslationMetadataCache)
 {
     $this->configManager = $configManager;
     $this->translator = $translator;
     $this->dbTranslationMetadataCache = $dbTranslationMetadataCache;
     $this->em = $configManager->getEntityManager();
 }
开发者ID:xamin123,项目名称:platform,代码行数:12,代码来源:ConfigSubscriber.php

示例9: getValueForOptionSet

 /**
  * @param object $entity
  * @param FieldConfigId $fieldConfig
  * @return OptionSetRelation[]
  */
 protected function getValueForOptionSet($entity, FieldConfigId $fieldConfig)
 {
     /** @var $optionSetRepository OptionSetRelationRepository */
     $optionSetRepository = $this->configManager->getEntityManager()->getRepository(OptionSetRelation::ENTITY_NAME);
     $model = $this->configManager->getConfigFieldModel($fieldConfig->getClassName(), $fieldConfig->getFieldName());
     $value = $optionSetRepository->findByFieldId($model->getId(), $entity->getId());
     array_walk($value, function (OptionSetRelation &$item) {
         $item = array('title' => $item->getOption()->getLabel());
     });
     $value['values'] = $value;
     return $value;
 }
开发者ID:xamin123,项目名称:platform,代码行数:17,代码来源:DynamicFieldsExtension.php

示例10: postSubmitData

 /**
  * @param FormEvent $event
  */
 public function postSubmitData(FormEvent $event)
 {
     $form = $event->getForm();
     $data = $event->getData();
     /** @var FieldConfigModel $configModel */
     $configModel = $form->getRoot()->getConfig()->getOptions()['config_model'];
     if (count($data)) {
         $em = $this->configManager->getEntityManager();
         $optionValues = $oldOptions = $configModel->getOptions()->getValues();
         $newOptions = [];
         array_walk_recursive($oldOptions, function (&$oldOption) {
             $oldOption = $oldOption->getId();
         });
         foreach ($data as $option) {
             if (is_array($option)) {
                 $optionSet = new OptionSet();
                 $optionSet->setField($configModel);
                 $optionSet->setData($option['id'], $option['priority'], $option['label'], (bool) $option['default']);
             } elseif (!$option->getId()) {
                 $optionSet = $option;
                 $optionSet->setField($configModel);
             } else {
                 $optionSet = $option;
             }
             if ($optionSet->getLabel() != null) {
                 $newOptions[] = $optionSet->getId();
             }
             if (!in_array($optionSet, $optionValues) && $optionSet->getLabel() != null) {
                 $em->persist($optionSet);
             }
         }
         $delOptions = array_diff($oldOptions, $newOptions);
         foreach ($delOptions as $key => $delOption) {
             $em->remove($configModel->getOptions()->getValues()[$key]);
         }
         $em->flush();
     }
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:41,代码来源:OptionSetCollectionType.php

示例11: load

 /**
  * Load entity configs from annotations to a database
  *
  * @param bool                 $force  Force overwrite config's option values
  * @param callable|null        $filter function (ClassMetadataInfo[] $doctrineAllMetadata)
  * @param LoggerInterface|null $logger
  * @param bool                 $dryRun Log modifications without apply them
  * @throws \Exception
  */
 public function load($force = false, \Closure $filter = null, LoggerInterface $logger = null, $dryRun = false)
 {
     $this->logger = $logger ?: new NullLogger();
     try {
         /** @var ClassMetadataInfo[] $doctrineAllMetadata */
         $doctrineAllMetadata = $this->configManager->getEntityManager()->getMetadataFactory()->getAllMetadata();
         if (null !== $filter) {
             $doctrineAllMetadata = $filter($doctrineAllMetadata);
         }
         foreach ($doctrineAllMetadata as $metadata) {
             $this->loadEntityConfigs($metadata, $force);
         }
         if ($dryRun) {
             $this->configManager->clear();
         } else {
             $this->configManager->flush();
             $this->configManager->clearCache();
             $this->configManager->clearConfigurableCache();
         }
     } catch (\Exception $ex) {
         $this->logger = null;
         throw $ex;
     }
 }
开发者ID:xamin123,项目名称:platform,代码行数:33,代码来源:ConfigLoader.php

示例12: generateProxies

 /**
  * Generate doctrine proxy classes for extended entities
  */
 public function generateProxies()
 {
     $em = $this->configManager->getEntityManager();
     $isAutoGenerated = $em->getConfiguration()->getAutoGenerateProxyClasses();
     if (!$isAutoGenerated) {
         $extendConfigProvider = $this->configManager->getProvider('extend');
         $entityConfigs = $extendConfigProvider->getConfigs(null, true);
         foreach ($entityConfigs as $entityConfig) {
             if (!$entityConfig->is('is_extend')) {
                 continue;
             }
             if ($entityConfig->in('state', [ExtendScope::STATE_NEW])) {
                 continue;
             }
             $proxyFileName = $em->getConfiguration()->getProxyDir() . DIRECTORY_SEPARATOR . '__CG__' . str_replace('\\', '', $entityConfig->getId()->getClassName()) . '.php';
             if (!file_exists($proxyFileName)) {
                 $proxyFactory = $em->getProxyFactory();
                 $proxyDir = $em->getConfiguration()->getProxyDir();
                 $meta = $em->getClassMetadata($entityConfig->getId()->getClassName());
                 $proxyFactory->generateProxyClasses([$meta], $proxyDir);
             }
         }
     }
 }
开发者ID:xamin123,项目名称:platform,代码行数:27,代码来源:EntityProcessor.php

示例13: createEntityModel

 /**
  * @param $entityName
  * @param $entityConfig
  * @return void
  */
 protected function createEntityModel($entityName, $entityConfig)
 {
     $mode = isset($entityConfig['mode']) ? $entityConfig['mode'] : ConfigModelManager::MODE_DEFAULT;
     $this->configManager->createConfigEntityModel($entityName, $mode);
     if (class_exists($entityName)) {
         $doctrineMetadata = $this->configManager->getEntityManager()->getClassMetadata($entityName);
         foreach ($doctrineMetadata->getFieldNames() as $fieldName) {
             $type = $doctrineMetadata->getTypeOfField($fieldName);
             $this->configManager->createConfigFieldModel($doctrineMetadata->getName(), $fieldName, $type);
         }
         foreach ($doctrineMetadata->getAssociationNames() as $fieldName) {
             $type = $doctrineMetadata->isSingleValuedAssociation($fieldName) ? 'ref-one' : 'ref-many';
             $this->configManager->createConfigFieldModel($doctrineMetadata->getName(), $fieldName, $type);
         }
     }
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:21,代码来源:InitCommand.php

示例14: prepareEntityName

 /**
  * Gets the full class name for the given entity name
  *
  * @param string $entityName
  *
  * @return string
  */
 protected function prepareEntityName($entityName)
 {
     return $this->configManager->getEntityManager()->getClassMetadata($entityName)->getName();
 }
开发者ID:xamin123,项目名称:platform,代码行数:11,代码来源:AbstractFieldsExtension.php


注:本文中的Oro\Bundle\EntityConfigBundle\Config\ConfigManager::getEntityManager方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。