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


PHP TypedConfigManagerInterface::getDefinition方法代码示例

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


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

示例1: checkConfigSchema

 /**
  * Checks the TypedConfigManager has a valid schema for the configuration.
  *
  * @param \Drupal\Core\Config\TypedConfigManagerInterface $typed_config
  *   The TypedConfigManager.
  * @param string $config_name
  *   The configuration name.
  * @param array $config_data
  *   The configuration data, assumed to be data for a top-level config object.
  *
  * @return array|bool
  *   FALSE if no schema found. List of errors if any found. TRUE if fully
  *   valid.
  */
 public function checkConfigSchema(TypedConfigManagerInterface $typed_config, $config_name, $config_data)
 {
     // We'd like to verify that the top-level type is either config_base,
     // config_entity, or a derivative. The only thing we can really test though
     // is that the schema supports having langcode in it. So add 'langcode' to
     // the data if it doesn't already exist.
     if (!isset($config_data['langcode'])) {
         $config_data['langcode'] = 'en';
     }
     $this->configName = $config_name;
     if (!$typed_config->hasConfigSchema($config_name)) {
         return FALSE;
     }
     $definition = $typed_config->getDefinition($config_name);
     $data_definition = $typed_config->buildDataDefinition($definition, $config_data);
     $this->schema = $typed_config->create($data_definition, $config_data);
     $errors = array();
     foreach ($config_data as $key => $value) {
         $errors = array_merge($errors, $this->checkValue($key, $value));
     }
     if (empty($errors)) {
         return TRUE;
     }
     return $errors;
 }
开发者ID:ravindrasingh22,项目名称:Drupal-8-rc,代码行数:39,代码来源:SchemaCheckTrait.php

示例2: getSchemaWrapper

 /**
  * Gets the schema wrapper for the whole configuration object.
  *
  * The schema wrapper is dependent on the configuration name and the whole
  * data structure, so if the name or the data changes in any way, the wrapper
  * should be reset.
  *
  * @return \Drupal\Core\Config\Schema\Element
  */
 protected function getSchemaWrapper()
 {
     if (!isset($this->schemaWrapper)) {
         $definition = $this->typedConfigManager->getDefinition($this->name);
         $data_definition = $this->typedConfigManager->buildDataDefinition($definition, $this->data);
         $this->schemaWrapper = $this->typedConfigManager->create($data_definition, $this->data);
     }
     return $this->schemaWrapper;
 }
开发者ID:nsp15,项目名称:Drupal8,代码行数:18,代码来源:StorableConfigBase.php

示例3: validate

 /**
  * Validates the config against the schema.
  *
  * @param array $config
  *   The configuration data.
  *
  * @throws \Exception
  *   If the configuration doesn't validate.
  */
 protected function validate(array $config)
 {
     $this->configName = 'display_variant.plugin.panels_variant';
     $definition = $this->typedConfigManager->getDefinition($this->configName);
     $data_definition = $this->typedConfigManager->buildDataDefinition($definition, $config);
     $this->schema = $this->typedConfigManager->create($data_definition, $config);
     $errors = array();
     foreach ($config as $key => $value) {
         $errors = array_merge($errors, $this->checkValue($key, $value));
     }
     if (!empty($errors)) {
         $error_list = [];
         foreach ($errors as $key => $error) {
             $error_list[] = $key . ': ' . $error;
         }
         throw new \Exception("Config for Panels display doesn't validate: " . implode(', ', $error_list));
     }
 }
开发者ID:neeravbm,项目名称:unify-d8,代码行数:27,代码来源:PanelsDisplayManager.php

示例4: getTranslatableDefaultConfig

 /**
  * Gets array of translated strings for Locale translatable configuration.
  *
  * @param string $name
  *   Configuration object name.
  *
  * @return array
  *   Array of Locale translatable elements of the default configuration in
  *   $name.
  */
 public function getTranslatableDefaultConfig($name)
 {
     if ($this->isSupported($name)) {
         // Create typed configuration wrapper based on install storage data.
         $data = $this->defaultConfigStorage->read($name);
         $type_definition = $this->typedConfigManager->getDefinition($name);
         $data_definition = $this->typedConfigManager->buildDataDefinition($type_definition, $data);
         $typed_config = $this->typedConfigManager->create($data_definition, $data);
         if ($typed_config instanceof TraversableTypedDataInterface) {
             return $this->getTranslatableData($typed_config);
         }
     }
     return array();
 }
开发者ID:sgtsaughter,项目名称:d8portfolio,代码行数:24,代码来源:LocaleConfigManager.php

示例5: get

 /**
  * Gets locale wrapper with typed configuration data.
  *
  * @param string $name
  *   Configuration object name.
  *
  * @return \Drupal\locale\LocaleTypedConfig
  *   Locale-wrapped configuration element.
  */
 public function get($name)
 {
     // Read default and current configuration data.
     $default = $this->installStorage->read($name);
     $updated = $this->configStorage->read($name);
     // We get only the data that didn't change from default.
     $data = $this->compareConfigData($default, $updated);
     $definition = $this->typedConfigManager->getDefinition($name);
     $data_definition = $this->typedConfigManager->buildDataDefinition($definition, $data);
     // Unless the configuration has a explicit language code we assume English.
     $langcode = isset($default['langcode']) ? $default['langcode'] : 'en';
     $wrapper = new LocaleTypedConfig($data_definition, $name, $langcode, $this, $this->typedConfigManager);
     $wrapper->setValue($data);
     return $wrapper;
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:24,代码来源:LocaleConfigManager.php

示例6: checkConfigSchema

 /**
  * Checks the TypedConfigManager has a valid schema for the configuration.
  *
  * @param \Drupal\Core\Config\TypedConfigManagerInterface $typed_config
  *   The TypedConfigManager.
  * @param string $config_name
  *   The configuration name.
  * @param array $config_data
  *   The configuration data.
  *
  * @return array|bool
  *   FALSE if no schema found. List of errors if any found. TRUE if fully
  *   valid.
  */
 public function checkConfigSchema(TypedConfigManagerInterface $typed_config, $config_name, $config_data)
 {
     $this->configName = $config_name;
     if (!$typed_config->hasConfigSchema($config_name)) {
         return FALSE;
     }
     $definition = $typed_config->getDefinition($config_name);
     $data_definition = $typed_config->buildDataDefinition($definition, $config_data);
     $this->schema = $typed_config->create($data_definition, $config_data);
     $errors = array();
     foreach ($config_data as $key => $value) {
         $errors = array_merge($errors, $this->checkValue($key, $value));
     }
     if (empty($errors)) {
         return TRUE;
     }
     return $errors;
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:32,代码来源:SchemaCheckTrait.php

示例7: loadSchema

 /**
  * {@inheritdoc}
  */
 public function loadSchema()
 {
     $fields = $this->typedConfig->getDefinition('domain.record.*');
     return isset($fields['mapping']) ? $fields['mapping'] : array();
 }
开发者ID:dropdog,项目名称:play,代码行数:8,代码来源:DomainLoader.php

示例8: getDefinition

 /**
  * Provides definition of a configuration.
  *
  * @param string $plugin_id
  *   A string plugin ID.
  *
  * @return mixed|void
  */
 public function getDefinition($plugin_id, $exception_on_invalid = TRUE)
 {
     return $this->typedConfigManager->getDefinition($plugin_id, $exception_on_invalid);
 }
开发者ID:njcameron,项目名称:ncmd,代码行数:12,代码来源:ConfigInspectorManager.php


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