當前位置: 首頁>>代碼示例>>PHP>>正文


PHP TypedConfigManagerInterface::create方法代碼示例

本文整理匯總了PHP中Drupal\Core\Config\TypedConfigManagerInterface::create方法的典型用法代碼示例。如果您正苦於以下問題:PHP TypedConfigManagerInterface::create方法的具體用法?PHP TypedConfigManagerInterface::create怎麽用?PHP TypedConfigManagerInterface::create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Drupal\Core\Config\TypedConfigManagerInterface的用法示例。


在下文中一共展示了TypedConfigManagerInterface::create方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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

示例6: getTranslation

 /**
  * {@inheritdoc}
  */
 public function getTranslation($langcode)
 {
     $options = array('source' => $this->langcode, 'target' => $langcode);
     $data = $this->getElementTranslation($this->getTypedConfig(), $options);
     return $this->typedConfigManager->create($this->definition, $data);
 }
開發者ID:Nikola-xiii,項目名稱:d8intranet,代碼行數:9,代碼來源:LocaleTypedConfig.php

示例7: createElement

 /**
  * Creates a contained typed configuration object.
  *
  * @param \Drupal\Core\TypedData\DataDefinitionInterface $definition
  *   The data definition object.
  * @param mixed $value
  *   (optional) The data value. If set, it has to match one of the supported
  *   data type format as documented for the data type classes.
  * @param string $key
  *   The key of the contained element.
  *
  * @return \Drupal\Core\TypedData\TypedDataInterface
  */
 protected function createElement($definition, $value, $key)
 {
     return $this->typedConfig->create($definition, $value, $key, $this);
 }
開發者ID:Nikola-xiii,項目名稱:d8intranet,代碼行數:17,代碼來源:ArrayElement.php


注:本文中的Drupal\Core\Config\TypedConfigManagerInterface::create方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。