private function getRequestPath($resource, $action, &$params)
    {
        if (!isset($this->resources[$resource]) || !isset($this->resources[$resource][$action])) {
            throw new \UnexpectedValueException('Resource path not found');
        }

        // get path
        $path = $this->resources[$resource][$action];

        // replace variables
        $matchCount = preg_match_all("/:(\w*)/", $path, $variables);
        if ($matchCount) {
            foreach ($variables[0] as $index => $placeholder) {
                if (!isset($params[$variables[1][$index]])) {
                    throw new \InvalidArgumentException('Missing parameter: ' . $variables[1][$index]);
                }

                $path = str_replace($placeholder, $params[$variables[1][$index]], $path);
                unset($params[$variables[1][$index]]); // remove parameter from $params
            }
        }

        return $path;
    }
private function getRequestPath($resource, $action, &$params)
    {
        if (!isset($this->resources[$resource]) || !isset($this->resources[$resource][$action])) {
            throw new \UnexpectedValueException('Resource path not found');
        }

        // get path
        $path = $this->resources[$resource][$action];

        // replace variables
        $matchCount = preg_match_all("/:(\w*)/", $path, $variables);
        if ($matchCount) {
            foreach ($variables[0] as $index => $placeholder) {
                if (!isset($params[$variables[1][$index]])) {
                    throw new \InvalidArgumentException('Missing parameter: ' . $variables[1][$index]);
                }

                $path = str_replace($placeholder, $params[$variables[1][$index]], $path);
                unset($params[$variables[1][$index]]); // remove parameter from $params
            }
        }

        return $path;
    }
private function getRequestPath ( $ resource , $ action , & $ params ) { if ( ! isset ( $ this -> resources [ $ resource ] ) || ! isset ( $ this -> resources [ $ resource ] [ $ action ] ) ) { throw new \ UnexpectedValueException ( 'Resource path not found' ) ; } // get path $ path = $ this -> resources [ $ resource ] [ $ action ] ; // replace variables $ matchCount = preg_match_all ( "/:(\w*)/" , $ path , $ variables ) ; if ( $ matchCount ) { foreach ( $ variables [ 0 ] as $ index => $ placeholder ) { if ( ! isset ( $ params [ $ variables [ 1 ] [ $ index ] ] ) ) { throw new \ InvalidArgumentException ( 'Missing parameter: ' . $ variables [ 1 ] [ $ index ] ) ; } $ path = str_replace ( $ placeholder , $ params [ $ variables [ 1 ] [ $ index ] ] , $ path ) ; unset ( $ params [ $ variables [ 1 ] [ $ index ] ] ) ; // remove parameter from $params } } return $ path ; }
Retrieve request path and replace variables with values
@param  string $resource Resource name
@param  string $action   Action name
@param  array  $params   Parameters
@return string Request path
Retrieve request path and replace variables with values