Skip to content

Commit

Permalink
added type param
Browse files Browse the repository at this point in the history
  • Loading branch information
wachterjohannes committed Aug 2, 2016
1 parent 835493b commit 33d6148
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
16 changes: 15 additions & 1 deletion Content/ArticleDataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use ProxyManager\Proxy\LazyLoadingInterface;
use Sulu\Bundle\ArticleBundle\Document\ArticleDocument;
use Sulu\Bundle\ArticleBundle\Document\ArticleOngrDocument;
use Sulu\Component\Content\Compat\PropertyParameter;
use Sulu\Component\DocumentManager\DocumentManagerInterface;
use Sulu\Component\SmartContent\Configuration\Builder;
use Sulu\Component\SmartContent\DataProviderInterface;
Expand Down Expand Up @@ -81,7 +82,7 @@ public function getConfiguration()
*/
public function getDefaultPropertyParameter()
{
return [];
return ['type' => new PropertyParameter('type', null)];
}

/**
Expand All @@ -95,6 +96,10 @@ public function resolveDataItems(
$page = 1,
$pageSize = null
) {
if (array_key_exists('type', $propertyParameter) && null !== ($type = $propertyParameter['type']->getValue())) {
$filters['type'] = $type;
}

$result = [];
$uuids = [];
/** @var ArticleOngrDocument $document */
Expand All @@ -117,6 +122,10 @@ public function resolveResourceItems(
$page = 1,
$pageSize = null
) {
if (array_key_exists('type', $propertyParameter) && null !== ($type = $propertyParameter['type']->getValue())) {
$filters['type'] = $type;
}

$result = [];
$uuids = [];
/** @var ArticleOngrDocument $document */
Expand Down Expand Up @@ -167,6 +176,11 @@ private function getSearchResult(array $filters, $limit, $page, $pageSize)
$operator = $this->getFilter($filters, 'websiteCategoriesOperator', 'or');
$this->addBoolQuery('websiteCategories', $filters, 'excerpt.categories', $operator, $query, $queriesCount);

if (array_key_exists('type', $filters)) {
$query->add(new TermQuery('type', $filters['type']));
$queriesCount++;
}

if (0 === $queriesCount) {
$search->addQuery(new MatchAllQuery());
} else {
Expand Down
2 changes: 1 addition & 1 deletion Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
<service id="sulu_article.content.data_provider.proxy_factory"
class="ProxyManager\Factory\LazyLoadingValueHolderFactory"/>
<service id="sulu_article.content.data_provider" class="Sulu\Bundle\ArticleBundle\Content\ArticleDataProvider">
<argument type="service" id="es.manager.default"/>
<argument type="service" id="es.manager.live"/>
<argument type="service" id="sulu_document_manager.document_manager"/>
<argument type="service" id="sulu_article.content.data_provider.proxy_factory"/>

Expand Down

0 comments on commit 33d6148

Please sign in to comment.