Skip to content

Resource ​

Type
Class
Namespace
craft\oauth
Inherits
craft\oauth\Resource » yii\base\BaseObject
Implements
yii\base\Configurable

A protected API's OAuth scopes, permission policy, and canonical URL.

@since 5.12.0

View source

Public Properties ​

PropertyDescription
consentDescription
defaultScopesstring[] – Scopes requested when the client omits scope.
id
permissions
resourceUrl
scopeLabelsarray<string,string> – Consent screen labels for access levels.
scopeLevelsstring[] – Scopes that form access levels, ordered from narrowest to broadest.
scopesarray<string,string> – Allowed scope IDs mapped to consent descriptions.
userScopesClosure, null – Returns the scope IDs, out of those given, that a user may be granted.

consentDescription ​

Default value
''

View source

defaultScopes ​

Type
string[]
Default value
[]

Scopes requested when the client omits scope.

View source

id ​

Default value
null

View source

permissions ​

Default value
[]

View source

resourceUrl ​

Default value
null

View source

scopeLabels ​

Type
array<string,string>
Default value
[]

Consent screen labels for access levels. Levels without a label show their scope ID.

View source

scopeLevels ​

Type
string[]
Default value
[]

Scopes that form access levels, ordered from narrowest to broadest. Each level includes the ones before it, and the user chooses one level on the consent screen.

View source

scopes ​

Type
array<string,string>
Default value
[]

Allowed scope IDs mapped to consent descriptions.

View source

userScopes ​

Type
Closure, null
Default value
null

Returns the scope IDs, out of those given, that a user may be granted. Signature: function(User $user, string[] $scopes): string[]

View source

Public Methods ​

MethodDescription
__call()Calls the named method which is not a class method.
__construct()Constructor.
__get()Returns the value of an object property.
__isset()Checks if a property is set, i.e. defined and not null.
__set()Sets value of an object property.
__unset()Sets an object property to null.
allowsScopes()Whether the scope IDs form a nonempty subset of this resource's allowed scopes.
canGetProperty()Returns a value indicating whether a property can be read.
canSetProperty()Returns a value indicating whether a property can be set.
className()Returns the fully qualified name of this class.
getResourceUrl()
grantedLevels()The scope IDs granted by choosing an access level: the level and the narrower ones.
grantsCover()Whether earlier grants cover the requested scopes. Scopes that aren't levels must all have been granted, and requested levels must overlap the levels granted by the broadest level chosen before.
hasMethod()Returns a value indicating whether a method is defined.
hasProperty()Returns a value indicating whether a property is defined.
highestLevel()The broadest access level in the given scopes.
init()Initializes the object.
levelChoices()The access levels a user may choose between for the requested scopes, narrowest first.
narrowScopes()Removes the requested access levels that $level doesn't grant, keeping scopes that aren't levels.
satisfyingLevels()The scope IDs that satisfy an access level: the level and the broader ones.
scopesForUser()The scope IDs, out of those given, that a user may be granted.

allowsScopes() ​

Whether the scope IDs form a nonempty subset of this resource's allowed scopes.

View source

Arguments ​

  • $scopes

getResourceUrl() ​

View source

grantedLevels() ​

The scope IDs granted by choosing an access level: the level and the narrower ones.

View source

Arguments ​

  • $level

Returns ​

string[]

grantsCover() ​

Whether earlier grants cover the requested scopes. Scopes that aren't levels must all have been granted, and requested levels must overlap the levels granted by the broadest level chosen before.

View source

Arguments ​

highestLevel() ​

The broadest access level in the given scopes.

View source

Arguments ​

levelChoices() ​

The access levels a user may choose between for the requested scopes, narrowest first.

View source

Arguments ​

Returns ​

string[]

narrowScopes() ​

Removes the requested access levels that $level doesn't grant, keeping scopes that aren't levels.

View source

Arguments ​

Returns ​

string[]

satisfyingLevels() ​

The scope IDs that satisfy an access level: the level and the broader ones.

View source

Arguments ​

  • $level

Returns ​

string[]

scopesForUser() ​

The scope IDs, out of those given, that a user may be granted.

View source

Arguments ​

Returns ​

string[]