[Flow] fetching constraints from repository method

Dominique Feyer dfeyer at ttree.ch
Thu Jul 24 18:04:29 CEST 2014


You can try to pass the current query to the method getDefaultConstraints, like this:

/** 
* @return object 
*/ 
protected function getDefaultConstraints($query){ 
$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($query))->execute(); 
return $result; 
} 

In your code you have two distinct query object.

Bests

--   
ttree sàrl  
Dominique Feyer  
Rue du Valentin 34 et demi
CH - 1004 Lausanne
+41 21  312 36 35  
dfeyer at ttree.ch
ttree.ch - @ttreeagency - plan d’accès

Le 24 juillet 2014 à 17:55:03, Alexander Wende (a_wende at web.de) a écrit:

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


More information about the Flow mailing list