Skip to content

Commit 96d0649

Browse files
Eric Funklsmith77
Eric Funk
authored andcommitted
Parse variablePattern and add mandatory fields to defaults
1 parent bd7da36 commit 96d0649

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Admin/RouteAdmin.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,19 @@ protected function configureFieldsForDefaults()
125125
$defaults[$name] = array($name, 'text', array('required' => false));
126126
}
127127
}
128+
129+
//parse variable pattern and add defaults for it - taken from routecompiler
130+
/** @var $route Route */
131+
$route = $this->subject;
132+
if ($route && $route->getVariablePattern()) {
133+
preg_match_all('#\{\w+\}#', $route->getVariablePattern(), $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER);
134+
foreach ($matches as $match) {
135+
$name = substr($match[0][0], 1, -1);
136+
if (!isset($defaults[$name])) {
137+
$defaults[$name] = array($name, 'text', array('required' => true));
138+
}
139+
}
140+
}
128141

129142
return $defaults;
130143
}

0 commit comments

Comments
 (0)