usebb2drupal-8.x-1.0-rc1/src/Plugin/migrate/process/Website.php

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

namespace Drupal\usebb2drupal\Plugin\migrate\process;

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

/**
 * Transform UseBB website to Drupal one.
 *
 * @MigrateProcessPlugin(
 *   id = "usebb_website"
 * )
 */
class Website extends ProcessPluginBase {

  /**
   * {@inheritdoc}
   */
  public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
    if (!($url = parse_url($value)) || empty($url['host'])) {
      return NULL;
    }
    $host = $url['host'];
    return [
      'uri' => $value,
      'title' => strpos($host, 'www.') === 0 ? substr($host, 4) : $host,
      'options' => [],
    ];
  }

}

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

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