public function getById($id) { $id = implode(',', (array) $id); if (!isset($this->entities[$id])) { return null; } return $this->entities[$id]; }
public function getById($id) { if ($id === NULL) { return NULL; } elseif ($id instanceof IEntity) { $id = $id->id; } elseif (!(is_scalar($id) || is_array($id))) { throw new InvalidArgumentException('Primary key value has to be a scalar.'); } $entity = $this->identityMap->getById($id); if ($entity === FALSE) { return NULL; } elseif ($entity instanceof IEntity) { return $entity; } $entity = $this->findAll()->getBy(['id' => $id]); if ($entity === NULL) { $this->identityMap->remove($id); } return $entity; }