本文整理汇总了PHP中Doctrine\ODM\PHPCR\DocumentManager::hasLocaleChooserStrategy方法的典型用法代码示例。如果您正苦于以下问题:PHP DocumentManager::hasLocaleChooserStrategy方法的具体用法?PHP DocumentManager::hasLocaleChooserStrategy怎么用?PHP DocumentManager::hasLocaleChooserStrategy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ODM\PHPCR\DocumentManager
的用法示例。
在下文中一共展示了DocumentManager::hasLocaleChooserStrategy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getQuery
/**
* Returns an ODM Query object from the given ODM (query) Builder.
*
* Dispatches the From, Select, Where and OrderBy nodes. Each of these
* "root" nodes append or set PHPCR QOM objects to corresponding properties
* in this class, which are subsequently used to create a PHPCR QOM object which
* is embedded in an ODM Query object.
*
* @param QueryBuilder $builder
*
* @return Query
*/
public function getQuery(QueryBuilder $builder)
{
$this->aliasWithTranslatedFields = array();
$this->locale = $builder->getLocale();
if (null === $this->locale && $this->dm->hasLocaleChooserStrategy()) {
$this->locale = $this->dm->getLocaleChooserStrategy()->getLocale();
}
$from = $builder->getChildrenOfType(QBConstants::NT_FROM);
if (!$from) {
throw new RuntimeException('No From (source) node in query');
}
$dispatches = array(QBConstants::NT_FROM, QBConstants::NT_SELECT, QBConstants::NT_WHERE, QBConstants::NT_ORDER_BY);
foreach ($dispatches as $dispatchType) {
$this->dispatchMany($builder->getChildrenOfType($dispatchType));
}
if (count($this->sourceDocumentNodes) > 1 && null === $builder->getPrimaryAlias()) {
throw new InvalidArgumentException('You must specify a primary alias when selecting from multiple document sources' . 'e.g. $qb->from(\'a\') ...');
}
// for each document source add phpcr:{class,classparents} restrictions
foreach ($this->sourceDocumentNodes as $sourceNode) {
$documentFqn = $this->aliasMetadata[$sourceNode->getAlias()]->getName();
$odmClassConstraints = $this->qomf->orConstraint($this->qomf->comparison($this->qomf->propertyValue($sourceNode->getAlias(), 'phpcr:class'), QOMConstants::JCR_OPERATOR_EQUAL_TO, $this->qomf->literal($documentFqn)), $this->qomf->comparison($this->qomf->propertyValue($sourceNode->getAlias(), 'phpcr:classparents'), QOMConstants::JCR_OPERATOR_EQUAL_TO, $this->qomf->literal($documentFqn)));
if ($this->constraint) {
$this->constraint = $this->qomf->andConstraint($this->constraint, $odmClassConstraints);
} else {
$this->constraint = $odmClassConstraints;
}
}
foreach (array_keys($this->aliasWithTranslatedFields) as $alias) {
$this->translator[$alias]->alterQueryForTranslation($this->qomf, $this->from, $this->constraint, $alias, $this->locale);
}
$phpcrQuery = $this->qomf->createQuery($this->from, $this->constraint, $this->orderings, $this->columns);
$query = new Query($phpcrQuery, $this->dm, $builder->getPrimaryAlias());
if ($firstResult = $builder->getFirstResult()) {
$query->setFirstResult($firstResult);
}
if ($maxResults = $builder->getMaxResults()) {
$query->setMaxResults($maxResults);
}
return $query;
}