DrupalDefaultEntityController::cleanIds

protected function DrupalDefaultEntityController::cleanIds

protected DrupalDefaultEntityController::cleanIds(&$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.

Parameters

array $ids: The entity IDs to verify. Non-integer IDs are removed from this array if the entity type requires IDs to be integers.

File

includes/entity.inc, line 242

Class

DrupalDefaultEntityController
Default implementation of DrupalEntityControllerInterface.

Code

protected function cleanIds(&$ids) {
  $entity_info = entity_get_info($this->entityType);
  if (isset($entity_info['base table field types'])) {
    $id_type = $entity_info['base table field types'][$this->idKey];
    if ($id_type == 'serial' || $id_type == 'int') {
      $ids = array_filter($ids, array($this, 'filterId'));
      $ids = array_map('intval', $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/includes!entity.inc/function/DrupalDefaultEntityController::cleanIds/7.x

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部