/**
* Generate query expression for a Criterion this handler accepts.
*
* accept() must be called before calling this method.
*
* @param \eZ\Publish\Core\Search\Legacy\Content\Common\Gateway\CriteriaConverter $converter
* @param \eZ\Publish\Core\Persistence\Database\SelectQuery $query
* @param \eZ\Publish\API\Repository\Values\Content\Query\Criterion $criterion
* @param array $languageSettings
*
* @return \eZ\Publish\Core\Persistence\Database\Expression
*/
public function handle(CriteriaConverter $converter, SelectQuery $query, Criterion $criterion, array $languageSettings)
{
switch ($criterion->target) {
case Criterion\UserMetadata::MODIFIER:
return $query->expr->in($this->dbHandler->quoteColumn('creator_id', 'ezcontentobject_version'), $criterion->value);
case Criterion\UserMetadata::GROUP:
$subSelect = $query->subSelect();
$subSelect->select($this->dbHandler->quoteColumn('contentobject_id', 't1'))->from($query->alias($this->dbHandler->quoteTable('ezcontentobject_tree'), 't1'))->innerJoin($query->alias($this->dbHandler->quoteTable('ezcontentobject_tree'), 't2'), $query->expr->like('t1.path_string', $query->expr->concat('t2.path_string', $query->bindValue('%'))))->where($query->expr->in($this->dbHandler->quoteColumn('contentobject_id', 't2'), $criterion->value));
return $query->expr->in($this->dbHandler->quoteColumn('owner_id', 'ezcontentobject'), $subSelect);
case Criterion\UserMetadata::OWNER:
return $query->expr->in($this->dbHandler->quoteColumn('owner_id', 'ezcontentobject'), $criterion->value);
}
throw new RuntimeException("Invalid target criterion encountered:'" . $criterion->target . "'");
}