update
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\MonologBundle\DependencyInjection\Compiler;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ChildDefinition;
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
|
||||
/**
|
||||
* Registers processors in Monolog loggers or handlers.
|
||||
*
|
||||
* @author Christophe Coevoet <stof@notk.org>
|
||||
*
|
||||
* @internalsince 3.9.0
|
||||
*/
|
||||
class AddProcessorsPass implements CompilerPassInterface
|
||||
{
|
||||
public function process(ContainerBuilder $container)
|
||||
{
|
||||
if (!$container->hasDefinition('monolog.logger')) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($container->findTaggedServiceIds('monolog.processor') as $id => $tags) {
|
||||
foreach ($tags as $tag) {
|
||||
if (!empty($tag['channel']) && !empty($tag['handler'])) {
|
||||
throw new \InvalidArgumentException(sprintf('you cannot specify both the "handler" and "channel" attributes for the "monolog.processor" tag on service "%s"', $id));
|
||||
}
|
||||
|
||||
if (!empty($tag['handler'])) {
|
||||
$definition = $container->findDefinition(sprintf('monolog.handler.%s', $tag['handler']));
|
||||
$parentDef = $definition;
|
||||
while (!$parentDef->getClass() && $parentDef instanceof ChildDefinition) {
|
||||
$parentDef = $container->findDefinition($parentDef->getParent());
|
||||
}
|
||||
$class = $container->getParameterBag()->resolveValue($parentDef->getClass());
|
||||
if (!method_exists($class, 'pushProcessor')) {
|
||||
throw new \InvalidArgumentException(sprintf('The "%s" handler does not accept processors', $tag['handler']));
|
||||
}
|
||||
} elseif (!empty($tag['channel'])) {
|
||||
if ('app' === $tag['channel']) {
|
||||
$definition = $container->getDefinition('monolog.logger');
|
||||
} else {
|
||||
$definition = $container->getDefinition(sprintf('monolog.logger.%s', $tag['channel']));
|
||||
}
|
||||
} else {
|
||||
$definition = $container->getDefinition('monolog.logger_prototype');
|
||||
}
|
||||
|
||||
if (!empty($tag['method'])) {
|
||||
$processor = [new Reference($id), $tag['method']];
|
||||
} else {
|
||||
// If no method is defined, fallback to use __invoke
|
||||
$processor = new Reference($id);
|
||||
}
|
||||
$definition->addMethodCall('pushProcessor', [$processor]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\MonologBundle\DependencyInjection\Compiler;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
|
||||
/**
|
||||
* Sets the transport for Swiftmailer handlers depending on the existing
|
||||
* container definitions.
|
||||
*
|
||||
* @author Christian Flothmann <christian.flothmann@xabbuh.de>
|
||||
*
|
||||
* @internalsince 3.9.0
|
||||
*/
|
||||
class AddSwiftMailerTransportPass implements CompilerPassInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function process(ContainerBuilder $container)
|
||||
{
|
||||
$handlers = $container->getParameter('monolog.swift_mailer.handlers');
|
||||
|
||||
foreach ($handlers as $id) {
|
||||
$definition = $container->getDefinition($id);
|
||||
$mailerId = (string) $definition->getArgument(0);
|
||||
|
||||
// Try to fetch the transport for a non-default mailer first, then go with the default swiftmailer
|
||||
$possibleServices = [
|
||||
$mailerId.'.transport.real',
|
||||
$mailerId.'.transport',
|
||||
'swiftmailer.transport.real',
|
||||
'swiftmailer.transport',
|
||||
];
|
||||
|
||||
foreach ($possibleServices as $serviceId) {
|
||||
if ($container->hasAlias($serviceId) || $container->hasDefinition($serviceId)) {
|
||||
$definition->addMethodCall(
|
||||
'setTransport',
|
||||
[new Reference($serviceId)]
|
||||
);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\MonologBundle\DependencyInjection\Compiler;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Monolog\Logger;
|
||||
|
||||
/**
|
||||
* Adds the DebugHandler when the profiler is enabled and kernel.debug is true.
|
||||
*
|
||||
* @author Christophe Coevoet <stof@notk.org>
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* @deprecated since version 2.12, to be removed in 4.0. Use AddDebugLogProcessorPass in FrameworkBundle instead.
|
||||
*/
|
||||
class DebugHandlerPass implements CompilerPassInterface
|
||||
{
|
||||
private $channelPass;
|
||||
|
||||
public function __construct(LoggerChannelPass $channelPass)
|
||||
{
|
||||
@trigger_error('The '.__CLASS__.' class is deprecated since version 2.12 and will be removed in 4.0. Use AddDebugLogProcessorPass in FrameworkBundle instead.', E_USER_DEPRECATED);
|
||||
|
||||
$this->channelPass = $channelPass;
|
||||
}
|
||||
|
||||
public function process(ContainerBuilder $container)
|
||||
{
|
||||
if (!$container->hasDefinition('profiler')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$container->getParameter('kernel.debug')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$debugHandler = new Definition('Symfony\Bridge\Monolog\Handler\DebugHandler', [Logger::DEBUG, true]);
|
||||
$container->setDefinition('monolog.handler.debug', $debugHandler);
|
||||
|
||||
foreach ($this->channelPass->getChannels() as $channel) {
|
||||
$container
|
||||
->getDefinition($channel === 'app' ? 'monolog.logger' : 'monolog.logger.'.$channel)
|
||||
->addMethodCall('pushHandler', [new Reference('monolog.handler.debug')]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\MonologBundle\DependencyInjection\Compiler;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
|
||||
/**
|
||||
* Fixes loggers with no handlers (by registering a "null" one).
|
||||
*
|
||||
* Monolog 1.x adds a default handler logging on STDERR when a logger has
|
||||
* no registered handlers. This is NOT what what we want in Symfony, so in such
|
||||
* cases, we add a "null" handler to avoid the issue.
|
||||
*
|
||||
* Note that Monolog 2.x does not register a default handler anymore, so this pass can
|
||||
* be removed when MonologBundle minimum version of Monolog is bumped to 2.0.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @see https://github.com/Seldaek/monolog/commit/ad37b7b2d11f300cbace9f5e84f855d329519e28
|
||||
*
|
||||
* @internalsince 3.9.0
|
||||
*/
|
||||
class FixEmptyLoggerPass implements CompilerPassInterface
|
||||
{
|
||||
private $channelPass;
|
||||
|
||||
public function __construct(LoggerChannelPass $channelPass)
|
||||
{
|
||||
$this->channelPass = $channelPass;
|
||||
}
|
||||
|
||||
public function process(ContainerBuilder $container)
|
||||
{
|
||||
$container->register('monolog.handler.null_internal', 'Monolog\Handler\NullHandler');
|
||||
foreach ($this->channelPass->getChannels() as $channel) {
|
||||
$def = $container->getDefinition($channel === 'app' ? 'monolog.logger' : 'monolog.logger.'.$channel);
|
||||
foreach ($def->getMethodCalls() as $method) {
|
||||
if ('pushHandler' === $method[0]) {
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
|
||||
$def->addMethodCall('pushHandler', [new Reference('monolog.handler.null_internal')]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\MonologBundle\DependencyInjection\Compiler;
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\DependencyInjection\Argument\BoundArgument;
|
||||
use Symfony\Component\DependencyInjection\ChildDefinition;
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
|
||||
/**
|
||||
* Replaces the default logger by another one with its own channel for tagged services.
|
||||
*
|
||||
* @author Christophe Coevoet <stof@notk.org>
|
||||
*
|
||||
* @internalsince 3.9.0
|
||||
*/
|
||||
class LoggerChannelPass implements CompilerPassInterface
|
||||
{
|
||||
protected $channels = ['app'];
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function process(ContainerBuilder $container)
|
||||
{
|
||||
if (!$container->hasDefinition('monolog.logger')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// create channels necessary for the handlers
|
||||
foreach ($container->findTaggedServiceIds('monolog.logger') as $id => $tags) {
|
||||
foreach ($tags as $tag) {
|
||||
if (empty($tag['channel']) || 'app' === $tag['channel']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$resolvedChannel = $container->getParameterBag()->resolveValue($tag['channel']);
|
||||
|
||||
$definition = $container->getDefinition($id);
|
||||
$loggerId = sprintf('monolog.logger.%s', $resolvedChannel);
|
||||
$this->createLogger($resolvedChannel, $loggerId, $container);
|
||||
|
||||
foreach ($definition->getArguments() as $index => $argument) {
|
||||
if ($argument instanceof Reference && 'logger' === (string) $argument) {
|
||||
$definition->replaceArgument($index, $this->changeReference($argument, $loggerId));
|
||||
}
|
||||
}
|
||||
|
||||
$calls = $definition->getMethodCalls();
|
||||
foreach ($calls as $i => $call) {
|
||||
foreach ($call[1] as $index => $argument) {
|
||||
if ($argument instanceof Reference && 'logger' === (string) $argument) {
|
||||
$calls[$i][1][$index] = $this->changeReference($argument, $loggerId);
|
||||
}
|
||||
}
|
||||
}
|
||||
$definition->setMethodCalls($calls);
|
||||
|
||||
$binding = new BoundArgument(new Reference($loggerId));
|
||||
|
||||
// Mark the binding as used already, to avoid reporting it as unused if the service does not use a
|
||||
// logger injected through the LoggerInterface alias.
|
||||
$values = $binding->getValues();
|
||||
$values[2] = true;
|
||||
$binding->setValues($values);
|
||||
|
||||
$bindings = $definition->getBindings();
|
||||
$bindings['Psr\Log\LoggerInterface'] = $binding;
|
||||
$definition->setBindings($bindings);
|
||||
}
|
||||
}
|
||||
|
||||
// create additional channels
|
||||
foreach ($container->getParameter('monolog.additional_channels') as $chan) {
|
||||
if ($chan === 'app') {
|
||||
continue;
|
||||
}
|
||||
$loggerId = sprintf('monolog.logger.%s', $chan);
|
||||
$this->createLogger($chan, $loggerId, $container);
|
||||
$container->getDefinition($loggerId)->setPublic(true);
|
||||
}
|
||||
$container->getParameterBag()->remove('monolog.additional_channels');
|
||||
|
||||
// wire handlers to channels
|
||||
$handlersToChannels = $container->getParameter('monolog.handlers_to_channels');
|
||||
foreach ($handlersToChannels as $handler => $channels) {
|
||||
foreach ($this->processChannels($channels) as $channel) {
|
||||
try {
|
||||
$logger = $container->getDefinition($channel === 'app' ? 'monolog.logger' : 'monolog.logger.'.$channel);
|
||||
} catch (InvalidArgumentException $e) {
|
||||
$msg = 'Monolog configuration error: The logging channel "'.$channel.'" assigned to the "'.substr($handler, 16).'" handler does not exist.';
|
||||
throw new \InvalidArgumentException($msg, 0, $e);
|
||||
}
|
||||
$logger->addMethodCall('pushHandler', [new Reference($handler)]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getChannels()
|
||||
{
|
||||
return $this->channels;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function processChannels(?array $configuration)
|
||||
{
|
||||
if (null === $configuration) {
|
||||
return $this->channels;
|
||||
}
|
||||
|
||||
if ('inclusive' === $configuration['type']) {
|
||||
return $configuration['elements'] ?: $this->channels;
|
||||
}
|
||||
|
||||
return array_diff($this->channels, $configuration['elements']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new logger from the monolog.logger_prototype
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function createLogger(string $channel, string $loggerId, ContainerBuilder $container)
|
||||
{
|
||||
if (!in_array($channel, $this->channels)) {
|
||||
$logger = new ChildDefinition('monolog.logger_prototype');
|
||||
$logger->replaceArgument(0, $channel);
|
||||
$container->setDefinition($loggerId, $logger);
|
||||
$this->channels[] = $channel;
|
||||
}
|
||||
|
||||
$parameterName = $channel . 'Logger';
|
||||
|
||||
$container->registerAliasForArgument($loggerId, LoggerInterface::class, $parameterName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a copy of a reference and alters the service ID.
|
||||
*/
|
||||
private function changeReference(Reference $reference, string $serviceId): Reference
|
||||
{
|
||||
return new Reference($serviceId, $reference->getInvalidBehavior());
|
||||
}
|
||||
}
|
||||
1145
projects/priceservice/vendor/symfony/monolog-bundle/DependencyInjection/Configuration.php
vendored
Normal file
1145
projects/priceservice/vendor/symfony/monolog-bundle/DependencyInjection/Configuration.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1090
projects/priceservice/vendor/symfony/monolog-bundle/DependencyInjection/MonologExtension.php
vendored
Normal file
1090
projects/priceservice/vendor/symfony/monolog-bundle/DependencyInjection/MonologExtension.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user