/** * Register our data source and renderer */ public function register() { /** * Set up the data source for the feed */ $this->app->bind('KoderHut\\RssFeedster\\DataSource', function ($app) { $config['page'] = Settings::get('post_page'); $config['comments_anchor'] = Settings::get('comments_anchor'); $config['controller'] = new Controller(); return new PostsSource($config); }); /** * Set up the adapter interface between the XML renderer and * the blog posts data */ $this->app->bind(IAdapter::DI_NAMESPACE, function () { return new BlogPostXmlAdapter(); }); /** * Set up the feed renderer */ $this->app->bind('KoderHut\\RssFeedster\\Renderer', function ($app) { $config = ['description' => Settings::get('feed_description'), 'title' => Settings::get('feed_title'), 'category' => Settings::get('feed_category'), 'copyright' => Settings::get('feed_copyright'), 'language' => Settings::get('feed_language'), 'link' => Url::action('KoderHut\\RssFeedster\\Controllers\\Rss@buildRssFeed')]; $pluginPath = PluginManager::instance()->getPluginPath(Plugin::KODERHUT_RSSFEEDSTER_NS); $xmlTemplate = $pluginPath . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR . 'feed-template.xml'; return new XmlRenderer($config, file_get_contents($xmlTemplate), $this->app->make(IAdapter::DI_NAMESPACE)); }); return; }
/** * Constructor * * @throws ApplicationException */ public function __construct(IDataSource $source = null, IRenderer $renderer = null, Settings $config = null) { $config = $config instanceof Settings ? $config : Settings::instance(); $this->validateSettings($config); $this->feedTitle = $config->feed_title; $this->dataRowsLimit = $config->post_max_number; $this->fullContent = $config->post_full_content; $this->source = $source ?: DataSource::getFacadeRoot(); $this->renderer = $renderer ?: Renderer::getFacadeRoot(); }
/** * Set up the test case */ public function setUp() { parent::setUp(); /** * Create a mock-up of the Settings object * TODO: find a better way to mock this object */ $config = Settings::instance(); $config->setAttribute('feed_title', 'test'); /** * Set up the data source for the feed */ App::bind('KoderHut\\RssFeedster\\DataSource', function ($app) { return new MockDataSource(); }); /** * Set up the feed renderer */ App::bind('KoderHut\\RssFeedster\\Renderer', function ($app) { $config = ['description' => 'feed description', 'title' => 'feed title', 'category' => 'feed category', 'copyright' => 'feed copyright', 'language' => 'feed language', 'link' => 'feed url']; return new MockJsonRenderer($config); }); $this->feed = new Feedster(null, null, $config); }