content_workflow_bynder-1.0.0/src/Plugin/migrate/process/ContentWorkflowBynderReferenceRevision.php

src/Plugin/migrate/process/ContentWorkflowBynderReferenceRevision.php
<?php

namespace Drupal\content_workflow_bynder\Plugin\migrate\process;

use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\Row;

/**
 * Perform custom value transformation.
 *
 * Converts simple arrays to multidimensional so we can use extract plugin.
 *
 * @MigrateProcessPlugin(
 *   id = "content_workflow_bynder_reference_revision",
 *   handle_multiples = TRUE
 * )
 *
 * @code
 * reference_revision_field:
 *   plugin: content_workflow_bynder_reference_revision
 *   source: field
 * @endcode
 */
class ContentWorkflowBynderReferenceRevisionReferenceRevision extends ProcessPluginBase {

  /**
   * {@inheritdoc}
   */
  public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
    if (!is_array($value)) {
      $value = [$value];
    }

    $return = [];

    foreach ($value as $data) {
      $return[] = ['id' => $data];
    }

    return $return;
  }

  /**
   * {@inheritdoc}
   */
  public function multiple() {
    return TRUE;
  }

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc