Esempio n. 1
0
 public function deleteAll($attributeValue, $attributeName = 'Id')
 {
     /** @var $criteria AbstractCriteria */
     $criteria = $this->criteriaFactory->getNativeCriteria($attributeName, $attributeValue);
     $collection = $this->repository->findMany($criteria);
     if (!$collection->count()) {
         $this->setErrors(array('general' => 'Entities does not found.'));
         return false;
     }
     $this->repository->deleteByAttribute($attributeValue, $criteria->getField());
     $this->trigger('deleteAll:post', $collection, 'collection');
     return $collection;
 }
Esempio n. 2
0
 /**
  * @param array $data
  * @return EntityInterface|null
  */
 public function create(array $data)
 {
     if (!$this->isValid($data)) {
         return;
     }
     $data = $this->inputFilter->getValues();
     if (empty($data)) {
         throw new \RuntimeException("Cannot create entity form empty data");
     }
     $entity = $this->entityFactory->create($data);
     $this->repository->add($entity);
     $this->trigger($entity);
     return $entity;
 }
Esempio n. 3
0
 public function updateAll($attributeValue, $attributeName = 'id', array $data)
 {
     $criteria = $this->criteriaFactory->getNativeCriteria($attributeName, $attributeValue);
     $collection = $this->repository->findMany($criteria);
     if (!$collection->count()) {
         return false;
     }
     $this->repository->updateByAttribute($data, $attributeValue, $criteria->getField());
     return $collection;
 }