protected function ConfigStorageController::buildQuery

Builds the query to load the entity.

This has full revision support. For entities requiring special queries, the class can be extended, and the default query can be constructed by calling parent::buildQuery(). This is usually necessary when the object being loaded needs to be augmented with additional data from another table, such as loading node type into comments or vocabulary machine name into terms, however it can also support $conditions on different tables. See Drupal\comment\CommentStorageController::buildQuery() or Drupal\taxonomy\TermStorageController::buildQuery() for examples.

Parameters

$ids: An array of entity IDs, or NULL to load all entities.

$revision_id: The ID of the revision to load, or FALSE if this query is asking for the most current revision(s).

Return value

SelectQuery A SelectQuery object for loading the entity.

1 call to ConfigStorageController::buildQuery()

File

drupal/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php, line 217
Definition of Drupal\Core\Config\Entity\ConfigStorageController.

Class

ConfigStorageController
Defines the storage controller class for configuration entities.

Namespace

Drupal\Core\Config\Entity

Code

protected function buildQuery($ids, $revision_id = FALSE) {
  $config_class = $this->entityInfo['class'];
  $prefix = $this
    ->getConfigPrefix();

  // Load all of the configuration entities.
  if ($ids === NULL) {
    $names = $this->configStorage
      ->listAll($prefix);
    $result = array();
    foreach ($names as $name) {
      $config = $this->configFactory
        ->get($name);
      $result[$config
        ->get($this->idKey)] = new $config_class($config
        ->get(), $this->entityType);
    }
    return $result;
  }
  else {
    $result = array();
    foreach ($ids as $id) {

      // Add the prefix to the ID to serve as the configuration object name.
      $config = $this->configFactory
        ->get($prefix . $id);
      if (!$config
        ->isNew()) {
        $result[$id] = new $config_class($config
          ->get(), $this->entityType);
      }
    }
    return $result;
  }
}