wxt-8.x-3.011/modules/custom/wxt_ext/wxt_ext_migration/src/Plugin/migrate/process/PrivPath.php

modules/custom/wxt_ext/wxt_ext_migration/src/Plugin/migrate/process/PrivPath.php
<?php

namespace Drupal\wxt_ext_migration\Plugin\migrate\process;

use Drupal\Core\StreamWrapper\PrivateStream;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\MigrateSkipProcessException;
use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\Row;

/**
 * Constructs the full private directory path.
 *
 * @MigrateProcessPlugin(
 *   id = "wxt_priv_path",
 * )
 */
class PrivPath extends ProcessPluginBase {

  /**
   * {@inheritdoc}
   */
  public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
    if (!$value) {
      throw new MigrateSkipProcessException();
    }
    return $this->getPrivPath($value);
  }

  /**
   * Custom function for getPrivPath().
   */
  protected function getPrivPath($value) {
    $file = str_replace('public://', '', $value);
    return PrivateStream::basePath() . '/files/' . $file;
  }

}

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

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