You are here

protected function DefaultFileHandler::embedFile in CMS Content Sync 2.1.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.0.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()
    ->getController()
    ->getEntityTypeConfig('crop', null, true);
  if ($moduleHandler
    ->moduleExists('crop') && !empty($crop_types)) {
    $settings = $this->flow
      ->getController()
      ->getEntityTypeConfig('file', 'file');
    if ($settings['handler_settings']['export_crop']) {
      foreach ($crop_types['crop'] as $bundle_name => $crop_type) {
        if (Crop::cropExists($file
          ->getFileUri(), $bundle_name)) {
          $crop = Crop::findCrop($file
            ->getFileUri(), $bundle_name);
          if ($crop) {
            $intent
              ->addDependency($crop);
          }
        }
      }
    }
  }
  return $intent
    ->addDependency($file, $value);
}