本文整理汇总了PHP中Drupal\Core\Config\StorageInterface::read方法的典型用法代码示例。如果您正苦于以下问题:PHP StorageInterface::read方法的具体用法?PHP StorageInterface::read怎么用?PHP StorageInterface::read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Config\StorageInterface
的用法示例。
在下文中一共展示了StorageInterface::read方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAllFolders
/**
* Returns a map of all config object names and their folders.
*
* The list is based on enabled modules and themes. The active configuration
* storage is used rather than \Drupal\Core\Extension\ModuleHandler and
* \Drupal\Core\Extension\ThemeHandler in order to resolve circular
* dependencies between these services and \Drupal\Core\Config\ConfigInstaller
* and \Drupal\Core\Config\TypedConfigManager.
*
* @return array
* An array mapping config object names with directories.
*/
protected function getAllFolders()
{
if (!isset($this->folders)) {
$this->folders = array();
$this->folders += $this->getComponentNames('core', array('core'));
$extensions = $this->configStorage->read('core.extension');
if (!empty($extensions['module'])) {
$modules = $extensions['module'];
if (!$this->includeProfile) {
if ($install_profile = Settings::get('install_profile')) {
unset($modules[$install_profile]);
}
}
$this->folders += $this->getComponentNames('module', array_keys($modules));
}
if (!empty($extensions['theme'])) {
$this->folders += $this->getComponentNames('theme', array_keys($extensions['theme']));
}
// The install profile can override module default configuration. We do
// this by replacing the config file path from the module/theme with the
// install profile version if there are any duplicates.
$profile_folders = $this->getComponentNames('profile', array(drupal_get_profile()));
$folders_to_replace = array_intersect_key($profile_folders, $this->folders);
if (!empty($folders_to_replace)) {
$this->folders = array_merge($this->folders, $folders_to_replace);
}
}
return $this->folders;
}
示例2: get
/**
* {@inheritdoc}
*/
public function get($name)
{
$data = $this->configStorage->read($name);
$type_definition = $this->getDefinition($name);
$data_definition = $this->buildDataDefinition($type_definition, $data);
return $this->create($data_definition, $data);
}
示例3: read
/**
* {@inheritdoc}
*/
public function read($name)
{
if (isset($this->replacementData[$this->collection][$name])) {
return $this->replacementData[$this->collection][$name];
}
return $this->storage->read($name);
}
示例4: loadOverrides
/**
* {@inheritdoc}
*/
public function loadOverrides($names)
{
$overrides = array();
// loadOverrides() runs on config entities, which means that if we try
// to run this routine on our own data, then we end up in an infinite loop.
// So ensure that we are _not_ looking up a domain.record.*.
$check = current($names);
$list = explode('.', $check);
if (isset($list[0]) && isset($list[1]) && $list[0] == 'domain' && $list[1] == 'record') {
return $overrides;
}
$this->initiateContext();
if (!empty($this->domain)) {
foreach ($names as $name) {
$config_name = $this->getDomainConfigName($name, $this->domain);
// Check to see if the config storage has an appropriately named file
// containing override data.
if ($override = $this->storage->read($config_name['langcode'])) {
$overrides[$name] = $override;
} elseif ($override = $this->storage->read($config_name['domain'])) {
$overrides[$name] = $override;
}
}
}
return $overrides;
}
示例5: read
/**
* {@inheritdoc}
*/
public function read($name)
{
$data = $this->storage->read($name);
foreach ($this->filters as $filter) {
$data = $filter->filterRead($name, $data);
}
return $data;
}
示例6: filterWrite
public function filterWrite($name, array $data, StorageInterface $storage)
{
if ($name != 'core.extension') {
return $data;
}
$originalData = $storage->read($name);
return $this->filterOutIgnored($data, $storage->read($name));
}
示例7: getAllFolders
/**
* Returns a map of all config object names and their folders.
*
* The list is based on enabled modules and themes. The active configuration
* storage is used rather than \Drupal\Core\Extension\ModuleHandler and
* \Drupal\Core\Extension\ThemeHandler in order to resolve circular
* dependencies between these services and \Drupal\Core\Config\ConfigInstaller
* and \Drupal\Core\Config\TypedConfigManager.
*
* @return array
* An array mapping config object names with directories.
*/
protected function getAllFolders()
{
if (!isset($this->folders)) {
$this->folders = array();
$this->folders += $this->getCoreNames();
$install_profile = Settings::get('install_profile');
$profile = drupal_get_profile();
$extensions = $this->configStorage->read('core.extension');
// @todo Remove this scan as part of https://www.drupal.org/node/2186491
$listing = new ExtensionDiscovery(\Drupal::root());
if (!empty($extensions['module'])) {
$modules = $extensions['module'];
// Remove the install profile as this is handled later.
unset($modules[$install_profile]);
$profile_list = $listing->scan('profile');
if ($profile && isset($profile_list[$profile])) {
// Prime the drupal_get_filename() static cache with the profile info
// file location so we can use drupal_get_path() on the active profile
// during the module scan.
// @todo Remove as part of https://www.drupal.org/node/2186491
drupal_get_filename('profile', $profile, $profile_list[$profile]->getPathname());
}
$module_list_scan = $listing->scan('module');
$module_list = array();
foreach (array_keys($modules) as $module) {
if (isset($module_list_scan[$module])) {
$module_list[$module] = $module_list_scan[$module];
}
}
$this->folders += $this->getComponentNames($module_list);
}
if (!empty($extensions['theme'])) {
$theme_list_scan = $listing->scan('theme');
foreach (array_keys($extensions['theme']) as $theme) {
if (isset($theme_list_scan[$theme])) {
$theme_list[$theme] = $theme_list_scan[$theme];
}
}
$this->folders += $this->getComponentNames($theme_list);
}
if ($this->includeProfile) {
// The install profile can override module default configuration. We do
// this by replacing the config file path from the module/theme with the
// install profile version if there are any duplicates.
if (isset($profile)) {
if (!isset($profile_list)) {
$profile_list = $listing->scan('profile');
}
if (isset($profile_list[$profile])) {
$profile_folders = $this->getComponentNames(array($profile_list[$profile]));
$this->folders = $profile_folders + $this->folders;
}
}
}
}
return $this->folders;
}
示例8: read
/**
* {@inheritdoc}
*/
public function read($name)
{
$data = $this->baseStorage->read($name);
if ($name == 'core.extension' && isset($data['module'])) {
// Remove any profiles from the list. These will be installed later.
// @see config_installer_config_import_profile()
$data['module'] = array_diff_key($data['module'], $this->profiles);
}
return $data;
}
示例9: read
/**
* Implements Drupal\Core\Config\StorageInterface::read().
*/
public function read($name)
{
if ($cache = $this->cache->get($name)) {
// The cache contains either the cached configuration data or FALSE
// if the configuration file does not exist.
return $cache->data;
}
// Read from the storage on a cache miss and cache the data. Also cache
// information about missing configuration objects.
$data = $this->storage->read($name);
$this->cache->set($name, $data);
return $data;
}
示例10: copyConfig
/**
* Copies configuration objects from source storage to target storage.
*
* @param \Drupal\Core\Config\StorageInterface $source_storage
* The source config storage service.
* @param \Drupal\Core\Config\StorageInterface $target_storage
* The target config storage service.
*/
protected function copyConfig(StorageInterface $source_storage, StorageInterface $target_storage)
{
$target_storage->deleteAll();
foreach ($source_storage->listAll() as $name) {
$target_storage->write($name, $source_storage->read($name));
}
}
示例11: createItemSnapshot
/**
* Creates a snapshot of a given configuration item as provided by an
* extension.
*
* @param FileStorage $extension_storage
* An extension's configuration file storage.
* @param string $item_name
* The name of the configuration item.
*/
function createItemSnapshot(FileStorage $extension_storage, $item_name)
{
// Snapshot the configuration item as provided by the extension.
$extension_value = $extension_storage->read($item_name);
$this->snapshotExtensionStorage->write($item_name, $extension_value);
// Snapshot the configuration item as installed in the active storage.
$active_value = $this->activeStorage->read($item_name);
$this->snapshotActiveStorage->write($item_name, $active_value);
}
示例12: getFromExtension
/**
* {@inheritdoc}
*/
public function getFromExtension($type, $name)
{
$full_name = $this->getFullName($type, $name);
$value = $this->extensionConfigStorage->read($full_name);
if (!$value) {
$value = $this->extensionOptionalConfigStorage->read($full_name);
}
return $value;
}
示例13: read
/**
* Read a configuration from install storage or default languages.
*
* @param string $name
* Configuration object name.
*
* @return array
* Configuration data from install storage or default language.
*/
public function read($name)
{
if ($this->requiredInstallStorage->exists($name)) {
return $this->requiredInstallStorage->read($name);
} elseif ($this->optionalInstallStorage->exists($name)) {
return $this->optionalInstallStorage->read($name);
} elseif (strpos($name, 'language.entity.') === 0) {
// Simulate default languages as if they were shipped as default
// configuration.
$langcode = str_replace('language.entity.', '', $name);
$predefined_languages = $this->languageManager->getStandardLanguageList();
if (isset($predefined_languages[$langcode])) {
$data = $this->configStorage->read($name);
$data['label'] = $predefined_languages[$langcode][0];
return $data;
}
}
}
示例14: addConfigList
protected function addConfigList($full_name, &$list) {
if (!in_array($full_name, $list)) {
array_unshift($list, $full_name);
$value = $this->extensionStorage->read($full_name);
if (isset($value['dependencies']['config'])) {
foreach ($value['dependencies']['config'] as $config_name) {
$this->addConfigList($config_name, $list);
}
}
}
}
示例15: filterWrite
public function filterWrite($name, array $data, StorageInterface $storage)
{
if ($name == 'core.extension') {
return $this->filterOutIgnored($data, $storage->read($name));
}
$dependent_configs = $this->getAllDependentConfigs($storage);
if (in_array($name, $dependent_configs)) {
$data = ($existing = $storage->read($name)) ? $existing : NULL;
}
return $data;
}