Documentation

FeatureFlag

Feature Flags API class for managing Canvas feature toggles.

Feature flags allow you to see what optional features apply to a given Account, Course, or User. Some feature flags can only be seen by users with administrative rights.

This class does NOT extend AbstractBaseApi as feature flags don't follow standard CRUD patterns. Instead, it implements custom methods specific to feature flag operations.

Tags
see
https://canvas.instructure.com/doc/api/feature_flags.html

Table of Contents

Properties

$appliesTo  : string|null
The type of object the feature applies to (RootAccount, Account, Course, or User)
$beta  : bool|null
If true, the feature is a beta feature that may change or be removed
$contextId  : int|null
The ID of the context (for tracking purposes, not from Canvas API)
$contextType  : string|null
The type of context (for tracking purposes, not from Canvas API)
$development  : bool|null
If true, the feature is in development. Should not be used in production
$displayName  : string|null
The user-visible name of the feature
$enableAt  : string|null
The name of the feature that this feature depends on, if any
$feature  : string|null
The symbolic name of the feature
$featureFlag  : array<string, mixed>|null
The FeatureFlag that applies to the caller
$hidden  : bool|null
If true, the feature flag is hidden from the UI
$locked  : bool|null
If true, the feature flag cannot be changed at lower levels
$releaseNotesUrl  : string|null
A URL to the release notes describing the feature
$rootOptIn  : bool|null
If true, a feature flag associated with this feature may only be set on the Root Account
$state  : string|null
The state of the feature flag (off, allowed, on)
$apiClient  : HttpClientInterface

Methods

allow()  : self
Allow a feature to be toggled for the default account context
allowByContext()  : self
Allow a feature to be toggled for a specific context
delete()  : bool
Remove a feature flag for the default account context
deleteByContext()  : bool
Remove a feature flag for a specific context
disable()  : self
Disable a feature for the default account context
disableByContext()  : self
Disable a feature for a specific context
enable()  : self
Enable a feature for the default account context
enableByContext()  : self
Enable a feature for a specific context
fetchByContext()  : array<int, self>
List features for a specific context
find()  : self
Get a specific feature flag for the default account context
findByContext()  : self
Get a specific feature flag for a specific context
get()  : array<int, self>
List features for the default account context
isAllowed()  : bool
Check if a feature is allowed (can be toggled)
isBeta()  : bool
Check if a feature is in beta
isDevelopment()  : bool
Check if a feature is in development
isDisabled()  : bool
Check if a feature is disabled
isEnabled()  : bool
Check if a feature is enabled
isHidden()  : bool
Check if a feature is hidden
isLocked()  : bool
Check if a feature is locked
setApiClient()  : void
Set the API client
setFeatureState()  : self
Set the state of a feature flag for the default account context
setFeatureStateByContext()  : self
Set the state of a feature flag for a specific context
update()  : self
Update a feature flag for the default account context
updateByContext()  : self
Update a feature flag for a specific context
hydrateProperties()  : void
Hydrate object properties from API response data
normalizeContextType()  : string
Normalize the context type from plural to singular
validateContextType()  : void
Validate that the context type is supported

Properties

$appliesTo

The type of object the feature applies to (RootAccount, Account, Course, or User)

public string|null $appliesTo = null

$beta

If true, the feature is a beta feature that may change or be removed

public bool|null $beta = null

$contextId

The ID of the context (for tracking purposes, not from Canvas API)

public int|null $contextId = null

$contextType

The type of context (for tracking purposes, not from Canvas API)

public string|null $contextType = null

$development

If true, the feature is in development. Should not be used in production

public bool|null $development = null

$displayName

The user-visible name of the feature

public string|null $displayName = null

$enableAt

The name of the feature that this feature depends on, if any

public string|null $enableAt = null

$feature

The symbolic name of the feature

public string|null $feature = null

$featureFlag

The FeatureFlag that applies to the caller

public array<string, mixed>|null $featureFlag = null

$hidden

If true, the feature flag is hidden from the UI

public bool|null $hidden = null

$locked

If true, the feature flag cannot be changed at lower levels

public bool|null $locked = null

$releaseNotesUrl

A URL to the release notes describing the feature

public string|null $releaseNotesUrl = null

$rootOptIn

If true, a feature flag associated with this feature may only be set on the Root Account

public bool|null $rootOptIn = null

$state

The state of the feature flag (off, allowed, on)

public string|null $state = null

Methods

allow()

Allow a feature to be toggled for the default account context

public static allow(string $featureName) : self
Parameters
$featureName : string

The symbolic name of the feature

Tags
throws
CanvasApiException
Return values
self

allowByContext()

Allow a feature to be toggled for a specific context

public static allowByContext(string $contextType, int $contextId, string $featureName) : self
Parameters
$contextType : string

The context type (accounts, courses, users)

$contextId : int

The context ID

$featureName : string

The symbolic name of the feature

Tags
throws
CanvasApiException
Return values
self

delete()

Remove a feature flag for the default account context

public static delete(string $featureName) : bool
Parameters
$featureName : string

The symbolic name of the feature

Tags
throws
CanvasApiException
Return values
bool

deleteByContext()

Remove a feature flag for a specific context

public static deleteByContext(string $contextType, int $contextId, string $featureName) : bool
Parameters
$contextType : string

The context type (accounts, courses, users)

$contextId : int

The context ID

$featureName : string

The symbolic name of the feature

Tags
throws
CanvasApiException
Return values
bool

disable()

Disable a feature for the default account context

public static disable(string $featureName) : self
Parameters
$featureName : string

The symbolic name of the feature

Tags
throws
CanvasApiException
Return values
self

disableByContext()

Disable a feature for a specific context

public static disableByContext(string $contextType, int $contextId, string $featureName) : self
Parameters
$contextType : string

The context type (accounts, courses, users)

$contextId : int

The context ID

$featureName : string

The symbolic name of the feature

Tags
throws
CanvasApiException
Return values
self

enable()

Enable a feature for the default account context

public static enable(string $featureName) : self
Parameters
$featureName : string

The symbolic name of the feature

Tags
throws
CanvasApiException
Return values
self

enableByContext()

Enable a feature for a specific context

public static enableByContext(string $contextType, int $contextId, string $featureName) : self
Parameters
$contextType : string

The context type (accounts, courses, users)

$contextId : int

The context ID

$featureName : string

The symbolic name of the feature

Tags
throws
CanvasApiException
Return values
self

fetchByContext()

List features for a specific context

public static fetchByContext(string $contextType, int $contextId[, array<string, mixed> $params = [] ]) : array<int, self>
Parameters
$contextType : string

The context type (accounts, courses, users)

$contextId : int

The context ID

$params : array<string, mixed> = []

Query parameters

Tags
throws
CanvasApiException
Return values
array<int, self>

Array of FeatureFlag objects

find()

Get a specific feature flag for the default account context

public static find(string $featureName) : self
Parameters
$featureName : string

The symbolic name of the feature

Tags
throws
CanvasApiException
Return values
self

findByContext()

Get a specific feature flag for a specific context

public static findByContext(string $contextType, int $contextId, string $featureName) : self
Parameters
$contextType : string

The context type (accounts, courses, users)

$contextId : int

The context ID

$featureName : string

The symbolic name of the feature

Tags
throws
CanvasApiException
Return values
self

get()

List features for the default account context

public static get([array<string, mixed> $params = [] ]) : array<int, self>
Parameters
$params : array<string, mixed> = []

Query parameters

Tags
throws
CanvasApiException
Return values
array<int, self>

Array of FeatureFlag objects

isAllowed()

Check if a feature is allowed (can be toggled)

public isAllowed() : bool
Return values
bool

isBeta()

Check if a feature is in beta

public isBeta() : bool
Return values
bool

isDevelopment()

Check if a feature is in development

public isDevelopment() : bool
Return values
bool

isDisabled()

Check if a feature is disabled

public isDisabled() : bool
Return values
bool

isEnabled()

Check if a feature is enabled

public isEnabled() : bool
Return values
bool

isHidden()

Check if a feature is hidden

public isHidden() : bool
Return values
bool

isLocked()

Check if a feature is locked

public isLocked() : bool
Return values
bool

setFeatureState()

Set the state of a feature flag for the default account context

public static setFeatureState(string $featureName, string $state) : self
Parameters
$featureName : string

The symbolic name of the feature

$state : string

The state to set (off, allowed, on)

Tags
throws
CanvasApiException
Return values
self

setFeatureStateByContext()

Set the state of a feature flag for a specific context

public static setFeatureStateByContext(string $contextType, int $contextId, string $featureName, string $state) : self
Parameters
$contextType : string

The context type (accounts, courses, users)

$contextId : int

The context ID

$featureName : string

The symbolic name of the feature

$state : string

The state to set (off, allowed, on)

Tags
throws
CanvasApiException
Return values
self

update()

Update a feature flag for the default account context

public static update(string $featureName, array<string, mixed>|UpdateFeatureFlagDTO $data) : self
Parameters
$featureName : string

The symbolic name of the feature

$data : array<string, mixed>|UpdateFeatureFlagDTO

The update data

Tags
throws
CanvasApiException
Return values
self

updateByContext()

Update a feature flag for a specific context

public static updateByContext(string $contextType, int $contextId, string $featureName, array<string, mixed>|UpdateFeatureFlagDTO $data) : self
Parameters
$contextType : string

The context type (accounts, courses, users)

$contextId : int

The context ID

$featureName : string

The symbolic name of the feature

$data : array<string, mixed>|UpdateFeatureFlagDTO

The update data

Tags
throws
CanvasApiException
Return values
self

hydrateProperties()

Hydrate object properties from API response data

protected static hydrateProperties(self $object, array<string, mixed> $data) : void
Parameters
$object : self

The object to hydrate

$data : array<string, mixed>

The API response data

normalizeContextType()

Normalize the context type from plural to singular

private static normalizeContextType(string $contextType) : string
Parameters
$contextType : string

The plural context type

Return values
string

The singular context type

validateContextType()

Validate that the context type is supported

private static validateContextType(string $contextType) : void
Parameters
$contextType : string

The context type to validate

Tags
throws
InvalidArgumentException

If the context type is invalid


        
On this page

Search results