Add default scopes

This commit is contained in:
Artem Vasilev 2024-03-16 23:06:06 +03:00
parent 2a7cad85db
commit 0f895497b8

View File

@ -9,13 +9,14 @@
namespace Webmasterskaya\Component\OauthServer\Administrator\Model; namespace Webmasterskaya\Component\OauthServer\Administrator\Model;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\MVC\Model\BaseModel; use Joomla\CMS\MVC\Model\BaseModel;
use Joomla\CMS\MVC\Model\ItemModelInterface; use Joomla\CMS\MVC\Model\ItemModelInterface;
use Joomla\CMS\MVC\Model\ListModelInterface;
use Webmasterskaya\Component\OauthServer\Administrator\ValueObject\Scope;
\defined('_JEXEC') or die; \defined('_JEXEC') or die;
class ScopeModel extends BaseModel implements ItemModelInterface class ScopeModel extends BaseModel implements ItemModelInterface, ListModelInterface
{ {
private const PREDEFINED_SCOPES = ['userinfo', 'email']; private const PREDEFINED_SCOPES = ['userinfo', 'email'];
private static array $_storage; private static array $_storage;
@ -25,10 +26,33 @@ class ScopeModel extends BaseModel implements ItemModelInterface
// TODO: Implement getItem() method. // 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.
} }
} }