本文整理汇总了PHP中Doctrine\ORM\QueryBuilder::setHint方法的典型用法代码示例。如果您正苦于以下问题:PHP QueryBuilder::setHint方法的具体用法?PHP QueryBuilder::setHint怎么用?PHP QueryBuilder::setHint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ORM\QueryBuilder
的用法示例。
在下文中一共展示了QueryBuilder::setHint方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: apply
/**
* Apply ACL filter
*
* @param QueryBuilder | Query $query
* @param array $permissions
* @param string | UserInterface $identity
* @param string $alias
* @param array|Query|QueryBuilder $extraCriteria
*
* @return Query
*/
public function apply($query, array $permissions = array('VIEW'), $identity = null, $alias = null, $extraCriteria = false)
{
if (null === $identity) {
$token = $this->securityContext->getToken();
$identity = $token->getUser();
}
$query->setHint(static::HINT_ACL_EXTRA_CRITERIA, $this->getExtraCriteria($extraCriteria));
if ($query instanceof QueryBuilder) {
$query = $this->cloneQuery($query->getQuery());
} elseif ($query instanceof Query) {
$query = $this->cloneQuery($query);
} else {
throw new \Exception();
}
$maskBuilder = new MaskBuilder();
foreach ($permissions as $permission) {
$mask = constant(get_class($maskBuilder) . '::MASK_' . strtoupper($permission));
$maskBuilder->add($mask);
}
$entity = $this->getEntityFromAlias($query, $alias);
$metadata = $entity['metadata'];
$alias = $entity['alias'];
$table = $metadata->getQuotedTableName($this->em->getConnection()->getDatabasePlatform());
$aclQuery = $this->getExtraQuery($this->getClasses($metadata), $this->getIdentifiers($identity), $maskBuilder->get());
$hintAclMetadata = false !== $query->getHint('acl.metadata') ? $query->getHint('acl.metadata') : array();
$hintAclMetadata[] = array('query' => $aclQuery, 'table' => $table, 'alias' => $alias);
$query->setHint('acl.metadata', $hintAclMetadata);
$query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, $this->aclWalker);
return $query;
}