You are here

protected function BrightcoveVideoSearch::prepareResults in Brightcove Video Connect 8.2

Same name and namespace in other branches
  1. 3.x src/Plugin/Search/BrightcoveVideoSearch.php \Drupal\brightcove\Plugin\Search\BrightcoveVideoSearch::prepareResults()

Prepare the result set from the chosen entities.

Parameters

array $entities: The entities to add to the passed results.

array $results: Initial result set to extend.

Return value

array The combined results.

Throws

\Drupal\Core\Entity\EntityMalformedException May happen if the video has no URL available. Should not happen.

1 call to BrightcoveVideoSearch::prepareResults()
BrightcoveVideoSearch::execute in src/Plugin/Search/BrightcoveVideoSearch.php
Executes the search.

File

src/Plugin/Search/BrightcoveVideoSearch.php, line 153

Class

BrightcoveVideoSearch
Executes a keyword search for videos against the {brightcove_video} table.

Namespace

Drupal\brightcove\Plugin\Search

Code

protected function prepareResults(array $entities, array $results) {

  /** @var \Drupal\Core\Entity\ContentEntityInterface $video */
  foreach ($entities as $video) {
    $url = $video
      ->toUrl()
      ->toString();
    $result = [
      'title' => $video
        ->getName(),
      'link' => $url,
    ];
    $this
      ->addCacheableDependency($video);
    $results[] = $result;
  }
  return $results;
}