本文整理汇总了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));
}
示例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;
}
示例3: addProvider
/**
* @param ConfigProvider $provider
*/
public function addProvider(ConfigProvider $provider)
{
$this->providers[$provider->getScope()] = $provider;
}
示例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;
}