You are here

public function CckIframe::transform in Iframe 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/migrate/process/d6/CckIframe.php \Drupal\iframe\Plugin\migrate\process\d6\CckIframe::transform()

Performs the associated process.

Parameters

mixed $value: The value to be transformed.

\Drupal\migrate\MigrateExecutableInterface $migrate_executable: The migration in which this process is being executed.

\Drupal\migrate\Row $row: The row from the source to process. Normally, just transforming the value is adequate but very rarely you might need to change two columns at the same time or something like that.

string $destination_property: The destination property currently worked on. This is only used together with the $row above.

Return value

string|array The newly transformed value.

Overrides ProcessPluginBase::transform

File

src/Plugin/migrate/process/d6/CckIframe.php, line 44

Class

CckIframe
Class CckIframe.

Namespace

Drupal\iframe\Plugin\migrate\process\d6

Code

public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
  $attributes = unserialize($value['attributes']);

  // Drupal 6 iframe attributes might be double serialized.
  if (!is_array($attributes)) {
    try {
      $attributes = unserialize($attributes);
    } catch (Exception $e) {

      // Ignore and set default attributes were
      // Only optional and ar not necessarily required.
      $attributes = [];
    }
  }

  // Massage the values into the correct form for the iframe.
  foreach ($attributes as $akey => $aval) {
    if (isset($akey)) {
      $route[$akey] = (string) $aval;
    }
  }
  $route['url'] = (string) $value['url'];
  $route['title'] = (string) $value['title_value'];
  $route['tokensupport'] = (int) $value['enable_tokens'];
  return $route;
}