You are here

public function BlockRegion::transform in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/block/src/Plugin/migrate/process/BlockRegion.php \Drupal\block\Plugin\migrate\process\BlockRegion::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/BlockRegion.php, line 61
Contains \Drupal\block\Plugin\migrate\process\BlockRegion.

Class

BlockRegion
Plugin annotation @MigrateProcessPlugin( id = "block_region" )

Namespace

Drupal\block\Plugin\migrate\process

Code

public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {

  // Set the destination region, based on the source region and theme as well
  // as the current destination default theme.
  list($region, $source_theme, $destination_theme) = $value;

  // Theme is the same on both source and destination, so ensure that the
  // region exists in the destination theme.
  if (strtolower($source_theme) == strtolower($destination_theme)) {
    if (isset($this->regions[$destination_theme][$region])) {
      return $region;
    }
  }

  // If the source and destination theme are different, try to use the
  // mappings defined in the configuration.
  $region_map = $this->configuration['region_map'];
  if (isset($region_map[$region])) {
    return $region_map[$region];
  }

  // Oh well, we tried. Put the block in the main content region.
  return 'content';
}