You are here

public function AudioFieldPluginBase::getItemRenderList in AudioField 8

Used to format file entities for use in the twig themes.

Parameters

object $items: A list of items for which we need to generate render information.

int $limit: An upper limit for the number of files to return. 0 indicates unlimited.

Return value

array A render array containing files in the proper format for rendering.

8 calls to AudioFieldPluginBase::getItemRenderList()
AudioFieldPluginBase::renderDefaultPlayer in src/AudioFieldPluginBase.php
Used to render a default player (for fallback).
AudioJsAudioPlayer::renderPlayer in src/Plugin/AudioPlayer/AudioJsAudioPlayer.php
Renders the player.
JPlayerAudioPlayer::renderPlayer in src/Plugin/AudioPlayer/JPlayerAudioPlayer.php
Renders the player.
MediaElementAudioPlayer::renderPlayer in src/Plugin/AudioPlayer/MediaElementAudioPlayer.php
Renders the player.
ProjekktorAudioPlayer::renderPlayer in src/Plugin/AudioPlayer/ProjekktorAudioPlayer.php
Renders the player.

... See full list

File

src/AudioFieldPluginBase.php, line 537

Class

AudioFieldPluginBase
Base class for audiofield plugins. Includes global functions.

Namespace

Drupal\audiofield

Code

public function getItemRenderList($items, $limit = 0) {
  $template_files = [];
  foreach ($items as $item) {

    // If this entity has passed validation, we render it.
    if ($this
      ->validateEntityAgainstPlayer($item)) {

      // Get render information for this item.
      $renderInfo = $this
        ->getAudioRenderInfo($item);

      // Add the file to the render array.
      $template_files[] = $renderInfo;

      // Return list if we have hit the limit.
      if ($limit > 0 && count($template_files) == $limit) {
        return $template_files;
      }
    }
  }
  return $template_files;
}