private function loadRouteForAsset(RouteCollection $routes, AssetInterface $asset, $name, $pos = null)
    {
        $defaults = array(
            '_controller' => 'assetic.controller:render',
            'name'        => $name,
            'pos'         => $pos,
        );
        $requirements = array();

        // remove the fake front controller
        $pattern = str_replace('_controller/', '', $asset->getTargetPath());

        if ($format = pathinfo($pattern, PATHINFO_EXTENSION)) {
            $defaults['_format'] = $format;
        }

        $route = '_assetic_'.$name;
        if (null !== $pos) {
            $route .= '_'.$pos;
        }

        foreach ($asset->getVars() as $var) {
            if (empty($this->varValues[$var])) {
                throw new \UnexpectedValueException(sprintf('The possible values for the asset variable "%s" are not known', $var));
            }

            $values = array();

            foreach ($this->varValues[$var] as $value) {
                $values[] = preg_quote($value, '#');
            }

            $requirements[$var] = implode('|', $values);
        }

        $routes->add($route, new Route($pattern, $defaults, $requirements));
    }
private function loadRouteForAsset(RouteCollection $routes, AssetInterface $asset, $name, $pos = null)
    {
        $defaults = array(
            '_controller' => 'assetic.controller:render',
            'name'        => $name,
            'pos'         => $pos,
        );
        $requirements = array();

        // remove the fake front controller
        $pattern = str_replace('_controller/', '', $asset->getTargetPath());

        if ($format = pathinfo($pattern, PATHINFO_EXTENSION)) {
            $defaults['_format'] = $format;
        }

        $route = '_assetic_'.$name;
        if (null !== $pos) {
            $route .= '_'.$pos;
        }

        foreach ($asset->getVars() as $var) {
            if (empty($this->varValues[$var])) {
                throw new \UnexpectedValueException(sprintf('The possible values for the asset variable "%s" are not known', $var));
            }

            $values = array();

            foreach ($this->varValues[$var] as $value) {
                $values[] = preg_quote($value, '#');
            }

            $requirements[$var] = implode('|', $values);
        }

        $routes->add($route, new Route($pattern, $defaults, $requirements));
    }
private function loadRouteForAsset ( RouteCollection $ routes , AssetInterface $ asset , $ name , $ pos = null ) { $ defaults = array ( '_controller' => 'assetic.controller:render' , 'name' => $ name , 'pos' => $ pos , ) ; $ requirements = array ( ) ; // remove the fake front controller $ pattern = str_replace ( '_controller/' , '' , $ asset -> getTargetPath ( ) ) ; if ( $ format = pathinfo ( $ pattern , PATHINFO_EXTENSION ) ) { $ defaults [ '_format' ] = $ format ; } $ route = '_assetic_' . $ name ; if ( null !== $ pos ) { $ route .= '_' . $ pos ; } foreach ( $ asset -> getVars ( ) as $ var ) { if ( empty ( $ this -> varValues [ $ var ] ) ) { throw new \ UnexpectedValueException ( sprintf ( 'The possible values for the asset variable "%s" are not known' , $ var ) ) ; } $ values = array ( ) ; foreach ( $ this -> varValues [ $ var ] as $ value ) { $ values [ ] = preg_quote ( $ value , '#' ) ; } $ requirements [ $ var ] = implode ( '|' , $ values ) ; } $ routes -> add ( $ route , new Route ( $ pattern , $ defaults , $ requirements ) ) ; }
Loads a route to serve an supplied asset.

The fake front controller that {@link UseControllerWorker} adds to the
target URL will be removed before set as a route pattern.

@param RouteCollection $routes The route collection
@param AssetInterface  $asset  The asset
@param string          $name   The name to use
@param integer         $pos    The leaf index
Loads a route to serve an supplied asset .