Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. EntityImageStyle.php

function EntityImageStyle::import

Overrides EntityConfigBase::import

File

core/modules/image/src/Plugin/migrate/destination/EntityImageStyle.php, line 23

Class

EntityImageStyle
Entity image style destination.

Namespace

Drupal\image\Plugin\migrate\destination

Code

public function import(Row $row, array $old_destination_id_values = []) {
    $effects = [];
    // Need to set the effects property to null on the row before the ImageStyle
    // is created, this prevents improper effect plugin initialization.
    if ($row->getDestinationProperty('effects')) {
        $effects = $row->getDestinationProperty('effects');
        $row->setDestinationProperty('effects', []);
    }
    
    /** @var \Drupal\image\Entity\ImageStyle $style */
    $style = $this->getEntity($row, $old_destination_id_values);
    // Iterate the effects array so each effect plugin can be initialized.
    // Catch any missing plugin exceptions.
    foreach ($effects as $effect) {
        try {
            $style->addImageEffect($effect);
        } catch (PluginNotFoundException $e) {
            throw new MigrateException($e->getMessage(), 0, $e);
        }
    }
    $style->save();
    return [
        $style->id(),
    ];
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal