You are here

private function MediaFileCopy::updateFocalPoint in Migrate File Entities to Media Entities 8

Update focal point.

Parameters

$uri_old: Old URI.

$uri_rokka: Rokka URI.

$rokka_file: Rokka file.

1 call to MediaFileCopy::updateFocalPoint()
MediaFileCopy::transform in src/Plugin/migrate/process/MediaFileCopy.php
Performs the associated process.

File

src/Plugin/migrate/process/MediaFileCopy.php, line 150

Class

MediaFileCopy
Copies or local file for usage in media module.

Namespace

Drupal\migrate_file_to_media\Plugin\migrate\process

Code

private function updateFocalPoint($uri_old, $uri_rokka, $rokka_file) {
  try {

    /** @var \Drupal\crop\Entity\Crop $old_crop */
    $old_crop = Crop::findCrop($uri_old, 'focal_point');
    if (!empty($old_crop)) {
      $crop = Crop::create([
        'type' => 'focal_point',
        'entity_id' => $rokka_file
          ->id(),
        'entity_type' => 'file',
        'uri' => $uri_rokka,
        'height' => $old_crop->height->value,
        'width' => $old_crop->width->value,
        'x' => $old_crop->x->value,
        'y' => $old_crop->y->value,
      ]);
      $crop
        ->save();
    }
  } catch (\Exception $exception) {
    throw new MigrateException('Failed to save the focal point to rokka');
  }
}