From 787e86aacff5a80887d27d900d52456ba7955404 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Fri, 14 Feb 2014 11:59:15 +0100 Subject: [PATCH] Fix latest merge --- .../Phrasea/Border/MimeGuesserConfiguration.php | 14 +++++++------- .../Core/Provider/BorderManagerServiceProvider.php | 2 +- .../Phrasea/Border/CustomExtensionGuesserTest.php | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/Alchemy/Phrasea/Border/MimeGuesserConfiguration.php b/lib/Alchemy/Phrasea/Border/MimeGuesserConfiguration.php index 6129d281cc..d6706a20b4 100644 --- a/lib/Alchemy/Phrasea/Border/MimeGuesserConfiguration.php +++ b/lib/Alchemy/Phrasea/Border/MimeGuesserConfiguration.php @@ -12,6 +12,7 @@ namespace Alchemy\Phrasea\Border; use Alchemy\Phrasea\Core\Configuration\Configuration; +use Alchemy\Phrasea\Core\Configuration\PropertyAccess; use MediaVorus\Utils\AudioMimeTypeGuesser; use MediaVorus\Utils\PostScriptMimeTypeGuesser; use MediaVorus\Utils\RawImageMimeTypeGuesser; @@ -21,11 +22,14 @@ use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser; class MimeGuesserConfiguration { + /** @var PropertyAccess */ private $conf; + private $store; - public function __construct(Configuration $conf) + public function __construct(PropertyAccess $conf, Configuration $store) { $this->conf = $conf; + $this->store = $store; } /** @@ -41,12 +45,8 @@ class MimeGuesserConfiguration $guesser->register(new AudioMimeTypeGuesser()); $guesser->register(new VideoMimeTypeGuesser()); - if ($this->conf->isSetup()) { - $conf = $this->conf->getConfig(); - - if (isset($conf['border-manager']['extension-mapping']) && is_array($conf['border-manager']['extension-mapping'])) { - $guesser->register(new CustomExtensionGuesser($conf['border-manager']['extension-mapping'])); - } + if ($this->store->isSetup()) { + $guesser->register(new CustomExtensionGuesser($this->conf->get(['border-manager', 'extension-mapping'], []))); } } } diff --git a/lib/Alchemy/Phrasea/Core/Provider/BorderManagerServiceProvider.php b/lib/Alchemy/Phrasea/Core/Provider/BorderManagerServiceProvider.php index b03507ae19..20e5fa11d0 100644 --- a/lib/Alchemy/Phrasea/Core/Provider/BorderManagerServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/Provider/BorderManagerServiceProvider.php @@ -100,7 +100,7 @@ class BorderManagerServiceProvider implements ServiceProviderInterface }); $app['border-manager.mime-guesser-configuration'] = $app->share(function (Application $app) { - return new MimeGuesserConfiguration($app['phraseanet.configuration']); + return new MimeGuesserConfiguration($app['conf'], $app['configuration.store']); }); } diff --git a/tests/Alchemy/Tests/Phrasea/Border/CustomExtensionGuesserTest.php b/tests/Alchemy/Tests/Phrasea/Border/CustomExtensionGuesserTest.php index 296d6bfaa6..a9632f5d5c 100644 --- a/tests/Alchemy/Tests/Phrasea/Border/CustomExtensionGuesserTest.php +++ b/tests/Alchemy/Tests/Phrasea/Border/CustomExtensionGuesserTest.php @@ -4,13 +4,13 @@ namespace Alchemy\Tests\Phrasea\Border; use Alchemy\Phrasea\Border\CustomExtensionGuesser; -class CustomExtensionGuesserTest extends \PhraseanetPHPUnitAbstract +class CustomExtensionGuesserTest extends \PhraseanetTestCase { public function testGuess() { - $conf = array( + $conf = [ 'mpeg' => 'video/x-romain-neutron', - ); + ]; $guesser = new CustomExtensionGuesser($conf); $this->assertNull($guesser->guess(__FILE__));