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


PHP TypedConfigManagerInterface::get方法代码示例

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


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

示例1: getConfigSchema

 /**
  * Provides configuration schema.
  *
  * @param string $name
  *   A string config key.
  *
  * @return array|null
  */
 public function getConfigSchema($name)
 {
     $old_state = $this->configFactory->getOverrideState();
     $this->configFactory->setOverrideState(FALSE);
     $config_schema = $this->typedConfigManager->get($name);
     $this->configFactory->setOverrideState($old_state);
     return $config_schema;
 }
开发者ID:njcameron,项目名称:ncmd,代码行数:16,代码来源:ConfigInspectorManager.php

示例2: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $form_values = $form_state->getValue(array('translation', 'config_names'));
     foreach ($this->mapper->getConfigNames() as $name) {
         $schema = $this->typedConfigManager->get($name);
         // Set configuration values based on form submission and source values.
         $base_config = $this->configFactory()->getEditable($name);
         $config_translation = $this->languageManager->getLanguageConfigOverride($this->language->getId(), $name);
         $element = $this->createFormElement($schema);
         $element->setConfig($base_config, $config_translation, $form_values[$name]);
         // If no overrides, delete language specific configuration file.
         $saved_config = $config_translation->get();
         if (empty($saved_config)) {
             $config_translation->delete();
         } else {
             $config_translation->save();
         }
     }
     $form_state->setRedirect($this->mapper->getOverviewRoute(), $this->mapper->getOverviewRouteParameters());
 }
开发者ID:HakS,项目名称:drupal8_training,代码行数:23,代码来源:ConfigTranslationFormBase.php

示例3: buildForm

 /**
  * Implements \Drupal\Core\Form\FormInterface::buildForm().
  *
  * Builds configuration form with metadata and values from the source
  * language.
  *
  * @param array $form
  *   An associative array containing the structure of the form.
  * @param array $form_state
  *   An associative array containing the current state of the form.
  * @param \Symfony\Component\HttpFoundation\Request $request
  *   (optional) Page request object.
  * @param string $plugin_id
  *   (optional) The plugin ID of the mapper.
  * @param string $langcode
  *   (optional) The language code of the language the form is adding or
  *   editing.
  *
  * @return array
  *   The form structure.
  *
  * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
  *   Throws an exception if the language code provided as a query parameter in
  *   the request does not match an active language.
  */
 public function buildForm(array $form, array &$form_state, Request $request = NULL, $plugin_id = NULL, $langcode = NULL)
 {
     /** @var \Drupal\config_translation\ConfigMapperInterface $mapper */
     $mapper = $this->configMapperManager->createInstance($plugin_id);
     $mapper->populateFromRequest($request);
     $language = language_load($langcode);
     if (!$language) {
         throw new NotFoundHttpException();
     }
     $this->mapper = $mapper;
     $this->language = $language;
     $this->sourceLanguage = $this->mapper->getLanguageWithFallback();
     // Get base language configuration to display in the form before setting the
     // language to use for the form. This avoids repetitively settings and
     // resetting the language to get original values later.
     $config_factory = $this->configFactory();
     $old_state = $config_factory->getOverrideState();
     $config_factory->setOverrideState(FALSE);
     $this->baseConfigData = $this->mapper->getConfigData();
     $config_factory->setOverrideState($old_state);
     // Set the translation target language on the configuration factory.
     $original_language = $this->languageManager->getConfigOverrideLanguage();
     $this->languageManager->setConfigOverrideLanguage($this->language);
     // Add some information to the form state for easier form altering.
     $form_state['config_translation_mapper'] = $this->mapper;
     $form_state['config_translation_language'] = $this->language;
     $form_state['config_translation_source_language'] = $this->sourceLanguage;
     $form['#attached']['library'][] = 'config_translation/drupal.config_translation.admin';
     $form['config_names'] = array('#type' => 'container', '#tree' => TRUE);
     foreach ($this->mapper->getConfigNames() as $name) {
         $form['config_names'][$name] = array('#type' => 'container');
         $form['config_names'][$name] += $this->buildConfigForm($this->typedConfigManager->get($name), $config_factory->get($name)->get(), $this->baseConfigData[$name]);
     }
     $form['actions']['#type'] = 'actions';
     $form['actions']['submit'] = array('#type' => 'submit', '#value' => $this->t('Save translation'), '#button_type' => 'primary');
     // Set the configuration language back.
     $this->languageManager->setConfigOverrideLanguage($original_language);
     return $form;
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:64,代码来源:ConfigTranslationFormBase.php

示例4: hasTranslatable

 /**
  * {@inheritdoc}
  */
 public function hasTranslatable($name)
 {
     return $this->findTranslatable($this->typedConfigManager->get($name));
 }
开发者ID:RealLukeMartin,项目名称:drupal8tester,代码行数:7,代码来源:ConfigMapperManager.php

示例5: getConfigSchema

 /**
  * Provides configuration schema.
  *
  * @param string $name
  *   A string config key.
  *
  * @return array|null
  */
 public function getConfigSchema($name)
 {
     return $this->typedConfigManager->get($name);
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:12,代码来源:ConfigInspectorManager.php


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