class BlockTheme in Drupal 9
Same name and namespace in other branches
- 8 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 DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\migrate\ProcessPluginBase implements MigrateProcessInterface
- class \Drupal\block\Plugin\migrate\process\BlockTheme implements ContainerFactoryPluginInterface
- class \Drupal\migrate\ProcessPluginBase implements MigrateProcessInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
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;
/**
* 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) {
list($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 (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;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
BlockTheme:: |
protected | property | Contains the configuration object factory. | |
BlockTheme:: |
protected | property | Contains the system.theme configuration object. | |
BlockTheme:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
|
BlockTheme:: |
public | function |
Performs the associated process. Overrides ProcessPluginBase:: |
|
BlockTheme:: |
public | function |
Constructs a BlockTheme object. Overrides PluginBase:: |
|
DependencySerializationTrait:: |
protected | property | ||
DependencySerializationTrait:: |
protected | property | ||
DependencySerializationTrait:: |
public | function | 2 | |
DependencySerializationTrait:: |
public | function | 2 | |
MessengerTrait:: |
protected | property | The messenger. | 27 |
MessengerTrait:: |
public | function | Gets the messenger. | 27 |
MessengerTrait:: |
public | function | Sets the messenger. | |
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
2 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
ProcessPluginBase:: |
public | function |
Indicates whether the returned value requires multiple handling. Overrides MigrateProcessInterface:: |
3 |
StringTranslationTrait:: |
protected | property | The string translation service. | 4 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |