Skip to content

Commit

Permalink
channel adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
mparaiso committed Mar 23, 2013
1 parent 65512e5 commit dd37f38
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
Expand Up @@ -2,7 +2,7 @@

namespace Mparaiso\Rss\Adapter;

interface IItemAdapter{
interface IChannelAdapter{
/**
* convert a model to an associative array
* @param $data
Expand All @@ -16,4 +16,4 @@ function toChannel($data);
* @return mixed
*/
function toModel($channel);
}
}
3 changes: 2 additions & 1 deletion src/Mparaiso/Rss/Builder/views/template.rss.twig
Expand Up @@ -20,7 +20,8 @@
<item>
<title>{{ item.title }}</title>
<description>{{ item.description }}</description>
<guid isPermaLink='{{ item.isPermalink|default("false") }}'>{{ item.guid }}</guid>
<guid isPermaLink='{{ item.isPermalink|default("false") }}'>{{ item.link }}</guid>
<link>{{ item.link }}</guid>
<pubDate>{{ item.pubDate|date("D, d M Y H:i:s T") }}</pubDate>
</item>
{% endfor %}
Expand Down
18 changes: 9 additions & 9 deletions src/Mparaiso/Rss/SimpleRss.php
Expand Up @@ -5,7 +5,7 @@
use Mparaiso\Rss\Builder\RssTwigBuilder;
use Mparaiso\Rss\Loader\FileLoader;
use Mparaiso\Rss\Loader\ILoader;
use Mparaiso\Rss\Adapter\IItemAdapter;
use Mparaiso\Rss\Adapter\IChannelAdapter;
use Mparaiso\Rss\Builder\IBuilder;

/**
Expand All @@ -26,7 +26,7 @@ class SimpleRss
* @var Mparaiso\Rss\Loader\ILoader
*/
protected $loader;
protected $itemAdapter;
protected $channelAdapter;

function __construct(array $channel, IBuilder $builder = NULL, ILoader $loader = NULL)
{
Expand Down Expand Up @@ -63,8 +63,8 @@ public function setBuilder($builder)

function generate()
{
if (isset($this->itemAdapter)) {
$channel = $this->itemAdapter->toChannel($this->channel);
if (isset($this->channelAdapter)) {
$channel = $this->channelAdapter->toChannel($this->channel);
} else {
$channel = $this->channel;
}
Expand All @@ -84,14 +84,14 @@ function fetch($file = NULL)
return $this->loader->load();
}

public function getItemAdapter()
public function getChannelAdapter()
{
return $this->itemAdapter;
return $this->channelAdapter;
}

public function setItemAdapter(IItemAdapter $itemAdapter)
public function setItemAdapter(IChannelAdapter $channelAdapter)
{
$this->itemAdapter = $itemAdapter;
$this->channelAdapter = $channelAdapter;
}

public function getLoader()
Expand All @@ -105,4 +105,4 @@ public function setLoader($loader)
}


}
}

0 comments on commit dd37f38

Please sign in to comment.