[Flow] fetching constraints from repository method
Alexander Wende
a_wende at web.de
Thu Jul 24 17:52:38 CEST 2014
In one of my repositories I have some default constraints which should be added with an logical AND to all queries.
My findAll method looks like this:
/**
*
* @return \TYPO3\Flow\Persistence\QueryResultInterface The query result
*/
public function findAll() {
$query = $this->createQuery();
$lastRevisionsConstraint = $query->equals('nextRevision',NULL);
$notDeletedConstraint = $query->equals('deleted',"0");
$result = $query->matching($query->logicalAnd(array($lastRevisionsConstraint,$notDeletedConstraint)))->execute();
return $result;
}
This works fine. But I don't want to repeat myself again and again for the other methods. So I moved the default constraints part into a seperate method.
Now I have two functions:
/**
* @return object
*/
protected function getDefaultConstraints(){
$query = $this->createQuery();
$lastRevisionsConstraint = $query->equals('nextRevision',NULL);
$notDeletedConstraint = $query->equals('deleted',"0");
return $query->logicalAnd(array($lastRevisionsConstraint,$notDeletedConstraint));
}
}
/**
*
* @return \TYPO3\Flow\Persistence\QueryResultInterface The query result
*/
public function findAll() {
$query = $this->createQuery();
$result = $query->matching($this->getDefaultConstraints())->execute();
return $result;
}
But this doesn't work. I thought it could a problem with the return annotation of the getDefaultConstraints method. So I changed it to \TYPO3\Flow\Persistence\Generic\Qom\LogicalAnd but it didn't work.
In the Exception Log I found the following exceptions:
Uncaught exception in line 255 of /var/www/flow3/Quickstart/Packages/Libraries/doctrine/orm/lib/Doctrine/ORM/Query.php: Invalid parameter number: number of bound variables does not match number of tokens
More information about the Flow
mailing list