You are here

protected function ContentEntityStorageBase::cleanIds in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php \Drupal\Core\Entity\ContentEntityStorageBase::cleanIds()

Ensures integer entity IDs are valid.

The identifier sanitization provided by this method has been introduced as Drupal used to rely on the database to facilitate this, which worked correctly with MySQL but led to errors with other DBMS such as PostgreSQL.

Parameters

array $ids: The entity IDs to verify.

Return value

array The sanitized list of entity IDs.

1 call to ContentEntityStorageBase::cleanIds()
SqlContentEntityStorage::getFromStorage in core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php
Gets entities from the storage.

File

core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php, line 544
Contains \Drupal\Core\Entity\ContentEntityStorageBase.

Class

ContentEntityStorageBase
Base class for content entity storage handlers.

Namespace

Drupal\Core\Entity

Code

protected function cleanIds(array $ids) {
  $definitions = $this->entityManager
    ->getBaseFieldDefinitions($this->entityTypeId);
  $id_definition = $definitions[$this->entityType
    ->getKey('id')];
  if ($id_definition
    ->getType() == 'integer') {
    $ids = array_filter($ids, function ($id) {
      return is_numeric($id) && $id == (int) $id;
    });
    $ids = array_map('intval', $ids);
  }
  return $ids;
}