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


PHP ConfigFactoryInterface::getEditable方法代码示例

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


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

示例1: onConfigSave

 /**
  * Causes the container to be rebuilt on the next request.
  *
  * This event subscriber assumes that the new default langcode and old default
  * langcode are valid langcodes. If the schema definition of either
  * system.site:default_langcode or language.negotiation::url.prefixes changes
  * then this event must be changed to work with both the old and new schema
  * definition so this event is update safe.
  *
  * @param ConfigCrudEvent $event
  *   The configuration event.
  */
 public function onConfigSave(ConfigCrudEvent $event)
 {
     $saved_config = $event->getConfig();
     if ($saved_config->getName() == 'system.site' && $event->isChanged('default_langcode')) {
         $new_default_langcode = $saved_config->get('default_langcode');
         $default_language = $this->configFactory->get('language.entity.' . $new_default_langcode);
         // During an import the language might not exist yet.
         if (!$default_language->isNew()) {
             $this->languageDefault->set(new Language($default_language->get()));
             $this->languageManager->reset();
             // Directly update language negotiation settings instead of calling
             // language_negotiation_url_prefixes_update() to ensure that the code
             // obeys the hook_update_N() restrictions.
             $negotiation_config = $this->configFactory->getEditable('language.negotiation');
             $negotiation_changed = FALSE;
             $url_prefixes = $negotiation_config->get('url.prefixes');
             $old_default_langcode = $saved_config->getOriginal('default_langcode');
             if (empty($url_prefixes[$old_default_langcode])) {
                 $negotiation_config->set('url.prefixes.' . $old_default_langcode, $old_default_langcode);
                 $negotiation_changed = TRUE;
             }
             if (empty($url_prefixes[$new_default_langcode])) {
                 $negotiation_config->set('url.prefixes.' . $new_default_langcode, '');
                 $negotiation_changed = TRUE;
             }
             if ($negotiation_changed) {
                 $negotiation_config->save(TRUE);
             }
         }
         // Trigger a container rebuild on the next request by invalidating it.
         ConfigurableLanguageManager::rebuildServices();
     }
 }
开发者ID:dmyerson,项目名称:d8ecs,代码行数:45,代码来源:ConfigSubscriber.php

示例2: getConfig

 /**
  * Gets the configuration object when needed.
  *
  * Since this service is injected into all static menu link objects, but
  * only used when updating one, avoid actually loading the config when it's
  * not needed.
  */
 protected function getConfig()
 {
     if (empty($this->config)) {
         // Get an override free and editable configuration object.
         $this->config = $this->configFactory->getEditable($this->configName);
     }
     return $this->config;
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:15,代码来源:StaticMenuLinkOverrides.php

示例3: markAsDefault

 /**
  * {@inheritdoc}
  */
 public function markAsDefault(StoreInterface $store)
 {
     $config = $this->configFactory->getEditable('commerce_store.settings');
     if ($config->get('default_store') != $store->uuid()) {
         $config->set('default_store', $store->uuid());
         $config->save();
     }
 }
开发者ID:alexburrows,项目名称:cream-2.x,代码行数:11,代码来源:StoreStorage.php

示例4: onMigratePostImport

 /**
  * @param \Drupal\migrate\Event\MigrateImportEvent $event
  */
 public function onMigratePostImport(MigrateImportEvent $event)
 {
     if ('basic_block' === $event->getMigration()->get('id')) {
         $files = ['block.block.callforpaper.yml', 'block.block.featuredfirst.yml', 'block.block.featuredsecond.yml', 'block.block.featuredthird.yml', 'block.block.mentorship.yml', 'block.block.training.yml'];
         foreach ($files as $file) {
             $base_path = $this->moduleHandler->getModule('ddd_fixtures')->getPath();
             $contents = @file_get_contents($base_path . '/sources/block_configs/' . $file);
             $config_name = basename('sources/block_configs/' . $file, '.yml');
             $data = (new InstallStorage())->decode($contents);
             $this->configFactory->getEditable($config_name)->setData($data)->save();
         }
     }
 }
开发者ID:itamair,项目名称:ddd-website,代码行数:16,代码来源:PostImportEventSubscriber.php

示例5: saveConfiguration

 /**
  * Saves the configuration.
  *
  * @param bool[] $configuration
  *   Keys are currency_exchanger plugin names. Values are booleans that
  *   describe whether the plugins are enabled. Items are ordered by weight.
  *
  * @return $this
  */
 public function saveConfiguration(array $configuration)
 {
     $config = $this->configFactory->getEditable('currency.exchange_rate_provider');
     // Massage the configuration into a format that can be stored, as
     // associative arrays are not supported by the config system
     $configuration_data = array();
     foreach ($configuration as $plugin_id => $status) {
         $configuration_data[] = array('plugin_id' => $plugin_id, 'status' => $status);
     }
     $config->set('plugins', $configuration_data);
     $config->save();
     return $this;
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:22,代码来源:PluginBasedExchangeRateProvider.php

示例6: revert

 /**
  * {@inheritdoc}
  */
 public function revert($type, $name)
 {
     // Read the config from the file.
     $full_name = $this->getFullName($type, $name);
     $value = $this->extensionConfigStorage->read($full_name);
     if (!$value) {
         $value = $this->extensionOptionalConfigStorage->read($full_name);
     }
     if (!$value) {
         return FALSE;
     }
     if ($type == 'system.simple') {
         // Load the current config and replace the value.
         $this->configFactory->getEditable($full_name)->setData($value)->save();
     } else {
         // Load the current config entity and replace the value, with the
         // old UUID.
         $definition = $this->entityManager->getDefinition($type);
         $id_key = $definition->getKey('id');
         $id = $value[$id_key];
         $entity_storage = $this->entityManager->getStorage($type);
         $entity = $entity_storage->load($id);
         $uuid = $entity->get('uuid');
         $entity = $entity_storage->updateFromStorageRecord($entity, $value);
         $entity->set('uuid', $uuid);
         $entity->save();
     }
     // Trigger an event notifying of this change.
     $event = new ConfigRevertEvent($type, $name);
     $this->dispatcher->dispatch(ConfigRevertInterface::REVERT, $event);
     return TRUE;
 }
开发者ID:selwynpolit,项目名称:d8_test2,代码行数:35,代码来源:ConfigReverter.php

示例7: uninstall

 /**
  * {@inheritdoc}
  */
 public function uninstall($type, $name)
 {
     $entities = $this->getConfigEntitiesToChangeOnDependencyRemoval($type, [$name], FALSE);
     // Fix all dependent configuration entities.
     /** @var \Drupal\Core\Config\Entity\ConfigEntityInterface $entity */
     foreach ($entities['update'] as $entity) {
         $entity->save();
     }
     // Remove all dependent configuration entities.
     foreach ($entities['delete'] as $entity) {
         $entity->setUninstalling(TRUE);
         $entity->delete();
     }
     $config_names = $this->configFactory->listAll($name . '.');
     foreach ($config_names as $config_name) {
         $this->configFactory->getEditable($config_name)->delete();
     }
     // Remove any matching configuration from collections.
     foreach ($this->activeStorage->getAllCollectionNames() as $collection) {
         $collection_storage = $this->activeStorage->createCollection($collection);
         $collection_storage->deleteAll($name . '.');
     }
     $schema_dir = drupal_get_path($type, $name) . '/' . InstallStorage::CONFIG_SCHEMA_DIRECTORY;
     if (is_dir($schema_dir)) {
         // Refresh the schema cache if uninstalling an extension that provides
         // configuration schema.
         $this->typedConfigManager->clearCachedDefinitions();
     }
 }
开发者ID:frankcr,项目名称:sftw8,代码行数:32,代码来源:ConfigManager.php

示例8: doSave

 /**
  * {@inheritdoc}
  */
 protected function doSave($id, EntityInterface $entity)
 {
     $is_new = $entity->isNew();
     $prefix = $this->getPrefix();
     $config_name = $prefix . $entity->id();
     if ($id !== $entity->id()) {
         // Renaming a config object needs to cater for:
         // - Storage needs to access the original object.
         // - The object needs to be renamed/copied in ConfigFactory and reloaded.
         // - All instances of the object need to be renamed.
         $this->configFactory->rename($prefix . $id, $config_name);
     }
     $config = $this->configFactory->getEditable($config_name);
     // Retrieve the desired properties and set them in config.
     $config->setData($this->mapToStorageRecord($entity));
     $config->save($entity->hasTrustedData());
     // Update the entity with the values stored in configuration. It is possible
     // that configuration schema has casted some of the values.
     if (!$entity->hasTrustedData()) {
         $data = $this->mapFromStorageRecords(array($config->get()));
         $updated_entity = current($data);
         foreach (array_keys($config->get()) as $property) {
             $value = $updated_entity->get($property);
             $entity->set($property, $value);
         }
     }
     return $is_new ? SAVED_NEW : SAVED_UPDATED;
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:31,代码来源:ConfigEntityStorage.php

示例9: __construct

 /**
  * Constructs a XmlSitemapGenerator object.
  *
  * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
  *   The config factory object.
  * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
  *   The entity manager handler.
  * @param \Drupal\Core\State\StateInterface $state
  *   The state handler.
  */
 public function __construct(ConfigFactoryInterface $config_factory, EntityManagerInterface $entity_manager, StateInterface $state, LanguageManagerInterface $language_manager)
 {
     $this->config = $config_factory->getEditable('xmlsitemap.settings');
     $this->entityManager = $entity_manager;
     $this->state = $state;
     $this->languageManager = $language_manager;
 }
开发者ID:jeroenos,项目名称:jeroenos_d8.mypressonline.com,代码行数:17,代码来源:XmlSitemapGenerator.php

示例10: getConfigData

 /**
  * {@inheritdoc}
  */
 public function getConfigData()
 {
     $config_data = array();
     foreach ($this->getConfigNames() as $name) {
         $config_data[$name] = $this->configFactory->getEditable($name)->get();
     }
     return $config_data;
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:11,代码来源:ConfigNamesMapper.php

示例11: setDefault

 /**
  * {@inheritdoc}
  */
 public function setDefault($name)
 {
     $list = $this->listInfo();
     if (!isset($list[$name])) {
         throw new \InvalidArgumentException("{$name} theme is not installed.");
     }
     $this->configFactory->getEditable('system.theme')->set('default', $name)->save();
     return $this;
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:12,代码来源:ThemeHandler.php

示例12: __construct

 /**
  * Constructs a ImageEffectsPluginBase object.
  *
  * @param array $configuration
  *   A configuration array containing information about the plugin instance.
  * @param string $plugin_id
  *   The plugin_id for the plugin instance.
  * @param mixed $plugin_definition
  *   The plugin implementation definition.
  * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
  *   The configuration factory.
  * @param \Drupal\Core\Routing\UrlGeneratorInterface $url_generator
  *   The URL generator.
  * @param \Psr\Log\LoggerInterface $logger
  *   The image_effects logger.
  */
 public function __construct(array $configuration, $plugin_id, $plugin_definition, ConfigFactoryInterface $config_factory, UrlGeneratorInterface $url_generator, LoggerInterface $logger)
 {
     $this->config = $config_factory->getEditable('image_effects.settings');
     parent::__construct($configuration, $plugin_id, $plugin_definition);
     $this->pluginType = $configuration['plugin_type'];
     $config = $this->config->get($this->pluginType . '.plugin_settings.' . $plugin_id);
     $this->setConfiguration(array_merge($this->defaultConfiguration(), is_array($config) ? $config : array()));
     $this->urlGenerator = $url_generator;
     $this->logger = $logger;
 }
开发者ID:andrewl,项目名称:andrewlnet,代码行数:26,代码来源:ImageEffectsPluginBase.php

示例13: saveLanguageTypesConfiguration

 /**
  * {@inheritdoc}
  */
 public function saveLanguageTypesConfiguration(array $values)
 {
     $config = $this->configFactory->getEditable('language.types');
     if (isset($values['configurable'])) {
         $config->set('configurable', $values['configurable']);
     }
     if (isset($values['all'])) {
         $config->set('all', $values['all']);
     }
     $config->save();
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:14,代码来源:ConfigurableLanguageManager.php

示例14: onOverrideChange

 /**
  * Updates the locale strings when a configuration override is saved/deleted.
  *
  * @param \Drupal\language\Config\LanguageConfigOverrideCrudEvent $event
  *   The language configuration event.
  */
 public function onOverrideChange(LanguageConfigOverrideCrudEvent $event)
 {
     // Only attempt to feed back configuration override changes to locale if
     // the update itself was not initiated by locale data changes.
     if (!drupal_installation_attempted() && !$this->localeConfigManager->isUpdatingTranslationsFromLocale()) {
         $translation_config = $event->getLanguageConfigOverride();
         $langcode = $translation_config->getLangcode();
         $reference_config = $this->configFactory->getEditable($translation_config->getName())->get();
         $this->updateLocaleStorage($translation_config, $langcode, $reference_config);
     }
 }
开发者ID:sarahwillem,项目名称:OD8,代码行数:17,代码来源:LocaleConfigSubscriber.php

示例15: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $key = $this->entity_type_parameter . '_' . $this->entity_type_id;
     $userInputValues = $form_state->getUserInput();
     $config = $this->configFactory->getEditable('auto_entitylabel.settings');
     $config->set('auto_entitylabel_php_' . $key, $userInputValues['auto_entitylabel_php_' . $key]);
     $config->set('auto_entitylabel_pattern_' . $key, $userInputValues['auto_entitylabel_pattern_' . $key]);
     $config->set('auto_entitylabel_' . $key, $userInputValues['auto_entitylabel_' . $key]);
     $config->save();
     parent::submitForm($form, $form_state);
 }
开发者ID:itspkrai,项目名称:auto_entitylabel,代码行数:14,代码来源:AutoEntityLabelForm.php


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