function ContentEntityStorageBase::cleanIds
Same name in other branches
- 9 core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php \Drupal\Core\Entity\ContentEntityStorageBase::cleanIds()
- 8.9.x core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php \Drupal\Core\Entity\ContentEntityStorageBase::cleanIds()
- 10 core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php \Drupal\Core\Entity\ContentEntityStorageBase::cleanIds()
Ensures integer entity key values 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 key values to verify.
string $entity_key: (optional) The entity key to sanitize values for. Defaults to 'id'.
Return value
array The sanitized list of entity key values.
2 calls to ContentEntityStorageBase::cleanIds()
- SqlContentEntityStorage::doLoadMultipleRevisionsFieldItems in core/
lib/ Drupal/ Core/ Entity/ Sql/ SqlContentEntityStorage.php - Actually loads revision field item values from the storage.
- 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 1061
Class
- ContentEntityStorageBase
- Base class for content entity storage handlers.
Namespace
Drupal\Core\EntityCode
protected function cleanIds(array $ids, $entity_key = 'id') {
$definitions = $this->entityFieldManager
->getActiveFieldStorageDefinitions($this->entityTypeId);
$field_name = $this->entityType
->getKey($entity_key);
if ($field_name && $definitions[$field_name]->getType() == 'integer') {
$ids = array_filter($ids, function ($id) {
return is_numeric($id) && $id == (int) $id;
});
$ids = array_map('intval', $ids);
}
return $ids;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.