Mapping/Driver/AnnotationDriver.php
protected function getRouteMetadata($routeName)
    {
        if (isset($this->routeMetadata[$routeName])) {
            return $this->routeMetadata[$routeName];
        }

        $route = $this->router->getRouteCollection()->get($routeName);

        if (null === $route) {
            // TODO Improve this
            throw new \Exception(sprintf('The route "%s" couldn\'t be found', $routeName));
        }

        // TODO Check this
        $controller = $route->getDefault('_controller');
        if (preg_match('#(.+)::([\w]+)#', $controller, $matches)) {
            $class = $matches[1];
            $method = $matches[2];
        } elseif (preg_match('#(.+):([\w]+)#', $controller, $matches)) {
            $controller = $matches[1];
            $method = $matches[2];
            if ($this->container->has($controller)) {
                $this->container->enterScope('request');
                $this->container->set('request', new Request());
                $class = get_class($this->container->get($controller));
                $this->container->leaveScope('request');
            }
        }

        if (isset($class) && isset($method)) {
            try {
                $method = new ReflectionMethod($class, $method);
            } catch (\ReflectionException $e) {
                throw new \Exception(sprintf('The controller method for the route "%s" couldn\'t be found', $routeName));
            }
        }

        if (null === ($annotation = $this->getAnnotation($method, 'ML\HydraBundle\Mapping\Operation'))) {
            throw new \Exception(sprintf('The controller method for the route "%s" is not marked as an operation', $routeName));
        }

        $operation = new OperationDefinition($routeName);
        $operation->setIri($annotation->getIri());
        $operation->setType($annotation->type);

        $operation->setRoute($route);

        $tmp = $this->getDocBlockText($method);

        $operation->setTitle($tmp['title']);
        $operation->setDescription($tmp['description']);

        $operation->setExpects($annotation->expect);
        $operation->setStatusCodes($annotation->status_codes);

        // TODO Check this
        $tmp = $this->getType($method);
        $operation->setReturns($tmp['type']);

        // TODO Check this! Should we use the return type instead?
        if ($tmp['is_array'] || (null !== ($annotation = $this->getAnnotation($method, 'ML\HydraBundle\Mapping\Collection')))) {
            $operation->setReturns('ML\HydraBundle\Entity\Collection');
        }

        // if (('array' === $operation['return']['type']) || (self::HYDRA_COLLECTION === $operation['return']['type'])) {
        //     $operation['return']['type'] = self::HYDRA_COLLECTION;
        // }

        // method/IRI
        $operation->setMethod($route->getRequirement('_method'));
        // $operation['path'] = $route->getPath();
        // $operation['variables'] = $route->compile()->getVariables();
        // $operation['defaults'] = $route->getDefaults();
        // unset($operation['defaults']['_controller']);

        // Cache the metadata since it might be needed several times
        $this->routeMetadata[$routeName] = $operation;

        return $operation;
    }
protected function getRouteMetadata($routeName)
    {
        if (isset($this->routeMetadata[$routeName])) {
            return $this->routeMetadata[$routeName];
        }

        $route = $this->router->getRouteCollection()->get($routeName);

        if (null === $route) {
            // TODO Improve this
            throw new \Exception(sprintf('The route "%s" couldn\'t be found', $routeName));
        }

        // TODO Check this
        $controller = $route->getDefault('_controller');
        if (preg_match('#(.+)::([\w]+)#', $controller, $matches)) {
            $class = $matches[1];
            $method = $matches[2];
        } elseif (preg_match('#(.+):([\w]+)#', $controller, $matches)) {
            $controller = $matches[1];
            $method = $matches[2];
            if ($this->container->has($controller)) {
                $this->container->enterScope('request');
                $this->container->set('request', new Request());
                $class = get_class($this->container->get($controller));
                $this->container->leaveScope('request');
            }
        }

        if (isset($class) && isset($method)) {
            try {
                $method = new ReflectionMethod($class, $method);
            } catch (\ReflectionException $e) {
                throw new \Exception(sprintf('The controller method for the route "%s" couldn\'t be found', $routeName));
            }
        }

        if (null === ($annotation = $this->getAnnotation($method, 'ML\HydraBundle\Mapping\Operation'))) {
            throw new \Exception(sprintf('The controller method for the route "%s" is not marked as an operation', $routeName));
        }

        $operation = new OperationDefinition($routeName);
        $operation->setIri($annotation->getIri());
        $operation->setType($annotation->type);

        $operation->setRoute($route);

        $tmp = $this->getDocBlockText($method);

        $operation->setTitle($tmp['title']);
        $operation->setDescription($tmp['description']);

        $operation->setExpects($annotation->expect);
        $operation->setStatusCodes($annotation->status_codes);

        // TODO Check this
        $tmp = $this->getType($method);
        $operation->setReturns($tmp['type']);

        // TODO Check this! Should we use the return type instead?
        if ($tmp['is_array'] || (null !== ($annotation = $this->getAnnotation($method, 'ML\HydraBundle\Mapping\Collection')))) {
            $operation->setReturns('ML\HydraBundle\Entity\Collection');
        }

        // if (('array' === $operation['return']['type']) || (self::HYDRA_COLLECTION === $operation['return']['type'])) {
        //     $operation['return']['type'] = self::HYDRA_COLLECTION;
        // }

        // method/IRI
        $operation->setMethod($route->getRequirement('_method'));
        // $operation['path'] = $route->getPath();
        // $operation['variables'] = $route->compile()->getVariables();
        // $operation['defaults'] = $route->getDefaults();
        // unset($operation['defaults']['_controller']);

        // Cache the metadata since it might be needed several times
        $this->routeMetadata[$routeName] = $operation;

        return $operation;
    }
Get information about a route

@param string $routeName