protected ContentEntityStorageBase::cleanIds(array $ids)
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.
array $ids: The entity IDs to verify.
array The sanitized list of entity IDs.
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; }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Entity!ContentEntityStorageBase.php/function/ContentEntityStorageBase::cleanIds/8.1.x