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


PHP ConfigFactoryInterface::loadMultiple方法代码示例

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


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

示例1: getAllDefinedLanguages

 /**
  * {@inheritdoc}
  */
 public function getAllDefinedLanguages()
 {
     // Get list of all configured languages.
     $languages = [];
     // See Drupal\language\ConfigurableLanguageManager::getLanguages() for details
     $predefined = LanguageManager::getStandardLanguageList();
     foreach ($predefined as $key => $value) {
         $languages[$key] = new TranslatableMarkup($value[0]);
     }
     $config_ids = $this->configFactory->listAll('language.entity.');
     foreach ($this->configFactory->loadMultiple($config_ids) as $config) {
         $data = $config->get();
         $languages[$data['id']] = new TranslatableMarkup($data['label']);
     }
     asort($languages);
     return $languages;
 }
开发者ID:globalbility,项目名称:flags,代码行数:20,代码来源:FullLanguageManager.php

示例2: doLoadMultiple

 /**
  * {@inheritdoc}
  */
 protected function doLoadMultiple(array $ids = NULL)
 {
     $prefix = $this->getPrefix();
     // Get the names of the configuration entities we are going to load.
     if ($ids === NULL) {
         $names = $this->configFactory->listAll($prefix);
     } else {
         $names = array();
         foreach ($ids as $id) {
             // Add the prefix to the ID to serve as the configuration object name.
             $names[] = $prefix . $id;
         }
     }
     // Load all of the configuration entities.
     /** @var \Drupal\Core\Config\Config[] $configs */
     $configs = [];
     $records = [];
     foreach ($this->configFactory->loadMultiple($names) as $config) {
         $id = $config->get($this->idKey);
         $records[$id] = $this->overrideFree ? $config->getOriginal(NULL, FALSE) : $config->get();
         $configs[$id] = $config;
     }
     $entities = $this->mapFromStorageRecords($records, $configs);
     // Config entities wrap config objects, and therefore they need to inherit
     // the cacheability metadata of config objects (to ensure e.g. additional
     // cacheability metadata added by config overrides is not lost).
     foreach ($entities as $id => $entity) {
         // But rather than simply inheriting all cacheability metadata of config
         // objects, we need to make sure the self-referring cache tag that is
         // present on Config objects is not added to the Config entity. It must be
         // removed for 3 reasons:
         // 1. When renaming/duplicating a Config entity, the cache tag of the
         //    original config object would remain present, which would be wrong.
         // 2. Some Config entities choose to not use the cache tag that the under-
         //    lying Config object provides by default (For performance and
         //    cacheability reasons it may not make sense to have a unique cache
         //    tag for every Config entity. The DateFormat Config entity specifies
         //    the 'rendered' cache tag for example, because A) date formats are
         //    changed extremely rarely, so invalidating all render cache items is
         //    fine, B) it means fewer cache tags per page.).
         // 3. Fewer cache tags is better for performance.
         $self_referring_cache_tag = ['config:' . $configs[$id]->getName()];
         $config_cacheability = CacheableMetadata::createFromObject($configs[$id]);
         $config_cacheability->setCacheTags(array_diff($config_cacheability->getCacheTags(), $self_referring_cache_tag));
         $entity->addCacheableDependency($config_cacheability);
     }
     return $entities;
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:51,代码来源:ConfigEntityStorage.php

示例3: getConfigDependencyManager

 /**
  * {@inheritdoc}
  */
 public function getConfigDependencyManager()
 {
     $dependency_manager = new ConfigDependencyManager();
     // Read all configuration using the factory. This ensures that multiple
     // deletes during the same request benefit from the static cache. Using the
     // factory also ensures configuration entity dependency discovery has no
     // dependencies on the config entity classes. Assume data with UUID is a
     // config entity. Only configuration entities can be depended on so we can
     // ignore everything else.
     $data = array_map(function ($config) {
         $data = $config->get();
         if (isset($data['uuid'])) {
             return $data;
         }
         return FALSE;
     }, $this->configFactory->loadMultiple($this->activeStorage->listAll()));
     $dependency_manager->setData(array_filter($data));
     return $dependency_manager;
 }
开发者ID:frankcr,项目名称:sftw8,代码行数:22,代码来源:ConfigManager.php

示例4: doLoadMultiple

 /**
  * {@inheritdoc}
  */
 protected function doLoadMultiple(array $ids = NULL)
 {
     $prefix = $this->getPrefix();
     // Get the names of the configuration entities we are going to load.
     if ($ids === NULL) {
         $names = $this->configFactory->listAll($prefix);
     } else {
         $names = array();
         foreach ($ids as $id) {
             // Add the prefix to the ID to serve as the configuration object name.
             $names[] = $prefix . $id;
         }
     }
     // Load all of the configuration entities.
     $records = array();
     foreach ($this->configFactory->loadMultiple($names) as $config) {
         $records[$config->get($this->idKey)] = $this->overrideFree ? $config->getOriginal(NULL, FALSE) : $config->get();
     }
     return $this->mapFromStorageRecords($records);
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:23,代码来源:ConfigEntityStorage.php

示例5: loadRecords

 /**
  * Loads the config records to examine for the query.
  *
  * @return array
  *   Config records keyed by entity IDs.
  */
 protected function loadRecords()
 {
     $prefix = $this->entityType->getConfigPrefix() . '.';
     $prefix_length = strlen($prefix);
     // Search the conditions for restrictions on entity IDs.
     $ids = array();
     if ($this->condition->getConjunction() == 'AND') {
         foreach ($this->condition->conditions() as $condition) {
             if (is_string($condition['field']) && $condition['field'] == $this->entityType->getKey('id')) {
                 $operator = $condition['operator'] ?: (is_array($condition['value']) ? 'IN' : '=');
                 if ($operator == '=') {
                     $ids = array($condition['value']);
                 } elseif ($operator == 'IN') {
                     $ids = $condition['value'];
                 }
                 // We stop at the first restricting condition on ID. In the (weird)
                 // case where there are additional restricting conditions, results
                 // will be eliminated when the conditions are checked on the loaded
                 // records.
                 if ($ids) {
                     break;
                 }
             }
         }
     }
     // If there are conditions restricting config ID, we can narrow the list of
     // records to load and parse.
     if ($ids) {
         $names = array_map(function ($id) use($prefix) {
             return $prefix . $id;
         }, $ids);
     } else {
         $names = $this->configStorage->listAll($prefix);
     }
     // Load the corresponding records.
     $records = array();
     foreach ($this->configFactory->loadMultiple($names) as $config) {
         $records[substr($config->getName(), $prefix_length)] = $config->get();
     }
     return $records;
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:47,代码来源:Query.php

示例6: updateLockedLanguageWeights

 /**
  * {@inheritdoc}
  */
 public function updateLockedLanguageWeights()
 {
     $max_weight = 0;
     // Get maximum weight to update the system languages to keep them on bottom.
     foreach ($this->getLanguages(LanguageInterface::STATE_CONFIGURABLE) as $language) {
         if (!$language->isLocked()) {
             $max_weight = max($max_weight, $language->getWeight());
         }
     }
     // Loop locked languages to maintain the existing order.
     $locked_languages = $this->getLanguages(LanguageInterface::STATE_LOCKED);
     $config_ids = array_map(function ($language) {
         return 'language.entity.' . $language->getId();
     }, $locked_languages);
     foreach ($this->configFactory->loadMultiple($config_ids) as $config) {
         // Update system languages weight.
         $max_weight++;
         $config->set('weight', $max_weight);
         $config->save();
     }
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:24,代码来源:ConfigurableLanguageManager.php

示例7: getLanguages

 /**
  * {@inheritdoc}
  */
 public function getLanguages($flags = LanguageInterface::STATE_CONFIGURABLE)
 {
     // If a config override is set, cache using that language's ID.
     if ($override_language = $this->getConfigOverrideLanguage()) {
         $static_cache_id = $override_language->getId();
     } else {
         $static_cache_id = $this->getCurrentLanguage()->getId();
     }
     if (!isset($this->languages[$static_cache_id][$flags])) {
         // Initialize the language list with the default language and default
         // locked languages. These cannot be removed. This serves as a fallback
         // list if this method is invoked while the language module is installed
         // and the configuration entities for languages are not yet fully
         // imported.
         $default = $this->getDefaultLanguage();
         $languages = array($default->getId() => $default);
         $languages += $this->getDefaultLockedLanguages($default->getWeight());
         // Load configurable languages on top of the defaults. Ideally this could
         // use the entity API to load and instantiate ConfigurableLanguage
         // objects. However the entity API depends on the language system, so that
         // would result in infinite loops. We use the configuration system
         // directly and instantiate runtime Language objects. When language
         // entities are imported those cover the default and locked languages, so
         // site-specific configuration will prevail over the fallback values.
         // Having them in the array already ensures if this is invoked in the
         // middle of importing language configuration entities, the defaults are
         // always present.
         $config_ids = $this->configFactory->listAll('language.entity.');
         foreach ($this->configFactory->loadMultiple($config_ids) as $config) {
             $data = $config->get();
             $data['name'] = $data['label'];
             $languages[$data['id']] = new Language($data);
         }
         Language::sort($languages);
         // Filter the full list of languages based on the value of $flags.
         $this->languages[$static_cache_id][$flags] = $this->filterLanguages($languages, $flags);
     }
     return $this->languages[$static_cache_id][$flags];
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:42,代码来源:ConfigurableLanguageManager.php

示例8: __construct

 /**
  * Creates new instance of BaseMapping class.
  *
  * @param ConfigFactoryInterface $config
  */
 public function __construct(ConfigFactoryInterface $config)
 {
     $ids = $config->listAll($this->getConfigKey());
     $this->config = $config->loadMultiple($ids);
 }
开发者ID:globalbility,项目名称:flags,代码行数:10,代码来源:BaseMapping.php

示例9: loadRecords

 /**
  * Loads the config records to examine for the query.
  *
  * @return array
  *   Config records keyed by entity IDs.
  */
 protected function loadRecords()
 {
     $prefix = $this->entityType->getConfigPrefix() . '.';
     $prefix_length = strlen($prefix);
     // Search the conditions for restrictions on configuration object names.
     $names = FALSE;
     $id_condition = NULL;
     $id_key = $this->entityType->getKey('id');
     if ($this->condition->getConjunction() == 'AND') {
         $lookup_keys = $this->entityType->getLookupKeys();
         $conditions = $this->condition->conditions();
         foreach ($conditions as $condition_key => $condition) {
             $operator = $condition['operator'] ?: (is_array($condition['value']) ? 'IN' : '=');
             if (is_string($condition['field']) && ($operator == 'IN' || $operator == '=')) {
                 // Special case ID lookups.
                 if ($condition['field'] == $id_key) {
                     $ids = (array) $condition['value'];
                     $names = array_map(function ($id) use($prefix) {
                         return $prefix . $id;
                     }, $ids);
                 } elseif (in_array($condition['field'], $lookup_keys)) {
                     // If we don't find anything then there are no matches. No point in
                     // listing anything.
                     $names = array();
                     $keys = (array) $condition['value'];
                     $keys = array_map(function ($value) use($condition) {
                         return $condition['field'] . ':' . $value;
                     }, $keys);
                     foreach ($this->getConfigKeyStore()->getMultiple($keys) as $list) {
                         $names = array_merge($names, $list);
                     }
                 }
             } elseif (!$id_condition && $condition['field'] == $id_key) {
                 $id_condition = $condition;
             }
             // We stop at the first restricting condition on name. In the case where
             // there are additional restricting conditions, results will be
             // eliminated when the conditions are checked on the loaded records.
             if ($names !== FALSE) {
                 // If the condition has been responsible for narrowing the list of
                 // configuration to check there is no point in checking it further.
                 unset($conditions[$condition_key]);
                 break;
             }
         }
     }
     // If no restrictions on IDs were found, we need to parse all records.
     if ($names === FALSE) {
         $names = $this->configFactory->listAll($prefix);
     }
     // In case we have an ID condition, try to narrow down the list of config
     // objects to load.
     if ($id_condition && !empty($names)) {
         $value = $id_condition['value'];
         $filter = NULL;
         switch ($id_condition['operator']) {
             case '<>':
                 $filter = function ($name) use($value, $prefix_length) {
                     $id = substr($name, $prefix_length);
                     return $id !== $value;
                 };
                 break;
             case 'STARTS_WITH':
                 $filter = function ($name) use($value, $prefix_length) {
                     $id = substr($name, $prefix_length);
                     return strpos($id, $value) === 0;
                 };
                 break;
             case 'CONTAINS':
                 $filter = function ($name) use($value, $prefix_length) {
                     $id = substr($name, $prefix_length);
                     return strpos($id, $value) !== FALSE;
                 };
                 break;
             case 'ENDS_WITH':
                 $filter = function ($name) use($value, $prefix_length) {
                     $id = substr($name, $prefix_length);
                     return strrpos($id, $value) === strlen($id) - strlen($value);
                 };
                 break;
         }
         if ($filter) {
             $names = array_filter($names, $filter);
         }
     }
     // Load the corresponding records.
     $records = array();
     foreach ($this->configFactory->loadMultiple($names) as $config) {
         $records[substr($config->getName(), $prefix_length)] = $config->get();
     }
     return $records;
 }
开发者ID:318io,项目名称:318-io,代码行数:98,代码来源:Query.php


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