/** * @param $id * @param array $data * @return EntityInterface|void */ public function update($id, array $data) { $this->entity = $this->repository->find($this->criteriaFactory->getNativeCriteria('Id', $id)); if (!$this->entity) { return false; } if (!$this->isValid($data)) { return false; } $data = $this->inputFilter->getValues(); $this->entity->populate($data); if ($this->eventManager) { $name = 'update:pre'; $event = new Event($name, $this, array('entity' => $this->entity)); $this->eventManager->trigger($event); if ($event->getParam('entity') && $event->getParam('entity') instanceof EntityInterface) { $this->entity = $event->getParam('entity'); } } $this->repository->add($this->entity); $this->trigger('update:post', $this->entity); return $this->entity; }
protected function isEntityChanged(EntityInterface $changedEntity) { $originalEntity = $this->identityMapOriginal->offsetGet($changedEntity->getId()); return $changedEntity != $originalEntity; }