Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
$ composer require syzygypl/kunstmaan-feed-bundle
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
Then, enable the bundle by adding it to the list of registered bundles
in the app/AppKernel.php
file of your project:
<?php
// app/AppKernel.php
// ...
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
// ...
new SZG\KunstmaanFeedBundle\KunstmaanFeedBundle(),
);
// ...
}
// ...
}
article
below represents an indexed type. It may be define as search_type in page configuration.
kunstmaan_node:
pages:
'AppBundle\Entity\Pages\ArticlePage':
...
indexable: true
search_type: article
{# Short notation, use defaults #}
{% set articles = get_article_feed() %}
{# Simple notation #}
{% set articles = get_recent_article_feed({ limit: 100 }) %}
{# full notation #}
{% set articles = get_feed_items('article', { limit: 100, feed: 'recent' }) %}
{% set random_product = get_random_product_feed({ limit: 1 }) %}
<?php
// ...
$articles = $this->get('szg_feed.elastic_search_items_provider')->getFeedItems('article', [
'feed' => 'recent',
'limit' => 100
]);
<?php
// ...
$articles = $this->get('szg_feed.elastic_search_items_provider')->getFeedItems('product', [
'feed' => 'random',
'limit' => 1
]);
Option | Type | Description | Default |
---|---|---|---|
page | int | Current page number | 1 |
limit | int | Items per page | 100 |
category | HasNodeInterface Category |
Page children Category children |
null |
tags | string array Taggable |
Single tag Tags collection Object implements Taggable interface |
null |
tags_logic | 'any' 'all' 'few' |
at least one must fit all must fit 33% must fit |
'any' |
excluded | HasNodeInterface Node NodeTranslation Category Result string NodeId int NodeId |
Array of elements to exclude from results. | null |
feed | 'recent' 'random' <...custom_feed> |
Feed alias | 'recent' |
returnRawResultSet | bool | Return raw result set | false |
offsetOverride | int | null | Override offset counted by page limit and page number by default |
extra | mixed | You can pass any data to RelationDefinition and use it for custom query | null |
Configure custom feeds in config.yml
kunstmaan_feed:
custom:
title : 'desc'
Implement SZG\KunstmaanFeedBundle\Feed\ElasticSearch\Interfaces\FeedElasticSearchInterface
.
<?php
// ...
class TitleDesc extends FeedElasticSearchInterface
{
/**
* @param QueryDefinition $queryDefinition
*/
public function modifyQuery(QueryDefinition $queryDefinition)
{
$queryDefinition->getQuery()->addSort(['title' => ['order' => 'desc']]);
}
}
szg_feed.feed.title:
class: AppBundle\Feed\TitleDesc
tags:
- { name: szg_feed.feed, alias: title }
{% set articlesByTitle = get_title_article_feed() %}