Files
Phraseanet/lib/Alchemy/Phrasea/Core/Provider/SearchEngineServiceProvider.php
Romain Neutron 420df7febd Merge branch '3.8'
Conflicts:
	lib/Alchemy/Phrasea/Command/CreateCollection.php
	lib/Alchemy/Phrasea/Controller/Admin/Databox.php
	lib/Alchemy/Phrasea/Controller/Root/Login.php
	lib/Alchemy/Phrasea/Core/Provider/SearchEngineServiceProvider.php
	lib/Alchemy/Phrasea/Model/Entities/AuthFailure.php
	lib/Alchemy/Phrasea/Model/Entities/LazaretAttribute.php
	lib/Alchemy/Phrasea/Model/Entities/LazaretCheck.php
	lib/Alchemy/Phrasea/Model/Entities/SessionModule.php
	lib/Alchemy/Phrasea/Model/Entities/ValidationData.php
	lib/Alchemy/Phrasea/Model/Repositories/BasketRepository.php
	lib/conf.d/Doctrine/Entities.Session.dcm.yml
	lib/conf.d/Doctrine/Entities.StoryWZ.dcm.yml
	lib/conf.d/Doctrine/Entities.UsrList.dcm.yml
	lib/conf.d/Doctrine/Entities.UsrListEntry.dcm.yml
	lib/conf.d/Doctrine/Entities.UsrListOwner.dcm.yml
	lib/conf.d/Doctrine/Entities.ValidationSession.dcm.yml
	lib/conf.d/PhraseaFixture/Basket/LoadFiveBaskets.php
	tests/Alchemy/Tests/Phrasea/SearchEngine/SphinxSearchEngineTest.php
2013-12-03 21:19:20 +01:00

61 lines
1.9 KiB
PHP

<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2013 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Core\Provider;
use Alchemy\Phrasea\SearchEngine\SearchEngineLogger;
use Alchemy\Phrasea\Exception\InvalidArgumentException;
use Alchemy\Phrasea\SearchEngine\SearchEngineInterface;
use Silex\Application;
use Silex\ServiceProviderInterface;
class SearchEngineServiceProvider implements ServiceProviderInterface
{
public function register(Application $app)
{
$app['phraseanet.SE'] = $app->share(function ($app) {
$engineOptions = $app['conf']->get(['main', 'search-engine', 'options']);
return $app['phraseanet.SE.engine-class']::create($app, $engineOptions);
});
$app['phraseanet.SE.logger'] = $app->share(function (Application $app) {
return new SearchEngineLogger($app);
});
$app['phraseanet.SE.engine-class'] = $app->share(function ($app) {
$engineClass = $app['conf']->get(['main', 'search-engine', 'type']);
if (!class_exists($engineClass) || $engineClass instanceof SearchEngineInterface) {
throw new InvalidArgumentException(sprintf('%s is not valid SearchEngineInterface', $engineClass));
}
return $engineClass;
});
$app['phraseanet.SE.subscriber'] = $app->share(function ($app) {
return $app['phraseanet.SE.engine-class']::createSubscriber($app);
});
}
public function boot(Application $app)
{
$app['dispatcher'] = $app->share(
$app->extend('dispatcher', function ($dispatcher, Application $app) {
$dispatcher->addSubscriber($app['phraseanet.SE.subscriber']);
return $dispatcher;
})
);
}
}