class BlockTheme
Determines the theme to use for a block.
Attributes
#[MigrateProcess('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\DependencyInjection\AutowiredInstanceTrait, \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\DependencyInjection\AutowiredInstanceTrait, \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 16 
Namespace
Drupal\block\Plugin\migrate\processView source
class BlockTheme extends ProcessPluginBase implements ContainerFactoryPluginInterface {
  
  /**
   * Contains the system.theme configuration object.
   */
  protected Config $themeConfig;
  
  /**
   * List of themes available on the destination.
   *
   * @var string[]
   */
  protected array $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\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, Config $theme_config, array $themes) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
    $this->themeConfig = $theme_config;
    $this->themes = $themes;
  }
  
  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    return new static($configuration, $plugin_id, $plugin_definition, $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;
  }
}Members
| Title Sort descending | Deprecated | Modifiers | Object type | Summary | Overriden Title | Overrides | 
|---|---|---|---|---|---|---|
| AutowiredInstanceTrait::createInstanceAutowired | public static | function | Instantiates a new instance of the implementing class using autowiring. | |||
| BlockTheme::$themeConfig | protected | property | Contains the system.theme configuration object. | |||
| BlockTheme::$themes | protected | property | List of themes available on the destination. | |||
| BlockTheme::create | public static | function | Instantiates a new instance of the implementing class using autowiring. | Overrides PluginBase::create | ||
| BlockTheme::transform | public | function | Performs the associated process. | Overrides ProcessPluginBase::transform | ||
| BlockTheme::__construct | public | function | Constructs a BlockTheme object. | Overrides PluginBase::__construct | ||
| DependencySerializationTrait::$_entityStorages | protected | property | An array of entity type IDs keyed by the property name of their storages. | |||
| DependencySerializationTrait::$_serviceIds | protected | property | An array of service IDs keyed by property name used for serialization. | |||
| DependencySerializationTrait::__sleep | public | function | 2 | |||
| DependencySerializationTrait::__wakeup | public | function | 2 | |||
| MessengerTrait::$messenger | protected | property | The messenger. | 25 | ||
| MessengerTrait::messenger | public | function | Gets the messenger. | 25 | ||
| MessengerTrait::setMessenger | public | function | Sets the messenger. | |||
| PluginBase::$configuration | protected | property | Configuration information passed into the plugin. | 1 | ||
| PluginBase::$pluginDefinition | protected | property | The plugin implementation definition. | 1 | ||
| PluginBase::$pluginId | protected | property | The plugin ID. | |||
| PluginBase::DERIVATIVE_SEPARATOR | constant | A string which is used to separate base plugin IDs from the derivative ID. | ||||
| PluginBase::getBaseId | public | function | Overrides DerivativeInspectionInterface::getBaseId | |||
| PluginBase::getDerivativeId | public | function | Overrides DerivativeInspectionInterface::getDerivativeId | |||
| PluginBase::getPluginDefinition | public | function | Overrides PluginInspectionInterface::getPluginDefinition | 2 | ||
| PluginBase::getPluginId | public | function | Overrides PluginInspectionInterface::getPluginId | |||
| PluginBase::isConfigurable | Deprecated | public | function | Determines if the plugin is configurable. | ||
| ProcessPluginBase::$stopPipeline | protected | property | Determines if processing of the pipeline is stopped. | |||
| ProcessPluginBase::isPipelineStopped | public | function | Determines if the pipeline should stop processing. | Overrides MigrateProcessInterface::isPipelineStopped | ||
| ProcessPluginBase::multiple | public | function | Indicates whether the returned value requires multiple handling. | Overrides MigrateProcessInterface::multiple | 3 | |
| ProcessPluginBase::reset | public | function | Resets the internal data of a plugin. | Overrides MigrateProcessInterface::reset | ||
| ProcessPluginBase::stopPipeline | protected | function | Stops pipeline processing after this plugin finishes. | |||
| StringTranslationTrait::$stringTranslation | protected | property | The string translation service. | 3 | ||
| StringTranslationTrait::formatPlural | protected | function | Formats a string containing a count of items. | |||
| StringTranslationTrait::getNumberOfPlurals | protected | function | Returns the number of plurals supported by a given language. | |||
| StringTranslationTrait::getStringTranslation | protected | function | Gets the string translation service. | |||
| StringTranslationTrait::setStringTranslation | public | function | Sets the string translation service to use. | 2 | ||
| StringTranslationTrait::t | protected | function | Translates a string to the current language or to a given language. | 1 | 
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
