AsseticBundle\Configuration::getRoute PHP Method

getRoute() public method

public getRoute ( $name, $default = null )
    public function getRoute($name, $default = null)
    {
        $assets = [];
        $routeMatched = false;
        // Merge all assets configuration for which regular expression matches route
        foreach ($this->routes as $spec => $config) {
            if (preg_match('(^' . $spec . '$)i', $name)) {
                $routeMatched = true;
                $assets = Stdlib\ArrayUtils::merge($assets, (array) $config);
            }
        }
        // Only return default if none regular expression matched
        return $routeMatched ? $assets : $default;
    }

Usage Example

 public function testEmptyRouteMatchWillNotTriggerDefault()
 {
     $this->object->setRoutes(array('bar' => array()));
     $assets = $this->object->getRoute('bar');
     $this->assertNotEquals('default', $assets);
     $this->assertCount(0, $assets);
 }
All Usage Examples Of AsseticBundle\Configuration::getRoute