You are here

public function MediaSelectionProcessorManager::processData in Gutenberg 8

Same name and namespace in other branches
  1. 8.2 src/MediaSelectionProcessor/MediaSelectionProcessorManager.php \Drupal\gutenberg\MediaSelectionProcessor\MediaSelectionProcessorManager::processData()

Process selection data.

If numeric string is provided, default processor will be fired.

Parameters

string $data: Serialized data to process.

Return value

\Drupal\media\MediaInterface[] List of media entities.

Overrides MediaSelectionProcessorManagerInterface::processData

File

src/MediaSelectionProcessor/MediaSelectionProcessorManager.php, line 44

Class

MediaSelectionProcessorManager
Provides management for tagged media selection processor services.

Namespace

Drupal\gutenberg\MediaSelectionProcessor

Code

public function processData(string $data) {
  $media_entities = [];
  if (is_numeric($data)) {
    $media_entities = $this
      ->process('default', [
      $data,
    ]);
  }
  else {
    $special_data = json_decode($data, TRUE);
    foreach ($special_data as $processor => $processor_data) {
      $media_entities = $this
        ->process($processor, $processor_data);
    }
  }
  return $media_entities;
}