[TYPO3-mvc] query->matching() constraint replacement.
Dennis Ahrens
dennis.ahrens at googlemail.com
Tue Aug 24 15:10:15 CEST 2010
Hi list,
the method matching() replaces the given constraint - i think it would
be nice, if an initial constraint will be conjuncted with logicalAnd().
The motivation is the following: It is possible to predefine constraints
that shall be applied to all queries inside createQuery(). e.g. access
restriction. Any opinions related to this topic? Any other solutions to
get a constraint into each query?
Sample implementation:
/**
* The constraint used to limit the result set. Returns $this to allow
* for chaining (fluid interface)
*
* @param Tx_Extbase_Persistence_QOM_ConstraintInterface $constraint
* @return Tx_Extbase_Persistence_QueryInterface
* @api
*/
public function matching($constraint, $replaceConstraint = TRUE) {
if($this->constraint === NULL) {
$this->constraint = $constraint;
} else {
if ($replaceConstraint === TRUE) {
$this->constraint = $constraint;
} else {
$this->constraint = $this->logicalAnd($this->constraint,$constraint);
}
}
return $this;
}
regards
Dennis
More information about the TYPO3-project-typo3v4mvc
mailing list