class BlockTheme
Same name and namespace in other branches
- 11.x core/modules/block/src/Plugin/migrate/process/BlockTheme.php \Drupal\block\Plugin\migrate\process\BlockTheme
- 10 core/modules/block/src/Plugin/migrate/process/BlockTheme.php \Drupal\block\Plugin\migrate\process\BlockTheme
- 8.9.x core/modules/block/src/Plugin/migrate/process/BlockTheme.php \Drupal\block\Plugin\migrate\process\BlockTheme
Plugin annotation
@MigrateProcessPlugin(
id = "block_theme"
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements \Drupal\Component\Plugin\PluginInspectionInterface, \Drupal\Component\Plugin\DerivativeInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait extends \Drupal\Component\Plugin\PluginBase
- class \Drupal\migrate\ProcessPluginBase implements \Drupal\migrate\Plugin\MigrateProcessInterface extends \Drupal\Core\Plugin\PluginBase
- class \Drupal\block\Plugin\migrate\process\BlockTheme implements \Drupal\Core\Plugin\ContainerFactoryPluginInterface extends \Drupal\migrate\ProcessPluginBase
- class \Drupal\migrate\ProcessPluginBase implements \Drupal\migrate\Plugin\MigrateProcessInterface extends \Drupal\Core\Plugin\PluginBase
- class \Drupal\Core\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait extends \Drupal\Component\Plugin\PluginBase
Expanded class hierarchy of BlockTheme
File
-
core/
modules/ block/ src/ Plugin/ migrate/ process/ BlockTheme.php, line 18
Namespace
Drupal\block\Plugin\migrate\processView source
class BlockTheme extends ProcessPluginBase implements ContainerFactoryPluginInterface {
/**
* Contains the configuration object factory.
*
* @var \Drupal\Core\Config\ConfigFactoryInterface
*/
protected $configFactory;
/**
* Contains the system.theme configuration object.
*
* @var \Drupal\Core\Config\Config
*/
protected $themeConfig;
/**
* List of themes available on the destination.
*/
protected $themes;
/**
* Constructs a BlockTheme object.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin ID for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param \Drupal\migrate\Plugin\MigrationInterface $migration
* The migration entity.
* @param \Drupal\Core\Config\Config $theme_config
* The system.theme configuration factory object.
* @param array $themes
* The list of themes available on the destination.
*/
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;
}
/**
* {@inheritdoc}
*/
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());
}
/**
* {@inheritdoc}
*/
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
[$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 ($admin_theme && 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;
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.