eZ\Bundle\EzPublishRestBundle\RequestParser\Router::parse PHP Method

parse() public method

public parse ( $url )
    public function parse($url)
    {
        // we create a request with a new context in order to match $url to a route and get its properties
        $request = Request::create($url, 'GET');
        $originalContext = $this->router->getContext();
        $context = clone $originalContext;
        $context->fromRequest($request);
        $this->router->setContext($context);
        try {
            $matchResult = $this->router->matchRequest($request);
        } catch (ResourceNotFoundException $e) {
            // Note: this probably won't occur in real life because of the legacy matcher
            $this->router->setContext($originalContext);
            throw new InvalidArgumentException("No route matched '{$url}'");
        }
        if (!$this->matchesRestRequest($matchResult)) {
            $this->router->setContext($originalContext);
            throw new InvalidArgumentException("No route matched '{$url}'");
        }
        $this->router->setContext($originalContext);
        return $matchResult;
    }