Update service provider

This commit is contained in:
Romain Neutron
2012-09-21 15:49:52 +02:00
parent b9e92fafff
commit d75b8ee239
5 changed files with 27 additions and 37 deletions

View File

@@ -22,18 +22,17 @@ class BorderManagerServiceProvider implements ServiceProviderInterface
{ {
$app['border-manager'] = $app->share(function(Application $app) { $app['border-manager'] = $app->share(function(Application $app) {
$configuration = $app['phraseanet.configuration'] $configuration = $app['phraseanet.configuration']
->getService($app['phraseanet.configuration'] ->getService($app['phraseanet.configuration']
->getBorder()); ->getBorder());
$service = Builder::create($app, $configuration); $service = Builder::create($app, $configuration);
return $service->getDriver(); return $service->getDriver();
}); });
} }
public function boot(Application $app) public function boot(Application $app)
{ {
} }
} }

View File

@@ -20,12 +20,11 @@ class BrowserServiceProvider implements ServiceProviderInterface
public function register(Application $app) public function register(Application $app)
{ {
$app['browser'] = $app->share(function($app) { $app['browser'] = $app->share(function($app) {
return new \Browser(); return new \Browser();
}); });
} }
public function boot(Application $app) public function boot(Application $app)
{ {
} }
} }

View File

@@ -20,33 +20,28 @@ class CacheServiceProvider implements ServiceProviderInterface
public function register(Application $app) public function register(Application $app)
{ {
$app['phraseanet.cache-service'] = $app->share(function(Application $app) { $app['phraseanet.cache-service'] = $app->share(function(Application $app) {
if ( ! file_exists(__DIR__ . '/../../../../../tmp/cache_registry.yml')) { if ( ! file_exists(__DIR__ . '/../../../../../tmp/cache_registry.yml')) {
touch(__DIR__ . '/../../../../../tmp/cache_registry.yml'); touch(__DIR__ . '/../../../../../tmp/cache_registry.yml');
} }
return new CacheManager($app, new \SplFileInfo(__DIR__ . '/../../../../../tmp/cache_registry.yml')); return new CacheManager($app, new \SplFileInfo(__DIR__ . '/../../../../../tmp/cache_registry.yml'));
}); });
$app['cache'] = $app->share(function(Application $app) { $app['cache'] = $app->share(function(Application $app) {
return $app['phraseanet.cache-service']
return $app['phraseanet.cache-service'] ->get('MainCache', $app['phraseanet.configuration']->getCache())
->get('MainCache', $app['phraseanet.configuration']->getCache()) ->getDriver();
->getDriver(); });
});
$app['opcode-cache'] = $app->share(function(Application $app) { $app['opcode-cache'] = $app->share(function(Application $app) {
return $app['phraseanet.cache-service']
return $app['phraseanet.cache-service'] ->get('OpcodeCache', $app['phraseanet.configuration']->getOpcodeCache())
->get('OpcodeCache', $app['phraseanet.configuration']->getOpcodeCache()) ->getDriver();
->getDriver(); });
});
} }
public function boot(Application $app) public function boot(Application $app)
{ {
} }
} }

View File

@@ -22,7 +22,6 @@ class ConfigurationServiceProvider implements ServiceProviderInterface
public function register(SilexApplication $app) public function register(SilexApplication $app)
{ {
$app['phraseanet.configuration'] = $app->share(function(Application $app) { $app['phraseanet.configuration'] = $app->share(function(Application $app) {
return Configuration::build(null, $app->getEnvironment()); return Configuration::build(null, $app->getEnvironment());
}); });
} }

View File

@@ -21,17 +21,15 @@ class ORMServiceProvider implements ServiceProviderInterface
public function register(Application $app) public function register(Application $app)
{ {
$app['EM'] = $app->share(function(Application $app) { $app['EM'] = $app->share(function(Application $app) {
return Builder::create(
return Builder::create( $app, $app['phraseanet.configuration']
$app, $app['phraseanet.configuration'] ->getService($app['phraseanet.configuration']
->getService($app['phraseanet.configuration'] ->getOrm())
->getOrm()) )->getDriver();
)->getDriver(); });
});
} }
public function boot(Application $app) public function boot(Application $app)
{ {
} }
} }