You are here

public function BrightcovePlaylistController::update in Brightcove Video Connect 3.x

Same name and namespace in other branches
  1. 8.2 src/Controller/BrightcovePlaylistController.php \Drupal\brightcove\Controller\BrightcovePlaylistController::update()
  2. 8 src/Controller/BrightcovePlaylistController.php \Drupal\brightcove\Controller\BrightcovePlaylistController::update()

Menu callback to update the existing Playlist with the latest version.

Parameters

int $entity_id: The ID of the playlist in Drupal.

Return value

\Symfony\Component\HttpFoundation\RedirectResponse Redirection response.

Throws

\Exception If BrightcoveAPIClient ID is missing when a new entity is being created.

1 string reference to 'BrightcovePlaylistController::update'
brightcove.routing.yml in ./brightcove.routing.yml
brightcove.routing.yml

File

src/Controller/BrightcovePlaylistController.php, line 65

Class

BrightcovePlaylistController
Provides controller for playlist related callbacks.

Namespace

Drupal\brightcove\Controller

Code

public function update($entity_id) {

  /** @var \Drupal\brightcove\Entity\BrightcovePlaylist $playlist */
  $playlist = BrightcovePlaylist::load($entity_id);

  /** @var \Brightcove\API\CMS $cms */
  $cms = BrightcoveUtil::getCmsApi($playlist
    ->getApiClient());

  // Update playlist.
  BrightcovePlaylist::createOrUpdate($cms
    ->getPlaylist($playlist
    ->getBrightcoveId()), $this->playlistStorage, $this->videoStorage);

  // Redirect back to the playlist edit form.
  return $this
    ->redirect('entity.brightcove_playlist.edit_form', [
    'brightcove_playlist' => $entity_id,
  ]);
}