function BlockTheme::transform

Same name in other branches
  1. 8.9.x core/modules/block/src/Plugin/migrate/process/BlockTheme.php \Drupal\block\Plugin\migrate\process\BlockTheme::transform()
  2. 10 core/modules/block/src/Plugin/migrate/process/BlockTheme.php \Drupal\block\Plugin\migrate\process\BlockTheme::transform()
  3. 11.x core/modules/block/src/Plugin/migrate/process/BlockTheme.php \Drupal\block\Plugin\migrate\process\BlockTheme::transform()

Overrides ProcessPluginBase::transform

File

core/modules/block/src/Plugin/migrate/process/BlockTheme.php, line 78

Class

BlockTheme
Plugin annotation @MigrateProcessPlugin( id = "block_theme" )

Namespace

Drupal\block\Plugin\migrate\process

Code

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.