本文整理汇总了PHP中Doctrine\ODM\PHPCR\DocumentManager::getDocumentsByQuery方法的典型用法代码示例。如果您正苦于以下问题:PHP DocumentManager::getDocumentsByQuery方法的具体用法?PHP DocumentManager::getDocumentsByQuery怎么用?PHP DocumentManager::getDocumentsByQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ODM\PHPCR\DocumentManager
的用法示例。
在下文中一共展示了DocumentManager::getDocumentsByQuery方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPagesByTags
/**
* Connect to Jackrabbit, and filter pages by tags
*
* @param $tags array with stanbol references
* @param $currentUrl string current url
* @param $lang string language
*
* @return array with links to pages
*/
protected function getPagesByTags($tags, $currentUrl, $lang)
{
$this->basePath = $this->basePath . '/' . $lang;
foreach ($tags as $i => $tag) {
$tags[$i] = 'referring.tags = ' . $this->dm->quote($tag);
}
$sql = 'SELECT routes.* FROM [nt:unstructured] AS routes';
$sql .= ' INNER JOIN [nt:unstructured] AS referring ON referring.[jcr:uuid] = routes.[routeContent]';
$sql .= ' WHERE (ISDESCENDANTNODE(routes, ' . $this->dm->quote($this->basePath) . ') OR ISSAMENODE(routes, ' . $this->dm->quote($this->basePath) . '))';
$sql .= ' AND (' . implode(' OR ', $tags) . ')';
$query = $this->dm->createQuery($sql, QueryInterface::JCR_SQL2);
$query->setLimit(-1);
$pages = $this->dm->getDocumentsByQuery($query);
$links = array();
foreach ($pages as $page) {
if ($page instanceof Route && $page->getRouteContent()) {
$url = $this->router->generate('', array('_locale' => $lang, 'content' => $page->getRouteContent()), true);
if (preg_replace('/^\\/|\\/$/', '', $url) !== preg_replace('/^\\/|\\/$/', '', $currentUrl)) {
$label = $page->getRouteContent()->title;
$links[] = array('url' => $url, 'label' => $label);
}
}
}
return $links;
}
示例2: getDocumentsByQuery
/**
* Get documents from a PHPCR query instance
*
* @param \PHPCR\Query\QueryResultInterface $result
* @return array of document instances
*/
public function getDocumentsByQuery(\PHPCR\Query\QueryInterface $query)
{
return $this->dm->getDocumentsByQuery($query, $this->className);
}