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);
 }
Exemple #2
0
 public function setIdentity(Entity $entity)
 {
     $this->getStorage()->set('identity', $entity->getId());
 }
Exemple #3
0
 /**
  * Удаление записи
  *
  * @param Entity $entity
  * @return bool
  */
 public function delete(Entity $entity)
 {
     $criteria = ['id' => $entity->getId()];
     return $this->deleteBy($criteria);
 }