BlockRegion.php in Zircon Profile 8
File
core/modules/block/src/Plugin/migrate/process/BlockRegion.php
View source
<?php
namespace Drupal\block\Plugin\migrate\process;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\Row;
use Symfony\Component\DependencyInjection\ContainerInterface;
class BlockRegion extends ProcessPluginBase implements ContainerFactoryPluginInterface {
protected $regions;
public function __construct(array $configuration, $plugin_id, $plugin_definition, array $regions) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->regions = $regions;
}
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
$regions = array();
foreach ($container
->get('theme_handler')
->listInfo() as $key => $theme) {
$regions[$key] = $theme->info['regions'];
}
return new static($configuration, $plugin_id, $plugin_definition, $regions);
}
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
list($region, $source_theme, $destination_theme) = $value;
if (strtolower($source_theme) == strtolower($destination_theme)) {
if (isset($this->regions[$destination_theme][$region])) {
return $region;
}
}
$region_map = $this->configuration['region_map'];
if (isset($region_map[$region])) {
return $region_map[$region];
}
return 'content';
}
}
Classes
Name |
Description |
BlockRegion |
Plugin annotation
@MigrateProcessPlugin(
id = "block_region"
) |