Вход Регистрация
Файл: onlinepoisk.wm-scripts.ru/vendor/silex/silex/silex/src/Silex/EventListener/ConverterListener.php
Строк: 89
<?php

/*
 * This file is part of the Silex framework.
 *
 * (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 SilexEventListener;

use 
SymfonyComponentHttpKernelKernelEvents;
use 
SymfonyComponentHttpKernelEventFilterControllerEvent;
use 
SymfonyComponentEventDispatcherEventSubscriberInterface;
use 
SymfonyComponentRoutingRouteCollection;

/**
 * Handles converters.
 *
 * @author Fabien Potencier <fabien@symfony.com>
 */
class ConverterListener implements EventSubscriberInterface
{
    protected 
$routes;

    
/**
     * Constructor.
     *
     * @param RouteCollection $routes A RouteCollection instance
     */
    
public function __construct(RouteCollection $routes)
    {
        
$this->routes $routes;
    }

    
/**
     * Handles converters.
     *
     * @param FilterControllerEvent $event The event to handle
     */
    
public function onKernelController(FilterControllerEvent $event)
    {
        
$request $event->getRequest();
        
$route $this->routes->get($request->attributes->get('_route'));
        if (
$route && $converters $route->getOption('_converters')) {
            foreach (
$converters as $name => $callback) {
                
$request->attributes->set($namecall_user_func($callback$request->attributes->get($name), $request));
            }
        }
    }

    public static function 
getSubscribedEvents()
    {
        return array(
            
KernelEvents::CONTROLLER => 'onKernelController',
        );
    }
}
Онлайн: 0
Реклама