protected function prepareEntity(Entity $entity) { /** @var \EvaCatalog\Entity\Attribute $entity */ if (!$entity->getCategory()) { if (!$this->getServiceManager()->getRouter()->getParams()->exists('id')) { $this->getServiceManager()->getRouter()->notFound(); } $categoryId = $this->getServiceManager()->getRouter()->getParams()->get('id'); /** @var \EvaCatalog\Entity\Category $category */ $category = $this->getCategoryRepository()->find($categoryId); $entity->setCategory($category); } parent::prepareEntity($entity); }
public function setIdentity(Entity $entity) { $this->getStorage()->set('identity', $entity->getId()); }
/** * Удаление записи * * @param Entity $entity * @return bool */ public function delete(Entity $entity) { $criteria = ['id' => $entity->getId()]; return $this->deleteBy($criteria); }