當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。