本文整理汇总了PHP中Drupal\Core\Config\StorageInterface::listAll方法的典型用法代码示例。如果您正苦于以下问题:PHP StorageInterface::listAll方法的具体用法?PHP StorageInterface::listAll怎么用?PHP StorageInterface::listAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Config\StorageInterface
的用法示例。
在下文中一共展示了StorageInterface::listAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getConfigNames
protected function getConfigNames($config_type)
{
$this->configStorage = $this->getDrupalService('config.storage');
// For a given entity type, load all entities.
if ($config_type && $config_type !== 'system.simple') {
$entity_storage = $this->entityManager->getStorage($config_type);
foreach ($entity_storage->loadMultiple() as $entity) {
$entity_id = $entity->id();
$label = $entity->label() ?: $entity_id;
$names[$entity_id] = $label;
}
} else {
// Gather the config entity prefixes.
$config_prefixes = array_map(function ($definition) {
return $definition->getConfigPrefix() . '.';
}, $this->definitions);
// Find all config, and then filter our anything matching a config prefix.
$names = $this->configStorage->listAll();
$names = array_combine($names, $names);
foreach ($names as $config_name) {
foreach ($config_prefixes as $config_prefix) {
if (strpos($config_name, $config_prefix) === 0) {
unset($names[$config_name]);
}
}
}
}
return $names;
}
示例2: getDefinitions
/**
* {@inheritdoc}
*/
public function getDefinitions()
{
$definitions = array();
foreach ($this->schemaStorage->readMultiple($this->schemaStorage->listAll()) as $schema) {
foreach ($schema as $type => $definition) {
$definitions[$type] = $definition;
}
}
return $definitions;
}
示例3: listConfigByType
/**
* {@inheritdoc}
*/
public function listConfigByType($config_type)
{
// For a given entity type, load all entities.
if ($config_type && $config_type !== FeaturesManagerInterface::SYSTEM_SIMPLE_CONFIG) {
$entity_storage = $this->entityManager->getStorage($config_type);
$names = [];
foreach ($entity_storage->loadMultiple() as $entity) {
$entity_id = $entity->id();
$label = $entity->label() ?: $entity_id;
$names[$entity_id] = $label;
}
} else {
$definitions = [];
foreach ($this->entityManager->getDefinitions() as $entity_type => $definition) {
if ($definition->isSubclassOf('Drupal\\Core\\Config\\Entity\\ConfigEntityInterface')) {
$definitions[$entity_type] = $definition;
}
}
// Gather the config entity prefixes.
$config_prefixes = array_map(function (EntityTypeInterface $definition) {
return $definition->getConfigPrefix() . '.';
}, $definitions);
// Find all config, and then filter our anything matching a config prefix.
$names = $this->configStorage->listAll();
$names = array_combine($names, $names);
foreach ($names as $item_name) {
foreach ($config_prefixes as $config_prefix) {
if (strpos($item_name, $config_prefix) === 0) {
unset($names[$item_name]);
}
}
}
}
return $names;
}
示例4: testInvalidStorage
/**
* Tests an invalid storage.
*/
public function testInvalidStorage()
{
$name = 'config_test.storage';
// Write something to the valid storage to prove that the storages do not
// pollute one another.
$data = array('foo' => 'bar');
$result = $this->storage->write($name, $data);
$this->assertIdentical($result, TRUE);
$raw_data = $this->read($name);
$this->assertIdentical($raw_data, $data);
// Reading from a non-existing storage bin returns FALSE.
$result = $this->invalidStorage->read($name);
$this->assertIdentical($result, FALSE);
// Deleting from a non-existing storage bin throws an exception.
try {
$this->invalidStorage->delete($name);
$this->fail('Exception not thrown upon deleting from a non-existing storage bin.');
} catch (\Exception $e) {
$class = get_class($e);
$this->pass($class . ' thrown upon deleting from a non-existing storage bin.');
}
// Listing on a non-existing storage bin returns an empty array.
$result = $this->invalidStorage->listAll();
$this->assertIdentical($result, array());
// Writing to a non-existing storage bin creates the bin.
$this->invalidStorage->write($name, array('foo' => 'bar'));
$result = $this->invalidStorage->read($name);
$this->assertIdentical($result, array('foo' => 'bar'));
}
示例5: findConfiguration
/**
* Handles switching the configuration type selector.
*/
protected function findConfiguration($config_type)
{
$names = array('' => $this->t('- Select -'));
// For a given entity type, load all entities.
if ($config_type && $config_type !== 'system.simple') {
$entity_storage = $this->entityManager->getStorage($config_type);
foreach ($entity_storage->loadMultiple() as $entity) {
$entity_id = $entity->id();
if ($label = $entity->label()) {
$names[$entity_id] = new TranslatableMarkup('@label (@id)', ['@label' => $label, '@id' => $entity_id]);
} else {
$names[$entity_id] = $entity_id;
}
}
} else {
// Gather the config entity prefixes.
$config_prefixes = array_map(function (EntityTypeInterface $definition) {
return $definition->getConfigPrefix() . '.';
}, $this->definitions);
// Find all config, and then filter our anything matching a config prefix.
$names = $this->configStorage->listAll();
$names = array_combine($names, $names);
foreach ($names as $config_name) {
foreach ($config_prefixes as $config_prefix) {
if (strpos($config_name, $config_prefix) === 0) {
unset($names[$config_name]);
}
}
}
}
return $names;
}
示例6: 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));
}
}
示例7: deleteAll
/**
* {@inheritdoc}
*/
public function deleteAll($prefix = '')
{
$list = $this->storage->listAll();
$result = TRUE;
foreach ($list as $name) {
$result = $this->delete($name) ? $result : FALSE;
}
return $result;
}
示例8: deleteAll
/**
* Implements Drupal\Core\Config\StorageInterface::deleteAll().
*/
public function deleteAll($prefix = '')
{
// If the cache was the first to be deleted, another process might start
// rebuilding the cache before the storage is renamed.
$names = $this->storage->listAll($prefix);
if ($this->storage->deleteAll($prefix)) {
$this->cache->deleteMultiple($this->getCacheKeys($names));
return TRUE;
}
return FALSE;
}
示例9: predefinedConfiguredLanguages
/**
* Compute the list of configuration names that match predefined languages.
*
* @return array
* The list of configuration names that match predefined languages.
*/
protected function predefinedConfiguredLanguages()
{
$names = $this->configStorage->listAll('language.entity.');
$predefined_languages = $this->languageManager->getStandardLanguageList();
foreach ($names as $id => $name) {
$langcode = str_replace('language.entity.', '', $name);
if (!isset($predefined_languages[$langcode])) {
unset($names[$id]);
}
}
return array_values($names);
}
示例10: getComponentNames
/**
* Gets configuration names associated with components.
*
* @param array $components
* (optional) Array of component lists indexed by type. If not present or it
* is an empty array, it will update all components.
*
* @return array
* Array of configuration object names.
*/
public function getComponentNames(array $components)
{
$components = array_filter($components);
if ($components) {
$names = array();
foreach ($components as $type => $list) {
// InstallStorage::getComponentNames returns a list of folders keyed by
// config name.
$names = array_merge($names, array_keys($this->installStorage->getComponentNames($type, $list)));
}
return $names;
} else {
return $this->installStorage->listAll();
}
}
示例11: getConfigDependencyManager
/**
* {@inheritdoc}
*/
public function getConfigDependencyManager()
{
$dependency_manager = new ConfigDependencyManager();
// This uses the configuration storage directly to avoid blowing the static
// caches in the configuration factory and the configuration entity system.
// Additionally this ensures that 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_filter($this->activeStorage->readMultiple($this->activeStorage->listAll()), function ($config) {
return isset($config['uuid']);
});
$dependency_manager->setData($data);
return $dependency_manager;
}
示例12: getDefinitions
/**
* {@inheritdoc}
*/
public function getDefinitions()
{
if (!isset($this->definitions)) {
if ($cache = $this->cache->get($this::CACHE_ID)) {
$this->definitions = $cache->data;
} else {
$this->definitions = array();
foreach ($this->schemaStorage->readMultiple($this->schemaStorage->listAll()) as $schema) {
foreach ($schema as $type => $definition) {
$this->definitions[$type] = $definition;
}
}
$this->cache->set($this::CACHE_ID, $this->definitions);
}
}
return $this->definitions;
}
示例13: listAll
/**
* {@inheritdoc}
*/
public function listAll($prefix = '')
{
$names = $this->storage->listAll($prefix);
$additional_names = [];
if ($prefix === '') {
$additional_names = array_keys($this->replacementData[$this->collection]);
} else {
foreach (array_keys($this->replacementData[$this->collection]) as $name) {
if (strpos($name, $prefix) === 0) {
$additional_names[] = $name;
}
}
}
if (!empty($additional_names)) {
$names = array_unique(array_merge($names, $additional_names));
}
return $names;
}
示例14: findMissingContentDependencies
/**
* {@inheritdoc}
*/
public function findMissingContentDependencies()
{
$content_dependencies = array();
$missing_dependencies = array();
foreach ($this->activeStorage->readMultiple($this->activeStorage->listAll()) as $config_data) {
if (isset($config_data['dependencies']['content'])) {
$content_dependencies = array_merge($content_dependencies, $config_data['dependencies']['content']);
}
}
foreach (array_unique($content_dependencies) as $content_dependency) {
// Format of the dependency is entity_type:bundle:uuid.
list($entity_type, $bundle, $uuid) = explode(':', $content_dependency, 3);
if (!$this->entityManager->loadEntityByUuid($entity_type, $uuid)) {
$missing_dependencies[$uuid] = array('entity_type' => $entity_type, 'bundle' => $bundle, 'uuid' => $uuid);
}
}
return $missing_dependencies;
}
示例15: getFeaturesConfigDependencyManager
/**
* Creates a high performant version of the ConfigDependencyManager.
*
* @return \Drupal\features\FeaturesConfigDependencyManager
* A high performant version of the ConfigDependencyManager.
*
* @see \Drupal\Core\Config\Entity\ConfigDependencyManager
*/
protected function getFeaturesConfigDependencyManager()
{
$dependency_manager = new FeaturesConfigDependencyManager();
// 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 (Drupal\Core\Config\ImmutableConfig $config) {
$data = $config->get();
if (isset($data['uuid'])) {
return $data;
}
return FALSE;
}, $this->configFactory->loadMultiple($this->configStorage->listAll()));
$dependency_manager->setData(array_filter($data));
return $dependency_manager;
}