示例#1
0
文件: Delete.php 项目: t4web/base
 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;
 }
示例#2
0
文件: Create.php 项目: t4web/base
 /**
  * @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;
 }
示例#3
0
文件: Update.php 项目: t4web/base
 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;
 }