Fix latest merge

This commit is contained in:
Romain Neutron
2014-02-14 11:59:15 +01:00
parent 903f63cd32
commit 787e86aacf
3 changed files with 11 additions and 11 deletions

View File

@@ -12,6 +12,7 @@
namespace Alchemy\Phrasea\Border; namespace Alchemy\Phrasea\Border;
use Alchemy\Phrasea\Core\Configuration\Configuration; use Alchemy\Phrasea\Core\Configuration\Configuration;
use Alchemy\Phrasea\Core\Configuration\PropertyAccess;
use MediaVorus\Utils\AudioMimeTypeGuesser; use MediaVorus\Utils\AudioMimeTypeGuesser;
use MediaVorus\Utils\PostScriptMimeTypeGuesser; use MediaVorus\Utils\PostScriptMimeTypeGuesser;
use MediaVorus\Utils\RawImageMimeTypeGuesser; use MediaVorus\Utils\RawImageMimeTypeGuesser;
@@ -21,11 +22,14 @@ use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser;
class MimeGuesserConfiguration class MimeGuesserConfiguration
{ {
/** @var PropertyAccess */
private $conf; private $conf;
private $store;
public function __construct(Configuration $conf) public function __construct(PropertyAccess $conf, Configuration $store)
{ {
$this->conf = $conf; $this->conf = $conf;
$this->store = $store;
} }
/** /**
@@ -41,12 +45,8 @@ class MimeGuesserConfiguration
$guesser->register(new AudioMimeTypeGuesser()); $guesser->register(new AudioMimeTypeGuesser());
$guesser->register(new VideoMimeTypeGuesser()); $guesser->register(new VideoMimeTypeGuesser());
if ($this->conf->isSetup()) { if ($this->store->isSetup()) {
$conf = $this->conf->getConfig(); $guesser->register(new CustomExtensionGuesser($this->conf->get(['border-manager', 'extension-mapping'], [])));
if (isset($conf['border-manager']['extension-mapping']) && is_array($conf['border-manager']['extension-mapping'])) {
$guesser->register(new CustomExtensionGuesser($conf['border-manager']['extension-mapping']));
}
} }
} }
} }

View File

@@ -100,7 +100,7 @@ class BorderManagerServiceProvider implements ServiceProviderInterface
}); });
$app['border-manager.mime-guesser-configuration'] = $app->share(function (Application $app) { $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']);
}); });
} }

View File

@@ -4,13 +4,13 @@ namespace Alchemy\Tests\Phrasea\Border;
use Alchemy\Phrasea\Border\CustomExtensionGuesser; use Alchemy\Phrasea\Border\CustomExtensionGuesser;
class CustomExtensionGuesserTest extends \PhraseanetPHPUnitAbstract class CustomExtensionGuesserTest extends \PhraseanetTestCase
{ {
public function testGuess() public function testGuess()
{ {
$conf = array( $conf = [
'mpeg' => 'video/x-romain-neutron', 'mpeg' => 'video/x-romain-neutron',
); ];
$guesser = new CustomExtensionGuesser($conf); $guesser = new CustomExtensionGuesser($conf);
$this->assertNull($guesser->guess(__FILE__)); $this->assertNull($guesser->guess(__FILE__));