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


PHP ConfigManager::getProviders方法代码示例

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


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

示例1: 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();
         }
     }
     $builder->setData($data);
     $builder->addEventSubscriber(new ConfigSubscriber($this->doctrine, $this->configManager, $this->translator, $this->dbTranslationMetadataCache));
 }
开发者ID:ramunasd,项目名称:platform,代码行数:33,代码来源:ConfigType.php

示例2: writeItem

 /**
  * @param FieldConfigModel $configModel
  * @return array
  */
 protected function writeItem(FieldConfigModel $configModel)
 {
     $className = $configModel->getEntity()->getClassName();
     $fieldName = $configModel->getFieldName();
     $state = ExtendScope::STATE_UPDATE;
     if (!$this->configManager->hasConfig($className, $fieldName)) {
         $this->configManager->createConfigFieldModel($className, $fieldName, $configModel->getType());
         $state = ExtendScope::STATE_NEW;
     }
     $translations = [];
     foreach ($this->configManager->getProviders() as $provider) {
         $scope = $provider->getScope();
         $data = $configModel->toArray($scope);
         if (!$data) {
             continue;
         }
         $translations = array_merge($translations, $this->processData($provider, $provider->getConfig($className, $fieldName), $data, $state));
     }
     $this->setExtendData($className, $fieldName, $state);
     $this->updateEntityState($className);
     if ($state === ExtendScope::STATE_UPDATE && in_array($configModel->getType(), ['enum', 'multiEnum'], true)) {
         $this->setEnumData($configModel->toArray('enum'), $className, $fieldName);
     }
     return $translations;
 }
开发者ID:Maksold,项目名称:platform,代码行数:29,代码来源:EntityFieldWriter.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: normalize

 /**
  * {@inheritdoc}
  */
 public function normalize($object, $format = null, array $context = [])
 {
     $result = ['id' => $object->getId(), 'fieldName' => $object->getFieldName(), 'type' => $object->getType()];
     foreach ($this->configManager->getProviders() as $provider) {
         $scope = $provider->getScope();
         foreach ($object->toArray($scope) as $code => $value) {
             $result[sprintf('%s.%s', $scope, $code)] = $value;
         }
     }
     return $result;
 }
开发者ID:ramunasd,项目名称:platform,代码行数:14,代码来源:EntityFieldNormalizer.php

示例5: getFieldProperties

 /**
  * @param string $fieldType
  * @param string $configType
  * @return array
  */
 public function getFieldProperties($fieldType, $configType = PropertyConfigContainer::TYPE_FIELD)
 {
     $properties = [];
     foreach ($this->configManager->getProviders() as $provider) {
         $propertyConfig = $provider->getPropertyConfig();
         if ($propertyConfig->hasForm($configType, $fieldType)) {
             $items = $propertyConfig->getFormItems($configType, $fieldType);
             $scope = $provider->getScope();
             foreach ($items as $code => $config) {
                 if (!isset($properties[$scope][$code])) {
                     $properties[$scope][$code] = $config;
                 }
             }
         }
     }
     return $properties;
 }
开发者ID:Maksold,项目名称:platform,代码行数:22,代码来源:FieldTypeProvider.php

示例6: getEmptyData

 /**
  * @return array
  */
 protected function getEmptyData()
 {
     if (null === $this->emptyData) {
         $this->emptyData = [];
         $providers = $this->configManager->getProviders();
         foreach ($providers as $scope => $provider) {
             $this->emptyData[$scope] = [];
         }
     }
     return $this->emptyData;
 }
开发者ID:Maksold,项目名称:platform,代码行数:14,代码来源:ConfigCacheWarmer.php

示例7: postSubmit

 /**
  * @param FormEvent $event
  */
 public function postSubmit(FormEvent $event)
 {
     $options = $event->getForm()->getConfig()->getOptions();
     $configModel = $options['config_model'];
     if ($configModel instanceof FieldConfigModel) {
         $className = $configModel->getEntity()->getClassName();
         $fieldName = $configModel->getFieldName();
     } else {
         $fieldName = null;
         $className = $configModel->getClassName();
     }
     $data = $event->getData();
     foreach ($this->configManager->getProviders() as $provider) {
         if (isset($data[$provider->getScope()])) {
             $config = $provider->getConfig($className, $fieldName);
             $config->setValues($data[$provider->getScope()]);
             $this->configManager->persist($config);
         }
     }
     if ($event->getForm()->isValid()) {
         $this->configManager->flush();
     }
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:26,代码来源:ConfigSubscriber.php

示例8: postSubmit

 /**
  * @param FormEvent $event
  */
 public function postSubmit(FormEvent $event)
 {
     $form = $event->getForm();
     $configModel = $form->getConfig()->getOption('config_model');
     $data = $event->getData();
     $labelsToBeUpdated = [];
     foreach ($this->configManager->getProviders() as $provider) {
         $scope = $provider->getScope();
         if (isset($data[$scope])) {
             $configId = $this->configManager->getConfigIdByModel($configModel, $scope);
             $config = $provider->getConfigById($configId);
             $translatable = $provider->getPropertyConfig()->getTranslatableValues($configId);
             foreach ($data[$scope] as $code => $value) {
                 if (in_array($code, $translatable, true)) {
                     // check if a label text was changed
                     $labelKey = $config->get($code);
                     if (!$configModel->getId()) {
                         $labelsToBeUpdated[$labelKey] = $value;
                     } elseif ($value != $this->translator->trans($labelKey)) {
                         $labelsToBeUpdated[$labelKey] = $value;
                     }
                     // replace label text with label name in $value variable
                     $value = $config->get($code);
                 }
                 $config->set($code, $value);
             }
             $this->configManager->persist($config);
         }
     }
     if ($form->isValid()) {
         // update changed labels if any
         if (!empty($labelsToBeUpdated)) {
             /** @var EntityManager $translationEm */
             $translationEm = $this->doctrine->getManagerForClass(Translation::ENTITY_NAME);
             /** @var TranslationRepository $translationRepo */
             $translationRepo = $translationEm->getRepository(Translation::ENTITY_NAME);
             $values = [];
             $locale = $this->translator->getLocale();
             foreach ($labelsToBeUpdated as $labelKey => $labelText) {
                 // save into translation table
                 $values[] = $translationRepo->saveValue($labelKey, $labelText, $locale, TranslationRepository::DEFAULT_DOMAIN, Translation::SCOPE_UI);
             }
             // mark translation cache dirty
             $this->dbTranslationMetadataCache->updateTimestamp($locale);
             $translationEm->flush($values);
         }
         $this->configManager->flush();
     }
 }
开发者ID:Maksold,项目名称:platform,代码行数:52,代码来源:ConfigSubscriber.php

示例9: prepareQuery

 /**
  * @param QueryBuilder $query
  * @param string       $rootAlias
  * @param              $joinAlias
  * @param string       $itemsType
  *
  * @return $this
  */
 protected function prepareQuery(QueryBuilder $query, $rootAlias, $joinAlias, $itemsType)
 {
     foreach ($this->configManager->getProviders() as $provider) {
         foreach ($provider->getPropertyConfig()->getItems($itemsType) as $code => $item) {
             $alias = $joinAlias . $code;
             $fieldName = $provider->getScope() . '_' . $code;
             if (isset($item['grid']['query'])) {
                 $query->andWhere($alias . '.value ' . $item['grid']['query']['operator'] . ' :' . $alias);
                 $query->setParameter($alias, $item['grid']['query']['value']);
             }
             $query->leftJoin($rootAlias . '.values', $alias, 'WITH', $alias . ".code='" . $code . "' AND " . $alias . ".scope='" . $provider->getScope() . "'");
             $query->addSelect($alias . '.value as ' . $fieldName);
         }
     }
     return $this;
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:24,代码来源:AbstractConfigGridListener.php

示例10: testGetProviders

 public function testGetProviders()
 {
     $providers = $this->configManager->getProviders();
     $this->assertCount(1, $providers);
     $this->assertSame($this->configProvider, $providers['entity']);
 }
开发者ID:Maksold,项目名称:platform,代码行数:6,代码来源:ConfigManagerTest.php


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