From 7ff4f7408aaa8d1739cf26669592a111a885edae Mon Sep 17 00:00:00 2001 From: Ransom Roberson Date: Sat, 13 Aug 2022 13:41:16 -0400 Subject: [PATCH] Tidier --- src/models/App.php | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/models/App.php b/src/models/App.php index deac4e5..721c78f 100644 --- a/src/models/App.php +++ b/src/models/App.php @@ -8,6 +8,7 @@ use craft\helpers\Template; use craft\helpers\UrlHelper; use craft\validators\UniqueValidator; +use craft\web\View; use Exception; use Twig\Error\LoaderError; use Twig\Error\RuntimeError; @@ -173,26 +174,22 @@ public function getTokenRecordQuery(): ActiveQuery /** * Renders some basic UI to allow a user to connect to the app * + * @param string|null $context * @return Markup * @throws LoaderError * @throws RuntimeError * @throws SyntaxError + * @throws \Throwable * @throws \yii\base\Exception */ - public function renderConnector($context = null) + public function renderConnector(string|null $context = null): Markup { - $view = Craft::$app->getView(); - $oldTemplateMode = $view->getTemplateMode(); - if ($oldTemplateMode !== $view::TEMPLATE_MODE_CP) { - $view->setTemplateMode($view::TEMPLATE_MODE_CP); - } $tokens = $this->getValidTokensForUser(); $template = Craft::$app->view->renderTemplate('oauthclient/_connector/connector', [ 'context' => $context, 'app' => $this, 'token' => count($tokens) ? $tokens[0] : null - ]); - $view->setTemplateMode($oldTemplateMode); + ], View::TEMPLATE_MODE_CP); return Template::raw($template); }