public static function BrightcoveSubscription::createFromArray in Brightcove Video Connect 8
Same name and namespace in other branches
- 8.2 src/Entity/BrightcoveSubscription.php \Drupal\brightcove\Entity\BrightcoveSubscription::createFromArray()
- 3.x src/Entity/BrightcoveSubscription.php \Drupal\brightcove\Entity\BrightcoveSubscription::createFromArray()
Creates a BrightcoveSubscription entity from an array.
Parameters
array $data: Array that contains information about the entity. Values:
- id (int): Internal Drupal identifier, it will be ignored when saving the entity.
- bcsid (string): Brightcove Subscription entity identifier.
- api_client_id (string): API Client ID.
- endpoint (string): Endpoint callback URL, required.
- events (string[]): Events list, eg.: video-change, required.
- is_default (bool): Whether the current Brightcove Subscription is default or not. Will be ignored for local entity update.
- status (bool): Indicates whether a subscription is enabled or disabled. An existing non-default subscription is always enabled, only default subscriptions can be set to disabled.
Return value
\Drupal\brightcove\Entity\BrightcoveSubscription|null The initialized BrightcoveSubscription entity object, or null if the $data array is empty.
5 calls to BrightcoveSubscription::createFromArray()
- BrightcoveSubscription::loadByField in src/
Entity/ BrightcoveSubscription.php - Loads the entity by a given field and value.
- BrightcoveSubscription::loadMultiple in src/
Entity/ BrightcoveSubscription.php - Loads multiple BrightcoveSubscription entities.
- BrightcoveSubscription::loadMultipleByApiClient in src/
Entity/ BrightcoveSubscription.php - Load Subscriptions for a given API client.
- BrightcoveSubscriptionForm::submitForm in src/
Form/ BrightcoveSubscriptionForm.php - Form submission handler.
- brightcove_update_8109 in ./
brightcove.install - Migrate config entity subscriptions.
File
- src/
Entity/ BrightcoveSubscription.php, line 397
Class
- BrightcoveSubscription
- Defines the Brightcove Subscription entity.
Namespace
Drupal\brightcove\EntityCode
public static function createFromArray(array $data) {
if (!empty($data) && !empty($data['api_client_id'])) {
$api_client = BrightcoveAPIClient::load($data['api_client_id']);
$brightcove_subscription = (new BrightcoveSubscription())
->setApiClient($api_client)
->setEndpoint($data['endpoint'])
->setEvents($data['events']);
if (isset($data['id'])) {
$brightcove_subscription->id = (int) $data['id'];
}
if (isset($data['bcsid'])) {
$brightcove_subscription->bcsid = $data['bcsid'];
}
if (isset($data['is_default'])) {
$brightcove_subscription->default = (bool) $data['is_default'];
}
if (isset($data['status'])) {
$brightcove_subscription->status = (bool) $data['status'];
}
return $brightcove_subscription;
}
return NULL;
}