public function persist($entity)
{
if ($this->evm->hasListeners(Events::prePersist)) {
$this->evm->dispatchEvent(Events::prePersist, new Event\LifecycleEventArgs($entity, $this->sm));
}
$oid = spl_object_hash($entity);
$this->scheduledForPersist[$oid] = $entity;
if ($this->evm->hasListeners(Events::postPersist)) {
$this->evm->dispatchEvent(Events::postPersist, new Event\LifecycleEventArgs($entity, $this->sm));
}
}
/** * Adds the object to the index * * @param array|object $objects * * @throws UnexpectedTypeException */ public function persist($objects) { if (!is_array($objects) && !$objects instanceof \Traversable) { $objects = array($objects); } foreach ($objects as $object) { if (!is_object($object)) { throw new UnexpectedTypeException($object, 'object'); } $this->unitOfWork->persist($object); } }