Skip to content
This repository has been archived by the owner on Jan 22, 2018. It is now read-only.

Commit

Permalink
add multiple filters support
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Kerin committed Oct 16, 2013
1 parent f056087 commit d87b42e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
13 changes: 9 additions & 4 deletions classes/Kohana/Task/Feed/Generate.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ protected function _execute(array $options)

Minion_CLI::write('Generating '.json_encode($config));

$content = $this->feed_content($config['model'], $config['filter'], $config['view']);
$filters = is_array($config['filter']) ? $config['filter'] : explode(',', $config['filter']);

$content = $this->feed_content($config['model'], (array) $filters, $config['view']);

Minion_CLI::write('Done.');

Expand All @@ -58,13 +60,16 @@ public function config($name)
return $config;
}

public function feed_content($model, $filter, $view)
public function feed_content($model, array $filters, $view)
{
$collection = Jam::all($model);

if ($filter)
if ($filters)
{
$collection->{$filter}();
foreach ($filters as $filter)
{
$collection->{$filter}();
}
}

return View::factory($view, array('collection' => $collection))->render();
Expand Down
4 changes: 2 additions & 2 deletions tests/tests/Task/Feed/GenerateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public function test_feed_content()
{
$task = Minion_Task::factory(array('feed:generate'));

$content = $task->feed_content('product', NULL, 'test/feedtest');
$content = $task->feed_content('product', array(), 'test/feedtest');

$expected = <<<CONTENT
<products>
Expand Down Expand Up @@ -41,7 +41,7 @@ public function test_feed_content_with_filter()
{
$task = Minion_Task::factory(array('feed:generate'));

$content = $task->feed_content('product', 'feed_test', 'test/feedtest');
$content = $task->feed_content('product', array('feed_test'), 'test/feedtest');

$expected = <<<CONTENT
<products>
Expand Down

0 comments on commit d87b42e

Please sign in to comment.