mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-10 11:33:17 +00:00

- Squashed Pull request #1730 - Squashed Pull request #1741 - Squashed Pull request #1742 - Squash merge branch 4.0 - Squashed Pull request #1744 - Squashed Pull request #1746 - Squashed merge branch 4.0 - Squashed merge branch 4.0 - Squashed merge branch 4.0 - Squashed merge branch 4.0 - Squashed Pull request #1758 - Avoid using imagine/imagine alias as it is causing install issues - Squashed merge branch 4.0 - Squashed Pull request #1763 - Squashed merge branch 4.0 - Squash of 6 commits - Squashed merge branch 4.0 - This is a combination of 2 commits. - Squashed Pull request #1775 - Squashed Pull request #1777 - Squashed Pull request #1779 - Squashed Pull request #1780 - Squashed Pull request #1782 - Adds a Pull request template - Squased Pull request #1783 - Squash Pull request #1786 - Squashed Pull request #1796 - Squashed merge branch 4.0 - Squash Pull request #1791 - Squashed merge branch 4.0 - Squashed Pull request #1808 - Squashed Pull request #1811 - Squashed Pull request #1809
66 lines
2.1 KiB
PHP
66 lines
2.1 KiB
PHP
<?php
|
|
/*
|
|
* This file is part of Phraseanet
|
|
*
|
|
* (c) 2005-2016 Alchemy
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
namespace Alchemy\Phrasea\ControllerProvider;
|
|
|
|
use Alchemy\Phrasea\Controller\MediaAccessorController;
|
|
use Alchemy\Phrasea\Media\MediaSubDefinitionUrlGenerator;
|
|
use Alchemy\Phrasea\Model\Entities\Secret;
|
|
use Alchemy\Phrasea\Model\Provider\DefaultSecretProvider;
|
|
use Doctrine\ORM\EntityManagerInterface;
|
|
use Silex\Application;
|
|
use Silex\ControllerProviderInterface;
|
|
use Silex\ServiceProviderInterface;
|
|
|
|
class MediaAccessor implements ServiceProviderInterface, ControllerProviderInterface
|
|
{
|
|
use ControllerProviderTrait;
|
|
|
|
public function register(Application $app)
|
|
{
|
|
$app['repo.secrets'] = $app->share(function (Application $app) {
|
|
/** @var EntityManagerInterface $manager */
|
|
$manager = $app['orm.em'];
|
|
return $manager->getRepository(Secret::class);
|
|
});
|
|
|
|
$app['provider.secrets'] = $app->share(function (Application $app) {
|
|
return new DefaultSecretProvider($app['repo.secrets'], $app['random.medium']);
|
|
});
|
|
|
|
$app['media_accessor.subdef_url_generator'] = $app->share(function (Application $app) {
|
|
$defaultTTL = (int)$app['conf']->get(['registry', 'general', 'default-subdef-url-ttl'], 0);
|
|
|
|
return new MediaSubDefinitionUrlGenerator($app['url_generator'], $app['provider.secrets'], $defaultTTL);
|
|
});
|
|
|
|
|
|
$app['controller.media_accessor'] = $app->share(function (Application $app) {
|
|
return (new MediaAccessorController($app))
|
|
->setAllowedAlgorithms(['HS256'])
|
|
->setKeyStorage($app['provider.secrets']);
|
|
});
|
|
|
|
$app['controller.media_accessor.route_prefix'] = '/medias';
|
|
}
|
|
|
|
public function boot(Application $app)
|
|
{
|
|
}
|
|
|
|
public function connect(Application $app)
|
|
{
|
|
$controllers = $this->createCollection($app);
|
|
$controllers->get('/{token}', 'controller.media_accessor:showAction')
|
|
->bind('media_accessor');
|
|
|
|
return $controllers;
|
|
}
|
|
}
|