summaryrefslogtreecommitdiffstats
path: root/dependencyinjection
diff options
context:
space:
mode:
authorBernhard Posselt <Raydiation@users.noreply.github.com>2013-09-26 03:48:44 -0700
committerBernhard Posselt <Raydiation@users.noreply.github.com>2013-09-26 03:48:44 -0700
commitcec643c249fb97a940b197287474341bdc598977 (patch)
treecb699c00b622df3ce85db1994384d939806c3a07 /dependencyinjection
parent7ea5a6b4881621f5a6ce43e18d6bc748bbeb7637 (diff)
parenteff84feac3affa2180923b905ae0987033b041e9 (diff)
Merge pull request #372 from owncloud/enhancer-json
move simple enhancer config into json file
Diffstat (limited to 'dependencyinjection')
-rw-r--r--dependencyinjection/dicontainer.php88
1 files changed, 16 insertions, 72 deletions
diff --git a/dependencyinjection/dicontainer.php b/dependencyinjection/dicontainer.php
index 94806b2f7..9efc9669d 100644
--- a/dependencyinjection/dicontainer.php
+++ b/dependencyinjection/dicontainer.php
@@ -61,13 +61,8 @@ use \OCA\News\Utility\Updater;
use \OCA\News\Utility\SimplePieFileFactory;
use \OCA\News\Utility\ArticleEnhancer\Enhancer;
-use \OCA\News\Utility\ArticleEnhancer\CyanideAndHappinessEnhancer;
-use \OCA\News\Utility\ArticleEnhancer\ThemeRepublicEnhancer;
-use OCA\News\Utility\ArticleEnhancer\CADEnhancer;
-use OCA\News\Utility\ArticleEnhancer\PennyArcadeEnhancer;
+use \OCA\News\Utility\ArticleEnhancer\ArticleEnhancer;
use OCA\News\Utility\ArticleEnhancer\TwoGAGEnhancer;
-use OCA\News\Utility\ArticleEnhancer\LeastICouldDoEnhancer;
-use OCA\News\Utility\ArticleEnhancer\EscapistComicEnhancer;
use \OCA\News\Middleware\CORSMiddleware;
@@ -262,61 +257,27 @@ class DIContainer extends BaseContainer {
$this['Enhancer'] = $this->share(function($c){
$enhancer = new Enhancer();
- // register fetchers in order
- // the most generic enhancer should be the last one
- $enhancer->registerEnhancer('explosm.net', $c['CyanideAndHappinessEnhancer']);
- $enhancer->registerEnhancer('themerepublic.net', $c['ThemeRepublicEnhancer']);
- $enhancer->registerEnhancer('cad-comic.com', $c['CADEnhancer']);
- $enhancer->registerEnhancer('penny-arcade.com', $c['PennyArcadeEnhancer']);
+ // register enhancers which need special implementation
$enhancer->registerEnhancer('twogag.com', $c['TwoGAGEnhancer']);
- $enhancer->registerEnhancer('leasticoulddo.com', $c['LeastICouldDoEnhancer']);
- $enhancer->registerEnhancer('escapistmagazine.com/articles/view/comics/critical-miss', $c['EscapistComicEnhancer']);
- $enhancer->registerEnhancer('escapistmagazine.com/articles/view/comics/critical-miss', $c['EscapistComicEnhancer']);
- $enhancer->registerEnhancer('escapistmagazine.com/articles/view/comics/namegame', $c['EscapistComicEnhancer']);
- $enhancer->registerEnhancer('escapistmagazine.com/articles/view/comics/stolen-pixels', $c['EscapistComicEnhancer']);
- $enhancer->registerEnhancer('escapistmagazine.com/articles/view/comics/bumhugparade', $c['EscapistComicEnhancer']);
- $enhancer->registerEnhancer('escapistmagazine.com/articles/view/comics/escapistradiotheater', $c['EscapistComicEnhancer']);
- $enhancer->registerEnhancer('escapistmagazine.com/articles/view/comics/paused', $c['EscapistComicEnhancer']);
- $enhancer->registerEnhancer('escapistmagazine.com/articles/view/comics/fraughtwithperil', $c['EscapistComicEnhancer']);
-
- return $enhancer;
- });
-
- $this['DefaultEnhancer'] = $this->share(function($c){
- return new DefaultEnhancer();
- });
-
- $this['CyanideAndHappinessEnhancer'] = $this->share(function($c){
- return new CyanideAndHappinessEnhancer(
- $c['SimplePieFileFactory'],
- $c['HTMLPurifier'],
- $c['feedFetcherTimeout']
- );
- });
- $this['ThemeRepublicEnhancer'] = $this->share(function($c){
- return new ThemeRepublicEnhancer(
- $c['SimplePieFileFactory'],
- $c['HTMLPurifier'],
- $c['feedFetcherTimeout']
+ // register simple enhancers from config json file
+ $enhancerConfig = file_get_contents(
+ __DIR__ . '/../utility/articleenhancer/enhancers.json'
);
- });
+ //print_r( json_decode($enhancerConfig, true) );
+ foreach(json_decode($enhancerConfig, true) as $feed => $config) {
+ $articleEnhancer = new ArticleEnhancer(
+ $c['HTMLPurifier'],
+ $c['SimplePieFileFactory'],
+ $config,
+ $c['feedFetcherTimeout']
+ );
+ $enhancer->registerEnhancer($feed, $articleEnhancer);
+ }
- $this['CADEnhancer'] = $this->share(function($c){
- return new CADEnhancer(
- $c['SimplePieFileFactory'],
- $c['HTMLPurifier'],
- $c['feedFetcherTimeout']
- );
+ return $enhancer;
});
- $this['PennyArcadeEnhancer'] = $this->share(function($c){
- return new PennyArcadeEnhancer(
- $c['SimplePieFileFactory'],
- $c['HTMLPurifier'],
- $c['feedFetcherTimeout']
- );
- });
$this['TwoGAGEnhancer'] = $this->share(function($c){
return new TwoGAGEnhancer(
@@ -326,23 +287,6 @@ class DIContainer extends BaseContainer {
);
});
- $this['LeastICouldDoEnhancer'] = $this->share(function($c){
- return new LeastICouldDoEnhancer(
- $c['SimplePieFileFactory'],
- $c['HTMLPurifier'],
- $c['feedFetcherTimeout']
- );
- });
-
- $this['EscapistComicEnhancer'] = $this->share(function($c){
- return new EscapistComicEnhancer(
- $c['SimplePieFileFactory'],
- $c['HTMLPurifier'],
- $c['feedFetcherTimeout']
- );
- });
-
-
$this['Fetcher'] = $this->share(function($c){
$fetcher = new Fetcher();