本文整理汇总了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;
}
示例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());
}
示例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;
}
示例4: hasTranslatable
/**
* {@inheritdoc}
*/
public function hasTranslatable($name)
{
return $this->findTranslatable($this->typedConfigManager->get($name));
}
示例5: getConfigSchema
/**
* Provides configuration schema.
*
* @param string $name
* A string config key.
*
* @return array|null
*/
public function getConfigSchema($name)
{
return $this->typedConfigManager->get($name);
}