3 namespace Drupal\image\Plugin\migrate\destination;
5 use Drupal\Component\Plugin\Exception\PluginNotFoundException;
6 use Drupal\migrate\MigrateException;
7 use Drupal\migrate\Plugin\migrate\destination\EntityConfigBase;
8 use Drupal\migrate\Row;
11 * Every migration that uses this destination must have an optional
12 * dependency on the d6_file migration to ensure it runs first.
14 * @MigrateDestination(
15 * id = "entity:image_style"
18 class EntityImageStyle extends EntityConfigBase {
23 public function import(Row $row, array $old_destination_id_values = []) {
26 // Need to set the effects property to null on the row before the ImageStyle
27 // is created, this prevents improper effect plugin initialization.
28 if ($row->getDestinationProperty('effects')) {
29 $effects = $row->getDestinationProperty('effects');
30 $row->setDestinationProperty('effects', []);
33 /** @var \Drupal\Image\Entity\ImageStyle $style */
34 $style = $this->getEntity($row, $old_destination_id_values);
36 // Iterate the effects array so each effect plugin can be initialized.
37 // Catch any missing plugin exceptions.
38 foreach ($effects as $effect) {
40 $style->addImageEffect($effect);
42 catch (PluginNotFoundException $e) {
43 throw new MigrateException($e->getMessage(), 0, $e);
49 return [$style->id()];