You are here

public function BrightcoveVideoController::update in Brightcove Video Connect 8

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

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

Parameters

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

Return value

\Symfony\Component\HttpFoundation\RedirectResponse Redirection response.

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

File

src/Controller/BrightcoveVideoController.php, line 92

Class

BrightcoveVideoController
Provides controller for video related callbacks.

Namespace

Drupal\brightcove\Controller

Code

public function update($entity_id) {

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

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

  // Update video.
  $video = $cms
    ->getVideo($video_entity
    ->getVideoId());
  $this->videoQueue
    ->createItem([
    'api_client_id' => $video_entity
      ->getApiClient(),
    'video' => $video,
  ]);

  // Run batch.
  batch_set([
    'operations' => [
      [
        [
          BrightcoveUtil::class,
          'runQueue',
        ],
        [
          'brightcove_video_queue_worker',
        ],
      ],
      [
        [
          BrightcoveUtil::class,
          'runQueue',
        ],
        [
          'brightcove_text_track_queue_worker',
        ],
      ],
      [
        [
          BrightcoveUtil::class,
          'runQueue',
        ],
        [
          'brightcove_text_track_delete_queue_worker',
        ],
      ],
    ],
  ]);

  // Run batch and redirect back to the video edit form.
  return batch_process(Url::fromRoute('entity.brightcove_video.edit_form', [
    'brightcove_video' => $entity_id,
  ]));
}