BlockRegion.php in Drupal 10
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\Plugin\migrate\process\StaticMap;
use Drupal\migrate\Row;
use Symfony\Component\DependencyInjection\ContainerInterface;
class BlockRegion extends StaticMap 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 = [];
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) {
[
$source_theme,
$destination_theme,
$region,
] = $value;
if (strtolower($source_theme) == strtolower($destination_theme)) {
if (isset($this->regions[$destination_theme][$region])) {
return $region;
}
}
return parent::transform($value, $migrate_executable, $row, $destination_property);
}
}
Classes
Name |
Description |
BlockRegion |
Plugin annotation
@MigrateProcessPlugin(
id = "block_region"
) |