move add mime type guesser pass to the component
This commit is contained in:
parent
1aa652e2cb
commit
ba20bb2e7e
@ -14,7 +14,6 @@ namespace Symfony\Bundle\FrameworkBundle;
|
|||||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddAnnotationsCachedReaderPass;
|
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddAnnotationsCachedReaderPass;
|
||||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddDebugLogProcessorPass;
|
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddDebugLogProcessorPass;
|
||||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddExpressionLanguageProvidersPass;
|
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddExpressionLanguageProvidersPass;
|
||||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddMimeTypeGuesserPass;
|
|
||||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ContainerBuilderDebugDumpPass;
|
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ContainerBuilderDebugDumpPass;
|
||||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\DataCollectorTranslatorPass;
|
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\DataCollectorTranslatorPass;
|
||||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\LoggingTranslatorPass;
|
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\LoggingTranslatorPass;
|
||||||
@ -45,6 +44,7 @@ use Symfony\Component\HttpKernel\DependencyInjection\RemoveEmptyControllerArgume
|
|||||||
use Symfony\Component\HttpKernel\DependencyInjection\ResettableServicePass;
|
use Symfony\Component\HttpKernel\DependencyInjection\ResettableServicePass;
|
||||||
use Symfony\Component\HttpKernel\KernelEvents;
|
use Symfony\Component\HttpKernel\KernelEvents;
|
||||||
use Symfony\Component\Messenger\DependencyInjection\MessengerPass;
|
use Symfony\Component\Messenger\DependencyInjection\MessengerPass;
|
||||||
|
use Symfony\Component\Mime\DependencyInjection\AddMimeTypeGuesserPass;
|
||||||
use Symfony\Component\PropertyInfo\DependencyInjection\PropertyInfoPass;
|
use Symfony\Component\PropertyInfo\DependencyInjection\PropertyInfoPass;
|
||||||
use Symfony\Component\Routing\DependencyInjection\RoutingResolverPass;
|
use Symfony\Component\Routing\DependencyInjection\RoutingResolverPass;
|
||||||
use Symfony\Component\Serializer\DependencyInjection\SerializerPass;
|
use Symfony\Component\Serializer\DependencyInjection\SerializerPass;
|
||||||
@ -124,7 +124,7 @@ class FrameworkBundle extends Bundle
|
|||||||
$container->addCompilerPass(new ResettableServicePass());
|
$container->addCompilerPass(new ResettableServicePass());
|
||||||
$container->addCompilerPass(new TestServiceContainerWeakRefPass(), PassConfig::TYPE_BEFORE_REMOVING, -32);
|
$container->addCompilerPass(new TestServiceContainerWeakRefPass(), PassConfig::TYPE_BEFORE_REMOVING, -32);
|
||||||
$container->addCompilerPass(new TestServiceContainerRealRefPass(), PassConfig::TYPE_AFTER_REMOVING);
|
$container->addCompilerPass(new TestServiceContainerRealRefPass(), PassConfig::TYPE_AFTER_REMOVING);
|
||||||
$container->addCompilerPass(new AddMimeTypeGuesserPass());
|
$this->addCompilerPassIfExists($container, AddMimeTypeGuesserPass::class);
|
||||||
$this->addCompilerPassIfExists($container, MessengerPass::class);
|
$this->addCompilerPassIfExists($container, MessengerPass::class);
|
||||||
|
|
||||||
if ($container->getParameter('kernel.debug')) {
|
if ($container->getParameter('kernel.debug')) {
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
|
namespace Symfony\Component\Mime\DependencyInjection;
|
||||||
|
|
||||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
@ -22,14 +22,23 @@ use Symfony\Component\DependencyInjection\Reference;
|
|||||||
*/
|
*/
|
||||||
class AddMimeTypeGuesserPass implements CompilerPassInterface
|
class AddMimeTypeGuesserPass implements CompilerPassInterface
|
||||||
{
|
{
|
||||||
|
private $mimeTypesService;
|
||||||
|
private $mimeTypeGuesserTag;
|
||||||
|
|
||||||
|
public function __construct(string $mimeTypesService = 'mime_types', string $mimeTypeGuesserTag = 'mime.mime_type_guesser')
|
||||||
|
{
|
||||||
|
$this->mimeTypesService = $mimeTypesService;
|
||||||
|
$this->mimeTypeGuesserTag = $mimeTypeGuesserTag;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function process(ContainerBuilder $container)
|
public function process(ContainerBuilder $container)
|
||||||
{
|
{
|
||||||
if ($container->has('mime_types')) {
|
if ($container->has($this->mimeTypesService)) {
|
||||||
$definition = $container->findDefinition('mime_types');
|
$definition = $container->findDefinition($this->mimeTypesService);
|
||||||
foreach ($container->findTaggedServiceIds('mime.mime_type_guesser', true) as $id => $attributes) {
|
foreach ($container->findTaggedServiceIds($this->mimeTypeGuesserTag, true) as $id => $attributes) {
|
||||||
$definition->addMethodCall('registerGuesser', [new Reference($id)]);
|
$definition->addMethodCall('registerGuesser', [new Reference($id)]);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,13 +9,13 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler;
|
namespace Symfony\Component\Mime\Tests\DependencyInjection;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddMimeTypeGuesserPass;
|
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
use Symfony\Component\DependencyInjection\Definition;
|
use Symfony\Component\DependencyInjection\Definition;
|
||||||
use Symfony\Component\DependencyInjection\Reference;
|
use Symfony\Component\DependencyInjection\Reference;
|
||||||
|
use Symfony\Component\Mime\DependencyInjection\AddMimeTypeGuesserPass;
|
||||||
use Symfony\Component\Mime\FileinfoMimeTypeGuesser;
|
use Symfony\Component\Mime\FileinfoMimeTypeGuesser;
|
||||||
use Symfony\Component\Mime\MimeTypes;
|
use Symfony\Component\Mime\MimeTypes;
|
||||||
|
|
@ -18,6 +18,9 @@
|
|||||||
"require": {
|
"require": {
|
||||||
"php": "^7.1.3"
|
"php": "^7.1.3"
|
||||||
},
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"symfony/dependency-injection": "~3.4|^4.1"
|
||||||
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": { "Symfony\\Component\\Mime\\": "" },
|
"psr-4": { "Symfony\\Component\\Mime\\": "" },
|
||||||
"exclude-from-classmap": [
|
"exclude-from-classmap": [
|
||||||
|
Reference in New Issue
Block a user