You are here

public function BrightcoveSubscriptionController::enable in Brightcove Video Connect 8

Same name and namespace in other branches
  1. 8.2 src/Controller/BrightcoveSubscriptionController.php \Drupal\brightcove\Controller\BrightcoveSubscriptionController::enable()
  2. 3.x src/Controller/BrightcoveSubscriptionController.php \Drupal\brightcove\Controller\BrightcoveSubscriptionController::enable()

Enables and creates the default Subscription from Brightcove.

Parameters

string $id: The ID of the Brightcove Subscription.

Return value

\Symfony\Component\HttpFoundation\RedirectResponse Redirect response to redirect user after enabling the default subscription.

1 string reference to 'BrightcoveSubscriptionController::enable'
brightcove.routing.yml in ./brightcove.routing.yml
brightcove.routing.yml

File

src/Controller/BrightcoveSubscriptionController.php, line 283

Class

BrightcoveSubscriptionController
Provides controller for subscription related callbacks.

Namespace

Drupal\brightcove\Controller

Code

public function enable($id) {
  try {
    $subscription = BrightcoveSubscription::load($id);
    $subscription
      ->saveToBrightcove();
    drupal_set_message($this
      ->t('Default subscription for the "@api_client" API client has been successfully enabled.', [
      '@api_client' => $subscription
        ->getApiClient()
        ->label(),
    ]));
  } catch (\Exception $e) {
    drupal_set_message($this
      ->t('Failed to enable the default subscription: @error', [
      '@error' => $e
        ->getMessage(),
    ]), 'error');
  }
  return $this
    ->redirect('entity.brightcove_subscription.list');
}