Skip to content

Commit

Permalink
Tidier
Browse files Browse the repository at this point in the history
  • Loading branch information
Mosnar committed Aug 13, 2022
1 parent 4d93d72 commit 7ff4f74
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/models/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit 7ff4f74

Please sign in to comment.