[MonologBridge] Add ProcessorInterface, enabling autoconfiguration of monolog processors

This commit is contained in:
Nicolas Grekas 2018-07-02 11:46:48 +02:00
parent 9efa555191
commit 28a4912f21
5 changed files with 35 additions and 2 deletions

View File

@ -1,6 +1,11 @@
CHANGELOG
=========
4.2.0
-----
* added `ProcessorInterface`: an optional interface to allow autoconfiguration of Monolog processors
4.1.0
-----

View File

@ -0,0 +1,25 @@
<?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\Bridge\Monolog\Processor;
/**
* An optional interface to allow autoconfiguration of Monolog processors.
*
* @author Nicolas Grekas <p@tchwork.com>
*/
interface ProcessorInterface
{
/**
* @return array The processed records
*/
public function __invoke(array $records);
}

View File

@ -18,7 +18,7 @@ use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInt
*
* @author Dany Maillard <danymaillard93b@gmail.com>
*/
class TokenProcessor
class TokenProcessor implements ProcessorInterface
{
private $tokenStorage;

View File

@ -21,7 +21,7 @@ use Symfony\Component\HttpKernel\KernelEvents;
*
* @author Jordi Boggiano <j.boggiano@seld.be>
*/
class WebProcessor extends BaseWebProcessor implements EventSubscriberInterface
class WebProcessor extends BaseWebProcessor implements EventSubscriberInterface, ProcessorInterface
{
public function __construct(array $extraFields = null)
{

View File

@ -14,6 +14,7 @@ namespace Symfony\Bundle\FrameworkBundle\DependencyInjection;
use Doctrine\Common\Annotations\Reader;
use Doctrine\Common\Annotations\AnnotationRegistry;
use Symfony\Bridge\Monolog\Processor\DebugProcessor;
use Symfony\Bridge\Monolog\Processor\ProcessorInterface;
use Symfony\Bridge\Twig\Extension\CsrfExtension;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
@ -324,6 +325,8 @@ class FrameworkExtension extends Extension
->addTag('kernel.event_subscriber');
$container->registerForAutoconfiguration(ResettableInterface::class)
->addTag('kernel.reset', array('method' => 'reset'));
$container->registerForAutoconfiguration(ProcessorInterface::class)
->addTag('monolog.processor');
$container->registerForAutoconfiguration(PropertyListExtractorInterface::class)
->addTag('property_info.list_extractor');
$container->registerForAutoconfiguration(PropertyTypeExtractorInterface::class)