Skip to content

Commit

Permalink
Parse variablePattern and add mandatory fields to defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Funk authored and lsmith77 committed Dec 16, 2013
1 parent bd7da36 commit 96d0649
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Admin/RouteAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,19 @@ protected function configureFieldsForDefaults()
$defaults[$name] = array($name, 'text', array('required' => false));
}
}

//parse variable pattern and add defaults for it - taken from routecompiler
/** @var $route Route */
$route = $this->subject;
if ($route && $route->getVariablePattern()) {
preg_match_all('#\{\w+\}#', $route->getVariablePattern(), $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER);
foreach ($matches as $match) {
$name = substr($match[0][0], 1, -1);
if (!isset($defaults[$name])) {
$defaults[$name] = array($name, 'text', array('required' => true));
}
}
}

return $defaults;
}
Expand Down

0 comments on commit 96d0649

Please sign in to comment.