. * * The interactive user interfaces in modified source and object code versions * of this program must display Appropriate Legal Notices, as required under * Section 5 of the GNU Affero General Public License version 3. * * In accordance with Section 7(b) of the GNU Affero General Public License version 3, * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ namespace Espo\Tools\OAuthServer\Scope; use Espo\Core\Acl\Scope; use Espo\Core\Utils\Metadata; /** * @since 10.1.0 */ class ScopesProvider { /** * @var string[] */ private array $commonScopes = [ Scope::ADMIN, Scope::GLOBAL, ]; public function __construct( private Metadata $metadata, ) {} /** * @return string[] */ public function get(): array { return [ ...$this->commonScopes, ...$this->getAclScopes(), ]; } /** * @return string[] */ private function getAclScopes(): array { /** * @var array $scopesDefs */ $scopesDefs = $this->metadata->get("scopes", []); $list = []; foreach ($scopesDefs as $scope => $defs) { if ( ($defs['disabled'] ?? false) || !($defs['acl'] ?? false) || in_array($scope, $this->commonScopes) ) { continue; } $list[] = $scope; } sort($list); return $list; } }