Skip to content

Commit

Permalink
refactor: Use @var instead of instanceof
Browse files Browse the repository at this point in the history
  • Loading branch information
khalwat committed Feb 5, 2024
1 parent 05e5632 commit 1a75afb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
28 changes: 14 additions & 14 deletions src/controllers/RedirectsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use nystudio107\retour\helpers\Permission as PermissionHelper;
use nystudio107\retour\models\StaticRedirects as StaticRedirectsModel;
use nystudio107\retour\Retour;
use Throwable;
use yii\base\Exception;
use yii\base\InvalidConfigException;
use yii\web\BadRequestHttpException;
Expand Down Expand Up @@ -122,7 +123,8 @@ public function actionEditRedirect(
string $defaultUrl = '',
int $siteId = 0,
StaticRedirectsModel $redirect = null,
): Response {
): Response
{
$variables = [];
PermissionHelper::controllerPermissionCheck('retour:redirects');

Expand Down Expand Up @@ -270,12 +272,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;
}
Expand All @@ -290,12 +291,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;
}
Expand All @@ -312,8 +312,8 @@ public function actionSaveRedirect(): ?Response
* @param string|null $siteHandle
*
* @return Response
* @throws \yii\web\ForbiddenHttpException
* @throws \yii\web\NotFoundHttpException
* @throws ForbiddenHttpException
* @throws NotFoundHttpException
*/
public function actionShortlinks(string $siteHandle = null): Response
{
Expand Down Expand Up @@ -366,7 +366,7 @@ public function actionShortlinks(string $siteHandle = null): Response
* @throws BadRequestHttpException
* @throws ForbiddenHttpException
* @throws MissingComponentException
* @throws \Throwable
* @throws Throwable
* @throws ElementNotFoundException
* @throws Exception
*/
Expand Down
9 changes: 4 additions & 5 deletions src/controllers/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 1a75afb

Please sign in to comment.