| Conditions | 3 |
| Paths | 3 |
| Total Lines | 28 |
| Code Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 21 | public function generate($actionName, $adminName, AdminConfiguration $configuration) |
||
| 22 | { |
||
| 23 | if (!$configuration->isResolved()) { |
||
| 24 | throw new Exception('The configuration should be resolved before using it'); |
||
| 25 | } |
||
| 26 | |||
| 27 | if (!array_key_exists($actionName, $configuration->getParameter('actions'))) { |
||
| 28 | throw new Exception( |
||
| 29 | sprintf('Invalid action name %s for admin %s (available action are: %s)', |
||
| 30 | $actionName, |
||
| 31 | $adminName, |
||
| 32 | implode(', ', array_keys($configuration->getParameter('actions')))) |
||
| 33 | ); |
||
| 34 | } |
||
| 35 | // generate the route name using the configured pattern |
||
| 36 | $routeName = str_replace( |
||
| 37 | '{admin}', |
||
| 38 | strtolower($adminName), |
||
| 39 | $configuration->getParameter('routing_name_pattern') |
||
| 40 | ); |
||
| 41 | $routeName = str_replace( |
||
| 42 | '{action}', |
||
| 43 | $actionName, |
||
| 44 | $routeName |
||
| 45 | ); |
||
| 46 | |||
| 47 | return $routeName; |
||
| 48 | } |
||
| 49 | } |
||
| 50 |