function MediaConfigUpdater::processOembedEagerLoadField

Same name and namespace in other branches
  1. 11.x core/modules/media/src/MediaConfigUpdater.php \Drupal\media\MediaConfigUpdater::processOembedEagerLoadField()

Processes oembed type fields.

Parameters

\Drupal\Core\Entity\Display\EntityViewDisplayInterface $view_display: The view display.

Return value

bool Whether the display was updated.

File

core/modules/media/src/MediaConfigUpdater.php, line 50

Class

MediaConfigUpdater
Provides a BC layer for modules providing old configurations.

Namespace

Drupal\media

Code

public function processOembedEagerLoadField(EntityViewDisplayInterface $view_display) : bool {
  $changed = FALSE;
  foreach ($view_display->getComponents() as $field => $component) {
    if (array_key_exists('type', $component) && $component['type'] === 'oembed' && !array_key_exists('loading', $component['settings'])) {
      $component['settings']['loading']['attribute'] = 'eager';
      $view_display->setComponent($field, $component);
      $changed = TRUE;
    }
  }
  $deprecations_triggered =& $this->triggeredDeprecations['3212351'][$view_display->id()];
  if ($this->deprecationsEnabled && $changed && !$deprecations_triggered) {
    $deprecations_triggered = TRUE;
    @trigger_error(sprintf('The oEmbed loading attribute update for view display "%s" is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Profile, module and theme provided configuration should be updated. See https://www.drupal.org/node/3275103', $view_display->id()), E_USER_DEPRECATED);
  }
  return $changed;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.