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