symfony-cmf / symfony-cmf-docs

The documentation for the symfony content management framework
http://cmf.symfony.com
44 stars 157 forks source link

[Routing] Fixing 'Creating the Route Provider' example #721

Closed yceruto closed 8 years ago

yceruto commented 8 years ago
Q A
Doc fix? yes
New docs? no
Applies to all
Fixed tickets n/a

Customizing the Dynamic Router > Using a Custom Route Provider > Creating the Route Provider > getRouteByName method link:

/**
 * This method is used to generate URLs, e.g. {{ path('foobar') }}.
 */
public function getRouteByName($name, $params = array())
{
    $document = $this->findOneBy(array(
        'name' => $name,
    ));

    // <--- missing RouteNotFoundException if $document is null

    if ($route) { // <--- undefined variable $route
        $route = new SymfonyRoute($route->getPattern(), array( // <--- undefined variable $route
            'document' => $document,
        ));
    }

    return $route;
}
dbu commented 8 years ago

seems we did not check good enough what we whre explaining here. thanks for fixing these mistakes!