| Conditions | 3 |
| Paths | 3 |
| Total Lines | 29 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 23 | public function render( |
||
| 24 | Link $action, |
||
| 25 | mixed $data = null, |
||
| 26 | array $options = [] |
||
| 27 | ): string { |
||
| 28 | $errors = $this->validator->validate($action, [new Valid()]); |
||
| 29 | |||
| 30 | if ($errors->count() > 0) { |
||
| 31 | throw new InvalidActionException($errors); |
||
| 32 | } |
||
| 33 | |||
| 34 | if ($action->getRoute()) { |
||
| 35 | $url = $this->urlGenerator->generateFromRouteName( |
||
| 36 | $action->getRoute(), |
||
| 37 | $action->getRouteParameters(), |
||
| 38 | $data, |
||
| 39 | ); |
||
| 40 | } else { |
||
| 41 | $url = $this->urlGenerator->generateFromOperationName( |
||
| 42 | $action->getResourceName(), |
||
|
|
|||
| 43 | $action->getOperationName(), |
||
| 44 | $data, |
||
| 45 | ); |
||
| 46 | } |
||
| 47 | |||
| 48 | return $this->environment->render($action->getTemplate(), [ |
||
| 49 | 'action' => $action, |
||
| 50 | 'url' => $url, |
||
| 51 | 'options' => $options, |
||
| 52 | ]); |
||
| 55 |