You are here

protected function DefaultFileHandler::embedFile in CMS Content Sync 2.0.x

Same name and namespace in other branches
  1. 8 src/Plugin/cms_content_sync/field_handler/DefaultFileHandler.php \Drupal\cms_content_sync\Plugin\cms_content_sync\field_handler\DefaultFileHandler::embedFile()
  2. 2.1.x src/Plugin/cms_content_sync/field_handler/DefaultFileHandler.php \Drupal\cms_content_sync\Plugin\cms_content_sync\field_handler\DefaultFileHandler::embedFile()

Parameters

\Drupal\cms_content_sync\PushIntent $intent:

\Drupal\file\Entity\File $file:

array $value:

mixed $item:

Return value

array|object

1 call to DefaultFileHandler::embedFile()
DefaultFileHandler::push in src/Plugin/cms_content_sync/field_handler/DefaultFileHandler.php

File

src/Plugin/cms_content_sync/field_handler/DefaultFileHandler.php, line 147

Class

DefaultFileHandler
Providing a minimalistic implementation for any field type.

Namespace

Drupal\cms_content_sync\Plugin\cms_content_sync\field_handler

Code

protected function embedFile($intent, $file, $value, $item) {

  // Handle crop entities.
  $moduleHandler = \Drupal::service('module_handler');
  $crop_types = $intent
    ->getFlow()
    ->getEntityTypeConfig('crop', null, true);
  if ($moduleHandler
    ->moduleExists('crop') && !empty($crop_types)) {
    $settings = $this->flow
      ->getEntityTypeConfig('file', 'file');
    if ($settings['handler_settings']['export_crop']) {
      foreach ($crop_types as $crop_type) {
        if (Crop::cropExists($file
          ->getFileUri(), $crop_type['bundle_name'])) {
          $crop = Crop::findCrop($file
            ->getFileUri(), $crop_type['bundle_name']);
          if ($crop) {
            $intent
              ->addDependency($crop);
          }
        }
      }
    }
  }
  return $intent
    ->addDependency($file, $value);
}