BlockTheme.php in Drupal 10
File
core/modules/block/src/Plugin/migrate/process/BlockTheme.php
View source
<?php
namespace Drupal\block\Plugin\migrate\process;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\Row;
use Drupal\Core\Config\Config;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class BlockTheme extends ProcessPluginBase implements ContainerFactoryPluginInterface {
protected $configFactory;
protected $themeConfig;
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, Config $theme_config, array $themes) {
parent::__construct($configuration, $plugin_id, $plugin_definition, $migration);
$this->themeConfig = $theme_config;
$this->themes = $themes;
}
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) {
return new static($configuration, $plugin_id, $plugin_definition, $migration, $container
->get('config.factory')
->get('system.theme'), $container
->get('theme_handler')
->listInfo());
}
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
[
$theme,
$default_theme,
$admin_theme,
] = $value;
if (isset($this->themes[$theme])) {
return $theme;
}
if (strtolower($theme) == strtolower($default_theme)) {
return $this->themeConfig
->get('default');
}
if ($admin_theme && strtolower($theme) == strtolower($admin_theme)) {
return $this->themeConfig
->get('admin');
}
return $theme;
}
}
Classes
Name |
Description |
BlockTheme |
Plugin annotation
@MigrateProcessPlugin(
id = "block_theme"
) |