listAll example


  public function invalidateMultiple(array $cids) {
    foreach ($cids as $cid) {
      $this->invalidate($cid);
    }
  }

  /** * {@inheritdoc} */
  public function invalidateAll() {
    foreach ($this->storage()->listAll() as $cidhash) {
      $this->invalidateByHash($cidhash);
    }
  }

  /** * {@inheritdoc} */
  public function garbageCollection() {
  }

  /** * {@inheritdoc} */
/** * Checks that the configuration synchronization is valid. * * This event listener prevents deleting all configuration. If there is * nothing to import then event propagation is stopped because there is no * config import to validate. * * @param \Drupal\Core\Config\ConfigImporterEvent $event * The config import event. */
  public function onConfigImporterValidateNotEmpty(ConfigImporterEvent $event) {
    $importList = $event->getConfigImporter()->getStorageComparer()->getSourceStorage()->listAll();
    if (empty($importList)) {
      $event->getConfigImporter()->logError($this->t('This import is empty and if applied would delete all of your configuration, so has been rejected.'));
      $event->stopPropagation();
    }
  }

  /** * Checks that the configuration synchronization is valid. * * This event listener checks that the system.site:uuid's in the source and * target match. * * @param \Drupal\Core\Config\ConfigImporterEvent $event * The config import event. */
/** * {@inheritdoc} */
  public function decode($raw) {
    return $this->storage->decode($raw);
  }

  /** * {@inheritdoc} */
  public function listAll($prefix = '') {
    return $this->storage->listAll($prefix);
  }

  /** * {@inheritdoc} */
  public function deleteAll($prefix = '') {
    throw new \BadMethodCallException(__METHOD__ . ' is not allowed on a ReadOnlyStorage');
  }

  /** * {@inheritdoc} */
$field = FieldConfig::load($field_id);
    $this->assertNull($field, 'The field was deleted.');
    \Drupal::entityTypeManager()->getStorage('field_config')->resetCache([$field_id_2a]);
    $field_2a = FieldConfig::load($field_id_2a);
    $this->assertNull($field_2a, 'The second field on test bundle was deleted.');
    \Drupal::entityTypeManager()->getStorage('field_config')->resetCache([$field_id_2b]);
    $field_2b = FieldConfig::load($field_id_2b);
    $this->assertNull($field_2b, 'The second field on test bundle 2 was deleted.');

    // Check that all config files are gone.     $active = $this->container->get('config.storage');
    $this->assertSame([]$active->listAll($field_storage_config_name));
    $this->assertSame([]$active->listAll($field_storage_config_name_2));
    $this->assertSame([]$active->listAll($field_config_name));
    $this->assertSame([]$active->listAll($field_config_name_2a));
    $this->assertSame([]$active->listAll($field_config_name_2b));

    // Check that only the first storage definition is preserved in state.     $deleted_storages = \Drupal::state()->get('field.storage.deleted', []);
    $this->assertTrue(isset($deleted_storages[$field_storage_uuid]));
    $this->assertFalse(isset($deleted_storages[$field_storage_uuid_2]));

    // Purge field data, and check that the storage definition has been
private function getDependentConfigNames() {
    $modules = $this->getExcludedModules();

    $dependencyManager = $this->manager->getConfigDependencyManager();
    $config = [];

    // Find all the configuration depending on the excluded modules.     foreach ($modules as $module) {
      foreach ($dependencyManager->getDependentEntities('module', $module) as $dependent) {
        $config[] = $dependent->getConfigDependencyName();
      }
      $config = array_merge($config$this->activeStorage->listAll($module . '.'));
    }

    // Find all configuration that depends on the configuration found above.     foreach ($this->manager->findConfigEntityDependencies('config', array_unique($config)) as $dependent) {
      $config[] = $dependent->getConfigDependencyName();
    }

    return array_unique($config);
  }

}
// Test chained set()->save().     $chained_name = 'biff.bang';
    $config = $this->config($chained_name);
    $config->set($key$value)->save();

    // Verify the database entry exists from a chained save.     $data = $storage->read($chained_name);
    $this->assertEquals($config->get()$data);

    // Get file listing for all files starting with 'foo'. Should return     // two elements.     $files = $storage->listAll('foo');
    $this->assertCount(2, $files, 'Two files listed with the prefix \'foo\'.');

    // Get file listing for all files starting with 'biff'. Should return     // one element.     $files = $storage->listAll('biff');
    $this->assertCount(1, $files, 'One file listed with the prefix \'biff\'.');

    // Get file listing for all files starting with 'foo.bar'. Should return     // one element.     $files = $storage->listAll('foo.bar');
    $this->assertCount(1, $files, 'One file listed with the prefix \'foo.bar\'.');

    
$this->assertSame($data$raw_data);

    // Checking whether an existing name exists returns TRUE.     $this->assertTrue($this->storage->exists($name));

    // Writing the identical data again still returns TRUE.     $result = $this->storage->write($name$data);
    $this->assertTrue($result);

    // Listing all names returns all.     $this->storage->write('system.performance', []);
    $names = $this->storage->listAll();
    $this->assertContains('system.performance', $names);
    $this->assertContains($name$names);

    // Listing all names with prefix returns names with that prefix only.     $names = $this->storage->listAll('config_test.');
    $this->assertNotContains('system.performance', $names);
    $this->assertContains($name$names);

    // Rename the configuration storage object.     $new_name = 'config_test.storage_rename';
    $this->storage->rename($name$new_name);
    
        if ($has_added_restrictions !== 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 ($has_added_restrictions === FALSE) {
      $filter_by_names = $this->configFactory->listAll($prefix);
    }
    else {
      $filter_by_names = array_merge(...$filter_by_names);
    }
    // In case we have an ID condition, try to narrow down the list of config     // objects to load.     if ($id_condition && !empty($filter_by_names)) {
      $value = $id_condition['value'];
      $filter = NULL;
      switch ($id_condition['operator']) {
        case '<>':
          


  /** * Validates configuration being imported does not have unmet dependencies. * * @param \Drupal\Core\Config\ConfigImporter $config_importer * The configuration importer. */
  protected function validateDependencies(ConfigImporter $config_importer) {
    $core_extension = $config_importer->getStorageComparer()->getSourceStorage()->read('core.extension');
    $existing_dependencies = [
      'config' => $config_importer->getStorageComparer()->getSourceStorage()->listAll(),
      'module' => array_keys($core_extension['module']),
      'theme' => array_keys($core_extension['theme']),
    ];

    $theme_data = $this->getThemeData();
    $module_data = $this->moduleExtensionList->getList();

    // Validate the dependencies of all the configuration. We have to validate     // the entire tree because existing configuration might depend on     // configuration that is being deleted.     foreach ($config_importer->getStorageComparer()->getSourceStorage()->listAll() as $name) {
      
/** * Returns entity (form) displays for the current entity display type. * * @return \Drupal\Core\Entity\Display\EntityDisplayInterface[] * An array holding entity displays or entity form displays. */
  protected function getDisplays() {
    $load_ids = [];
    $display_entity_type = $this->entity->getEntityTypeId();
    $entity_type = $this->entityTypeManager->getDefinition($display_entity_type);
    $config_prefix = $entity_type->getConfigPrefix();
    $ids = $this->configFactory()->listAll($config_prefix . '.' . $this->entity->getTargetEntityTypeId() . '.' . $this->entity->getTargetBundle() . '.');
    foreach ($ids as $id) {
      $config_id = str_replace($config_prefix . '.', '', $id);
      [,, $display_mode] = explode('.', $config_id);
      if ($display_mode != 'default') {
        $load_ids[] = $config_id;
      }
    }
    return $this->entityTypeManager->getStorage($display_entity_type)->loadMultiple($load_ids);
  }

  /** * Returns form or view modes statuses for the bundle used by this form. * * @return array * An array of form or view mode statuses. */

  public function __construct(StorageInterface $schema_storage) {
    $this->schemaStorage = $schema_storage;
  }

  /** * {@inheritdoc} */
  public function getDefinitions() {
    $definitions = [];
    foreach ($this->schemaStorage->readMultiple($this->schemaStorage->listAll()) as $schema) {
      foreach ($schema as $type => $definition) {
        $definitions[$type] = $definition;
      }
    }
    return $definitions;
  }

}
$storage = $this->createMock('Drupal\Core\Config\StorageInterface');

    $response = ["$prefix." . $this->randomMachineName(), "$prefix." . $this->randomMachineName()];
    $storage->expects($this->once())
      ->method('listAll')
      ->with($prefix)
      ->willReturn($response);

    $cache = new NullBackend(__FUNCTION__);

    $cachedStorage = new CachedStorage($storage$cache);
    $this->assertEquals($response$cachedStorage->listAll($prefix));
    $this->assertEquals($response$cachedStorage->listAll($prefix));
  }

}
$components = array_filter($components);
    if ($components) {
      $names = [];
      foreach ($components as $type => $list) {
        // InstallStorage::getComponentNames returns a list of folders keyed by         // config name.         $names = array_merge($names$this->defaultConfigStorage->getComponentNames($type$list));
      }
      return $names;
    }
    else {
      return $this->defaultConfigStorage->listAll();
    }
  }

  /** * Gets configuration names associated with strings. * * @param array $lids * Array with string identifiers. * * @return array * Array of configuration object names. */
// Ensure that we have no configuration changes to import.     $storage_comparer = new StorageComparer(
      $this->container->get('config.storage.sync'),
      $this->container->get('config.storage')
    );
    $this->assertSame($storage_comparer->getEmptyChangelist()$storage_comparer->createChangelist()->getChangelist());

    // Now we have all configuration imported, test all of them for schema     // conformance. Ensures all imported default configuration is valid when     // all modules are enabled.     $names = $this->container->get('config.storage')->listAll();
    /** @var \Drupal\Core\Config\TypedConfigManagerInterface $typed_config */
    $typed_config = $this->container->get('config.typed');
    foreach ($names as $name) {
      $config = $this->config($name);
      $this->assertConfigSchema($typed_config$name$config->get());
    }
  }

}
/** * Return the list of configuration in install storage and current languages. * * @return array * List of configuration in install storage and current languages. */
  public function listAll() {
    $languages = $this->predefinedConfiguredLanguages();
    return array_unique(
      array_merge(
        $this->requiredInstallStorage->listAll(),
        $this->optionalInstallStorage->listAll(),
        $languages
      )
    );
  }

  /** * Get all configuration names and folders for a list of modules or themes. * * @param string $type * Type of components: 'module' | 'theme' | 'profile' * @param array $list * Array of theme or module names. * * @return array * Configuration names provided by that component. In case of language * module this list is extended with configured languages that have * predefined names as well. */
Home | Imprint | This part of the site doesn't use cookies.