| Conditions | 5 |
| Paths | 7 |
| Total Lines | 25 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 30 |
| Changes | 0 | ||
| 1 | <?php |
||
| 28 | public static function redirectToPostedUrl( |
||
| 29 | WebController $controller, |
||
| 30 | $object = null, |
||
| 31 | string $default = null |
||
| 32 | ): Response { |
||
| 33 | if ($controller instanceof CraftWebController) { |
||
| 34 | return $controller->redirectToPostedUrl($object, $default); |
||
| 35 | } |
||
| 36 | |||
| 37 | $url = Craft::$app->getRequest()->getValidatedBodyParam('redirect'); |
||
| 38 | |||
| 39 | if ($url === null) { |
||
| 40 | if ($default !== null) { |
||
| 41 | $url = $default; |
||
| 42 | } else { |
||
| 43 | $url = Craft::$app->getRequest()->getPathInfo(); |
||
| 44 | } |
||
| 45 | } |
||
| 46 | |||
| 47 | if ($object) { |
||
| 48 | $url = Craft::$app->getView()->renderObjectTemplate($url, $object); |
||
| 49 | } |
||
| 50 | |||
| 51 | return $controller->redirect($url); |
||
| 52 | } |
||
| 53 | } |
||
| 54 |