Skip to content

Commit

Permalink
refactor: Use @var instead of instanceof
Browse files Browse the repository at this point in the history
khalwat committed Feb 5, 2024
1 parent de8c4c5 commit 4bea6a8
Showing 2 changed files with 12 additions and 15 deletions.
18 changes: 8 additions & 10 deletions src/controllers/RedirectsController.php
Original file line number Diff line number Diff line change
@@ -275,12 +275,11 @@ public function actionSaveRedirect(): ?Response
if (!$redirect->validate()) {
Craft::$app->getSession()->setError(Craft::t('app', "Couldn't save redirect settings."));
// Send the redirect back to the template
/** @var UrlManager $urlManager */
$urlManager = Craft::$app->getUrlManager();
if ($urlManager instanceof UrlManager) {
$urlManager->setRouteParams([
'redirect' => $redirect,
]);
}
$urlManager->setRouteParams([
'redirect' => $redirect,
]);

return null;
}
@@ -295,12 +294,11 @@ public function actionSaveRedirect(): ?Response
if ($testRedirectConfig === null) {
Craft::$app->getSession()->setError(Craft::t('app', "Couldn't save redirect settings because it'd create a redirect loop."));
// Send the redirect back to the template
/** @var UrlManager $urlManager */
$urlManager = Craft::$app->getUrlManager();
if ($urlManager instanceof UrlManager) {
$urlManager->setRouteParams([
'redirect' => $redirect,
]);
}
$urlManager->setRouteParams([
'redirect' => $redirect,
]);

return null;
}
9 changes: 4 additions & 5 deletions src/controllers/SettingsController.php
Original file line number Diff line number Diff line change
@@ -129,12 +129,11 @@ public function actionSavePluginSettings(): ?Response
Craft::$app->getSession()->setError(Craft::t('app', "Couldn't save plugin settings."));

// Send the plugin back to the template
/** @var UrlManager $urlManager */
$urlManager = Craft::$app->getUrlManager();
if ($urlManager instanceof UrlManager) {
$urlManager->setRouteParams([
'plugin' => $plugin,
]);
}
$urlManager->setRouteParams([
'plugin' => $plugin,
]);

return null;
}

0 comments on commit 4bea6a8

Please sign in to comment.