Deleted useless ControllerListener
This commit is contained in:
parent
b4a293940a
commit
265826f6c6
|
@ -1,64 +0,0 @@
|
||||||
<?php
|
|
||||||
/*
|
|
||||||
* This file is part of the WebServiceBundle.
|
|
||||||
*
|
|
||||||
* (c) Christian Kerl <christian-kerl@web.de>
|
|
||||||
*
|
|
||||||
* This source file is subject to the MIT license that is bundled
|
|
||||||
* with this source code in the file LICENSE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Bundle\WebServiceBundle\EventListener;
|
|
||||||
|
|
||||||
use Bundle\WebServiceBundle\ServiceDefinition\Annotation\ConfigurationInterface;
|
|
||||||
|
|
||||||
use Doctrine\Common\Annotations\Reader;
|
|
||||||
|
|
||||||
use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Based on \Sensio\Bundle\FrameworkExtraBundle\EventListener\ControllerListener
|
|
||||||
*
|
|
||||||
* @author Francis Besset <francis.besset@gmail.com>
|
|
||||||
*/
|
|
||||||
class ControllerListener
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var \Doctrine\Common\Annotations\Reader
|
|
||||||
*/
|
|
||||||
protected $reader;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor.
|
|
||||||
*
|
|
||||||
* @param Reader $reader An Reader instance
|
|
||||||
*/
|
|
||||||
public function __construct(Reader $reader)
|
|
||||||
{
|
|
||||||
$this->reader = $reader;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Modifies the Request object to apply configuration information found in
|
|
||||||
* controllers annotations like the template to render or HTTP caching
|
|
||||||
* configuration.
|
|
||||||
*
|
|
||||||
* @param FilterControllerEvent $event A FilterControllerEvent instance
|
|
||||||
*/
|
|
||||||
public function onKernelController(FilterControllerEvent $event)
|
|
||||||
{
|
|
||||||
if (!is_array($controller = $event->getController())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$object = new \ReflectionObject($controller[0]);
|
|
||||||
$method = $object->getMethod($controller[1]);
|
|
||||||
|
|
||||||
$request = $event->getRequest();
|
|
||||||
foreach ($this->reader->getMethodAnnotations($method) as $configuration) {
|
|
||||||
if ($configuration instanceof ConfigurationInterface) {
|
|
||||||
$request->attributes->set('_'.$configuration->getAliasName(), $configuration);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -5,7 +5,6 @@
|
||||||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
|
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
|
||||||
|
|
||||||
<parameters>
|
<parameters>
|
||||||
<parameter key="webservice.definition.controller.listener.class">Bundle\WebServiceBundle\EventListener\ControllerListener</parameter>
|
|
||||||
<parameter key="webservice.definition.loader.resolver.class">Symfony\Component\Config\Loader\LoaderResolver</parameter>
|
<parameter key="webservice.definition.loader.resolver.class">Symfony\Component\Config\Loader\LoaderResolver</parameter>
|
||||||
<parameter key="webservice.definition.loader.class">Symfony\Component\Config\Loader\DelegatingLoader</parameter>
|
<parameter key="webservice.definition.loader.class">Symfony\Component\Config\Loader\DelegatingLoader</parameter>
|
||||||
<parameter key="webservice.definition.loader.annot_dir.class">Bundle\WebServiceBundle\ServiceDefinition\Loader\AnnotationDirectoryLoader</parameter>
|
<parameter key="webservice.definition.loader.annot_dir.class">Bundle\WebServiceBundle\ServiceDefinition\Loader\AnnotationDirectoryLoader</parameter>
|
||||||
|
@ -14,11 +13,6 @@
|
||||||
</parameters>
|
</parameters>
|
||||||
|
|
||||||
<services>
|
<services>
|
||||||
<service id="webservice.definition.controller.listener" class="%webservice.definition.controller.listener.class%">
|
|
||||||
<tag name="kernel.event_listener" event="kernel.controller" method="onKernelController" />
|
|
||||||
<argument type="service" id="annotation_reader" />
|
|
||||||
</service>
|
|
||||||
|
|
||||||
<service id="webservice.definition.loader.resolver" class="%webservice.definition.loader.resolver.class%" public="false" />
|
<service id="webservice.definition.loader.resolver" class="%webservice.definition.loader.resolver.class%" public="false" />
|
||||||
|
|
||||||
<service id="webservice.definition.loader" class="%webservice.definition.loader.class%">
|
<service id="webservice.definition.loader" class="%webservice.definition.loader.class%">
|
||||||
|
@ -37,4 +31,4 @@
|
||||||
</service>
|
</service>
|
||||||
</services>
|
</services>
|
||||||
|
|
||||||
</container>
|
</container>
|
||||||
|
|
Loading…
Reference in New Issue