本文整理汇总了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));
}
示例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;
}
示例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));
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
}
示例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();
}
}
示例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;
}
示例10: testGetProviders
public function testGetProviders()
{
$providers = $this->configManager->getProviders();
$this->assertCount(1, $providers);
$this->assertSame($this->configProvider, $providers['entity']);
}