Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / link / src / Plugin / migrate / process / d6 / FieldLink.php
index 4badcb6c66e5eda3c9e2eeba917d5b72e4431f16..19c5e35ef99961b567ad78a80be96be91adf0bd3 100644 (file)
@@ -2,85 +2,16 @@
 
 namespace Drupal\link\Plugin\migrate\process\d6;
 
-use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
-use Drupal\migrate\Plugin\MigrationInterface;
-use Drupal\migrate\MigrateExecutableInterface;
-use Drupal\migrate\ProcessPluginBase;
-use Drupal\migrate\Row;
-use Symfony\Component\DependencyInjection\ContainerInterface;
+use Drupal\link\Plugin\migrate\process\FieldLink as GeneralPurposeFieldLink;
+
+@trigger_error('FieldLink is deprecated in Drupal 8.4.x and will be removed before Drupal 9.0.x. Use \Drupal\link\Plugin\migrate\process\FieldLink instead.', E_USER_DEPRECATED);
 
 /**
  * @MigrateProcessPlugin(
  *   id = "d6_field_link"
  * )
+ *
+ * @deprecated in Drupal 8.4.x, to be removed before Drupal 9.0.x. Use
+ * \Drupal\link\Plugin\migrate\process\FieldLink instead.
  */
-class FieldLink extends ProcessPluginBase implements ContainerFactoryPluginInterface {
-
-  /**
-   * {@inheritdoc}
-   */
-  public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration) {
-    parent::__construct($configuration, $plugin_id, $plugin_definition);
-    $this->migration = $migration;
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) {
-    return new static(
-      $configuration,
-      $plugin_id,
-      $plugin_definition,
-      $migration
-    );
-  }
-
-  /**
-   * Turn a Drupal 6 URI into a Drupal 8-compatible format.
-   *
-   * @param string $uri
-   *   The 'url' value from Drupal 6.
-   *
-   * @return string
-   *   The Drupal 8-compatible URI.
-   *
-   * @see \Drupal\link\Plugin\Field\FieldWidget\LinkWidget::getUserEnteredStringAsUri()
-   */
-  protected function canonicalizeUri($uri) {
-    // If we already have a scheme, we're fine.
-    if (empty($uri) || !is_null(parse_url($uri, PHP_URL_SCHEME))) {
-      return $uri;
-    }
-
-    // Remove the <front> component of the URL.
-    if (strpos($uri, '<front>') === 0) {
-      $uri = substr($uri, strlen('<front>'));
-    }
-
-    // Add the internal: scheme and ensure a leading slash.
-    return 'internal:/' . ltrim($uri, '/');
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
-    $attributes = unserialize($value['attributes']);
-    // Drupal 6 link attributes might be double serialized.
-    if (!is_array($attributes)) {
-      $attributes = unserialize($attributes);
-    }
-
-    if (!$attributes) {
-      $attributes = [];
-    }
-
-    // Massage the values into the correct form for the link.
-    $route['uri'] = $this->canonicalizeUri($value['url']);
-    $route['options']['attributes'] = $attributes;
-    $route['title'] = $value['title'];
-    return $route;
-  }
-
-}
+class FieldLink extends GeneralPurposeFieldLink {}