本文整理匯總了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;
}