From 0f895497b814008ba64d807a8883b198a7008fec Mon Sep 17 00:00:00 2001 From: Artem Vasilev Date: Sat, 16 Mar 2024 23:06:06 +0300 Subject: [PATCH] Add default scopes --- .../administrator/src/Model/ScopeModel.php | 32 ++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/com_oauthserver/administrator/src/Model/ScopeModel.php b/com_oauthserver/administrator/src/Model/ScopeModel.php index e4c55ac..c258c06 100644 --- a/com_oauthserver/administrator/src/Model/ScopeModel.php +++ b/com_oauthserver/administrator/src/Model/ScopeModel.php @@ -9,13 +9,14 @@ namespace Webmasterskaya\Component\OauthServer\Administrator\Model; -use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\MVC\Model\BaseModel; use Joomla\CMS\MVC\Model\ItemModelInterface; +use Joomla\CMS\MVC\Model\ListModelInterface; +use Webmasterskaya\Component\OauthServer\Administrator\ValueObject\Scope; \defined('_JEXEC') or die; -class ScopeModel extends BaseModel implements ItemModelInterface +class ScopeModel extends BaseModel implements ItemModelInterface, ListModelInterface { private const PREDEFINED_SCOPES = ['userinfo', 'email']; private static array $_storage; @@ -25,10 +26,33 @@ class ScopeModel extends BaseModel implements ItemModelInterface // TODO: Implement getItem() method. } - private function fillStorage(): void + private function fillStorage(): array { - $config = ComponentHelper::getParams('com_oauthserver'); + if (isset(self::$_storage)) + { + return self::$_storage; + } + + self::$_storage = [ + 'userinfo' => new Scope( + 'userinfo', + 'COM_OAUTHSERVER_SCOPE_USERINFO', + 'COM_OAUTHSERVER_SCOPE_USERINFO_DESCRIPTION' + ), + 'email' => new Scope( + 'email', + 'COM_OAUTHSERVER_SCOPE_EMAIL', + 'COM_OAUTHSERVER_SCOPE_EMAIL_DESCRIPTION' + ) + ]; + + return []; + } + + public function getItems() + { + // TODO: Implement getItems() method. } }