You are here

public function BlockTheme::transform in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/block/src/Plugin/migrate/process/BlockTheme.php \Drupal\block\Plugin\migrate\process\BlockTheme::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

core/modules/block/src/Plugin/migrate/process/BlockTheme.php, line 73

Class

BlockTheme
Plugin annotation @MigrateProcessPlugin( id = "block_theme" )

Namespace

Drupal\block\Plugin\migrate\process

Code

public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
  list($theme, $default_theme, $admin_theme) = $value;

  // If the source theme exists on the destination, we're good.
  if (isset($this->themes[$theme])) {
    return $theme;
  }

  // If the source block is assigned to a region in the source default theme,
  // then assign it to the destination default theme.
  if (strtolower($theme) == strtolower($default_theme)) {
    return $this->themeConfig
      ->get('default');
  }

  // If the source block is assigned to a region in the source admin theme,
  // then assign it to the destination admin theme.
  if (strtolower($theme) == strtolower($admin_theme)) {
    return $this->themeConfig
      ->get('admin');
  }

  // We couldn't map it to a D8 theme so just return the incoming theme.
  return $theme;
}