public function handle(CriteriaConverter $converter, SelectQuery $query, Criterion $criterion, array $languageSettings)
{
$table = 'permission_subtree';
$statements = array();
foreach ($criterion->value as $pattern) {
$statements[] = $query->expr->like($this->dbHandler->quoteColumn('path_string', $table), $query->bindValue($pattern . '%'));
}
// Check if ezcontentobject_tree was already joined, if it was there is no need to join
// with it again - first join will be reused by all other PermissionSubtree criteria
/** @var $query \eZ\Publish\Core\Persistence\Doctrine\SelectDoctrineQuery */
if (!$query->permissionSubtreeJoinAdded) {
$query->leftJoin($query->alias($this->dbHandler->quoteTable('ezcontentobject_tree'), $this->dbHandler->quoteIdentifier($table)), $query->expr->eq($this->dbHandler->quoteColumn('contentobject_id', $table), $this->dbHandler->quoteColumn('id', 'ezcontentobject')));
// Set joined state to true
$query->permissionSubtreeJoinAdded = true;
}
return $query->expr->lOr($statements);
}