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; }
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; }
/** * @expectedException \RuntimeException * @expectedExceptionMessage Criteria class T4webBaseTest\Domain\Criteria\UnknownCriteria not found */ public function testGetNativeCriteriaBadCriteria() { $criteries = array('Domain' => array('empty' => array('table' => 'table'), 'id' => array('field' => 'field', 'table' => 'table', 'buildMethod' => 'buildMethod'), 'productId' => array('field' => 'field1', 'table' => 'table1', 'buildMethod' => 'buildMethod1'))); $factory = new Factory('T4webBaseTest', 'Domain', array(), $criteries); $factory->getNativeCriteria('UnknownCriteria', 1); }