Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Expose route parameter names
Browse files Browse the repository at this point in the history
  • Loading branch information
harto committed Jul 8, 2014
1 parent 74630e3 commit b7ffcf8
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions classes/Ergo/Routing/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function __construct($name, $template)
{
$this->_name = $name;
$this->_template = $template;
$this->_parameters = $this->_getParameterNames($template);
$this->_parameters = $this->_extractParameterNames($template);
$this->_pattern = $this->_getParameterPattern($template);
}

Expand Down Expand Up @@ -105,6 +105,15 @@ public function getName()
return $this->_name;
}

/**
* Returns the names of the replaceable parameters defined in this route
* @return array
*/
public function getParameterNames()
{
return $this->_parameters;
}

// ----------------------------------------

/**
Expand Down Expand Up @@ -203,7 +212,7 @@ private function _getParameterPattern($template)
* @param string $template
* @return array list of parameter names contained in the template.
*/
private function _getParameterNames($template)
private function _extractParameterNames($template)
{
if(!is_string($template))
throw new \InvalidArgumentException("Template is not a string");
Expand Down

0 comments on commit b7ffcf8

Please sign in to comment.