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


PHP ConfigProvider::getScope方法代码示例

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


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

示例1: testConfig

 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));
 }
开发者ID:ramunasd,项目名称:platform,代码行数:13,代码来源:ConfigProviderTest.php

示例2: processData

 /**
  * @param ConfigProvider $provider
  * @param ConfigInterface $config
  * @param array $data
  * @param string $state
  * @return array
  */
 protected function processData(ConfigProvider $provider, ConfigInterface $config, array $data, $state)
 {
     if ($provider->getScope() === 'enum' && $config->get('enum_code')) {
         return [];
     }
     $translatable = $provider->getPropertyConfig()->getTranslatableValues($config->getId());
     $translations = [];
     foreach ($data as $code => $value) {
         if (in_array($code, $translatable, true)) {
             // check if a label text was changed
             $labelKey = $config->get($code);
             if ($state === ExtendScope::STATE_NEW || !$this->translationHelper->isTranslationEqual($labelKey, $value)) {
                 $translations[$labelKey] = $value;
             }
             // replace label text with label name in $value variable
             $value = $labelKey;
         }
         $config->set($code, $value);
     }
     $this->configManager->persist($config);
     return $translations;
 }
开发者ID:Maksold,项目名称:platform,代码行数:29,代码来源:EntityFieldWriter.php

示例3: addProvider

 /**
  * @param ConfigProvider $provider
  */
 public function addProvider(ConfigProvider $provider)
 {
     $this->providers[$provider->getScope()] = $provider;
 }
开发者ID:Maksold,项目名称:platform,代码行数:7,代码来源:ConfigManager.php

示例4: getFieldDefaultValues

 /**
  * Extracts field default values from an annotation and config file
  *
  * @param ConfigProvider     $provider
  * @param string             $className
  * @param string             $fieldName
  * @param string             $fieldType
  * @param FieldMetadata|null $metadata
  * @return array
  */
 protected function getFieldDefaultValues(ConfigProvider $provider, $className, $fieldName, $fieldType, $metadata = null)
 {
     $defaultValues = [];
     $scope = $provider->getScope();
     // try to get default values from an annotation
     if ($metadata && isset($metadata->defaultValues[$scope])) {
         $defaultValues = $metadata->defaultValues[$scope];
     }
     // combine them with default values from a config file
     $defaultValues = array_merge($provider->getPropertyConfig()->getDefaultValues(PropertyConfigContainer::TYPE_FIELD, $fieldType), $defaultValues);
     // process translatable values
     $translatablePropertyNames = $provider->getPropertyConfig()->getTranslatableValues(PropertyConfigContainer::TYPE_FIELD);
     foreach ($translatablePropertyNames as $propertyName) {
         if (empty($defaultValues[$propertyName])) {
             $defaultValues[$propertyName] = ConfigHelper::getTranslationKey($scope, $propertyName, $className, $fieldName);
         }
     }
     return $defaultValues;
 }
开发者ID:nmallare,项目名称:platform,代码行数:29,代码来源:ConfigManager.php


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