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; }
/** * @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; }
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; }