-
Notifications
You must be signed in to change notification settings - Fork 380
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix service definitions for mime and extension guessers #1379
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the `liip/LiipImagineBundle` project. | ||
* | ||
* (c) /~https://github.com/liip/LiipImagineBundle/graphs/contributors | ||
* | ||
* For the full copyright and license information, please view the LICENSE.md | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Liip\ImagineBundle\DependencyInjection\Compiler; | ||
|
||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Definition; | ||
|
||
/** | ||
* Changes the `liip_imagine.mime_type_guesser` and `liip_imagine.extension_guesser` services to be aliases of the | ||
* `mime_types` service provided by the FrameworkBundle when available. | ||
* | ||
* This compiler pass can be removed when dropping support for Symfony 4.2 and earlier. | ||
* | ||
* @internal | ||
*/ | ||
final class MaybeSetMimeServicesAsAliasesCompilerPass extends AbstractCompilerPass | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function process(ContainerBuilder $container): void | ||
{ | ||
if ($container->hasDefinition('mime_types')) { | ||
$container->removeDefinition('liip_imagine.mime_type_guesser'); | ||
$container->removeDefinition('liip_imagine.extension_guesser'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could this be a BC break if people customized one of these services? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, but as is these definitions already are invalid when
IMO, I'd say this PR is the "best" option moving forward. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks for the clarification. yeah, lets do it this way. i will add a note in UPGRADE.md |
||
|
||
$container->setAlias('liip_imagine.mime_type_guesser', 'mime_types'); | ||
$container->setAlias('liip_imagine.extension_guesser', 'mime_types'); | ||
|
||
$message = 'Replaced the "%s" and "%s" service definitions with aliases to "%s"'; | ||
|
||
$this->log($container, $message, 'liip_imagine.mime_type_guesser', 'liip_imagine.extension_guesser', 'mime_types'); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Purposefully final and internal to make it clear this is a B/C layer that can (and should) go away when older Symfony version support is dropped.