drupalorg_migrate-1.0.x-dev/src/Plugin/migrate/process/FieldLinkFromUrl.php

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

namespace Drupal\drupalorg_migrate\Plugin\migrate\process;

use Drupal\link\Plugin\migrate\process\FieldLink;
use Drupal\migrate\Attribute\MigrateProcess;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\Row;

/**
 * Transform a D7 URL link for use in Drupal 8.
 *
 * @code
 * process:
 *   field_link:
 *     plugin: field_link_from_url
 *     uri_scheme: 'https://'
 *     source: field_link
 * @endcode
 */
#[MigrateProcess('field_link_from_url')]
class FieldLinkFromUrl extends FieldLink {

  /**
   * {@inheritdoc}
   */
  public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
    $value['url'] = $value['value'];
    $value['title'] = $value['title'] ?? '';
    return parent::transform($value, $migrate_executable, $row, $destination_property);
  }

}

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

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