mothership-ec / cog

Cog
Other
2 stars 3 forks source link

Feature/callback filter #476

Closed kuiche closed 8 years ago

kuiche commented 8 years ago

Adds a new Filter which uses callbacks. This is useful for simple filters for which an entire extra class/service is overkill.

Try in conjunction with the page loader. For example:

$pages = $pageLoader->loadFromFilters(new FilterCollection([
    $filter = new \Message\Cog\Filter\CallbackFilter('cross-sell', 'CrossSell', function($qb) {
        return $qb
            ->orderBy('RAND()')
            ->where('page.type = \'product\'')
            ->limit(2);
    })
]));