Update to Drupal 8.0.0 beta 14. For more information, see https://drupal.org/node/2544542
This commit is contained in:
parent
3b2511d96d
commit
81ccda77eb
2155 changed files with 54307 additions and 46870 deletions
|
|
@ -69,7 +69,7 @@ class ThemeLocalTask extends DeriverBase implements ContainerDeriverInterface {
|
|||
}
|
||||
// Default task!
|
||||
if ($default_theme == $theme_name) {
|
||||
$this->derivatives[$theme_name]['route_name'] = 'block.admin_display';
|
||||
$this->derivatives[$theme_name]['route_name'] = $base_plugin_definition['parent_id'];
|
||||
// Emulate default logic because without the base plugin id we can't
|
||||
// change the base_route.
|
||||
$this->derivatives[$theme_name]['weight'] = -10;
|
||||
|
|
|
|||
|
|
@ -8,17 +8,14 @@
|
|||
namespace Drupal\block\Plugin\DisplayVariant;
|
||||
|
||||
use Drupal\block\BlockRepositoryInterface;
|
||||
use Drupal\block\Event\BlockContextEvent;
|
||||
use Drupal\block\Event\BlockEvents;
|
||||
use Drupal\Core\Block\MainContentBlockPluginInterface;
|
||||
use Drupal\Core\Block\MessagesBlockPluginInterface;
|
||||
use Drupal\Core\Cache\CacheableMetadata;
|
||||
use Drupal\Core\Display\PageVariantInterface;
|
||||
use Drupal\Core\Entity\EntityTypeInterface;
|
||||
use Drupal\Core\Entity\EntityViewBuilderInterface;
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Drupal\Core\Display\VariantBase;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
|
||||
/**
|
||||
* Provides a page display variant that decorates the main content with blocks.
|
||||
|
|
@ -79,16 +76,13 @@ class BlockPageVariant extends VariantBase implements PageVariantInterface, Cont
|
|||
* The block repository.
|
||||
* @param \Drupal\Core\Entity\EntityViewBuilderInterface $block_view_builder
|
||||
* The block view builder.
|
||||
* @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher
|
||||
* The event dispatcher.
|
||||
* @param string[] $block_list_cache_tags
|
||||
* The Block entity type list cache tags.
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, BlockRepositoryInterface $block_repository, EntityViewBuilderInterface $block_view_builder, EventDispatcherInterface $dispatcher, array $block_list_cache_tags) {
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, BlockRepositoryInterface $block_repository, EntityViewBuilderInterface $block_view_builder, array $block_list_cache_tags) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||
$this->blockRepository = $block_repository;
|
||||
$this->blockViewBuilder = $block_view_builder;
|
||||
$this->dispatcher = $dispatcher;
|
||||
$this->blockListCacheTags = $block_list_cache_tags;
|
||||
}
|
||||
|
||||
|
|
@ -102,7 +96,6 @@ class BlockPageVariant extends VariantBase implements PageVariantInterface, Cont
|
|||
$plugin_definition,
|
||||
$container->get('block.repository'),
|
||||
$container->get('entity.manager')->getViewBuilder('block'),
|
||||
$container->get('event_dispatcher'),
|
||||
$container->get('entity.manager')->getDefinition('block')->getListCacheTags()
|
||||
);
|
||||
}
|
||||
|
|
@ -128,9 +121,9 @@ class BlockPageVariant extends VariantBase implements PageVariantInterface, Cont
|
|||
'tags' => $this->blockListCacheTags,
|
||||
],
|
||||
];
|
||||
$contexts = $this->getActiveBlockContexts();
|
||||
// Load all region content assigned via blocks.
|
||||
foreach ($this->blockRepository->getVisibleBlocksPerRegion($contexts) as $region => $blocks) {
|
||||
$cacheable_metadata_list = [];
|
||||
foreach ($this->blockRepository->getVisibleBlocksPerRegion($cacheable_metadata_list) as $region => $blocks) {
|
||||
/** @var $blocks \Drupal\block\BlockInterface[] */
|
||||
foreach ($blocks as $key => $block) {
|
||||
$block_plugin = $block->getPlugin();
|
||||
|
|
@ -172,17 +165,18 @@ class BlockPageVariant extends VariantBase implements PageVariantInterface, Cont
|
|||
];
|
||||
}
|
||||
|
||||
// The access results' cacheability is currently added to the top level of the
|
||||
// render array. This is done to prevent issues with empty regions being
|
||||
// displayed.
|
||||
// This would need to be changed to allow caching of block regions, as each
|
||||
// region must then have the relevant cacheable metadata.
|
||||
$merged_cacheable_metadata = CacheableMetadata::createFromRenderArray($build);
|
||||
foreach ($cacheable_metadata_list as $cacheable_metadata) {
|
||||
$merged_cacheable_metadata = $merged_cacheable_metadata->merge($cacheable_metadata);
|
||||
}
|
||||
$merged_cacheable_metadata->applyTo($build);
|
||||
|
||||
return $build;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of context objects to set on the blocks.
|
||||
*
|
||||
* @return \Drupal\Component\Plugin\Context\ContextInterface[]
|
||||
* An array of contexts to set on the blocks.
|
||||
*/
|
||||
protected function getActiveBlockContexts() {
|
||||
return $this->dispatcher->dispatch(BlockEvents::ACTIVE_CONTEXT, new BlockContextEvent())->getContexts();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,100 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\block\Plugin\migrate\process\d6\BlockPluginId.
|
||||
*/
|
||||
|
||||
namespace Drupal\block\Plugin\migrate\process\d6;
|
||||
|
||||
use Drupal\Core\Entity\EntityStorageInterface;
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Drupal\migrate\Entity\MigrationInterface;
|
||||
use Drupal\migrate\MigrateExecutableInterface;
|
||||
use Drupal\migrate\MigrateSkipRowException;
|
||||
use Drupal\migrate\Plugin\MigratePluginManager;
|
||||
use Drupal\migrate\ProcessPluginBase;
|
||||
use Drupal\migrate\Row;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* @MigrateProcessPlugin(
|
||||
* id = "d6_block_plugin_id"
|
||||
* )
|
||||
*/
|
||||
class BlockPluginId extends ProcessPluginBase implements ContainerFactoryPluginInterface {
|
||||
|
||||
/**
|
||||
* @var \Drupal\migrate\Plugin\MigratePluginManager
|
||||
*/
|
||||
protected $processPluginManager;
|
||||
|
||||
/**
|
||||
* @var \Drupal\Core\Entity\EntityStorageInterface
|
||||
*/
|
||||
protected $blockContentStorage;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, array $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, MigratePluginManager $process_plugin_manager) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||
$this->blockContentStorage = $storage;
|
||||
$this->migration = $migration;
|
||||
$this->processPluginManager = $process_plugin_manager;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) {
|
||||
$entity_manager = $container->get('entity.manager');
|
||||
return new static(
|
||||
$configuration,
|
||||
$plugin_id,
|
||||
$plugin_definition,
|
||||
$migration,
|
||||
$entity_manager->getDefinition('block_content') ? $entity_manager->getStorage('block_content') : NULL,
|
||||
$container->get('plugin.manager.migrate.process')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* Set the block plugin id.
|
||||
*/
|
||||
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
|
||||
if (is_array($value)) {
|
||||
list($module, $delta) = $value;
|
||||
switch ($module) {
|
||||
case 'aggregator':
|
||||
list($type, $id) = explode('-', $delta);
|
||||
if ($type == 'category') {
|
||||
// @TODO skip row.
|
||||
// throw new MigrateSkipRowException();
|
||||
}
|
||||
$value = 'aggregator_feed_block';
|
||||
break;
|
||||
case 'menu':
|
||||
$value = "system_menu_block:$delta";
|
||||
break;
|
||||
case 'block':
|
||||
if ($this->blockContentStorage) {
|
||||
$block_ids = $this->processPluginManager
|
||||
->createInstance('migration', array('migration' => 'd6_custom_block'), $this->migration)
|
||||
->transform($delta, $migrate_executable, $row, $destination_property);
|
||||
$value = 'block_content:' . $this->blockContentStorage->load($block_ids[0])->uuid();
|
||||
}
|
||||
else {
|
||||
throw new MigrateSkipRowException();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new MigrateSkipRowException();
|
||||
}
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\block\Plugin\migrate\process\d6\BlockRegion.
|
||||
*/
|
||||
|
||||
namespace Drupal\block\Plugin\migrate\process\d6;
|
||||
|
||||
use Drupal\migrate\MigrateExecutableInterface;
|
||||
use Drupal\migrate\ProcessPluginBase;
|
||||
use Drupal\migrate\Row;
|
||||
|
||||
/**
|
||||
* @MigrateProcessPlugin(
|
||||
* id = "d6_block_region"
|
||||
* )
|
||||
*/
|
||||
class BlockRegion extends ProcessPluginBase {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* Set the destination block region, based on the source region and theme as
|
||||
* well as the current destination default theme.
|
||||
*/
|
||||
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
|
||||
list($region, $source_theme, $destination_theme) = $value;
|
||||
|
||||
// Theme is the same on both source and destination, we will assume they
|
||||
// have the same regions.
|
||||
if (strtolower($source_theme) == strtolower($destination_theme)) {
|
||||
return $region;
|
||||
}
|
||||
|
||||
// If the source and destination theme are different, try to use the
|
||||
// mappings defined in the configuration.
|
||||
$region_map = $this->configuration['region_map'];
|
||||
if (isset($region_map[$region])) {
|
||||
return $region_map[$region];
|
||||
}
|
||||
|
||||
// Oh well, we tried. Put the block in the main content region.
|
||||
return 'content';
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\block\Plugin\migrate\process\d6\BlockSettings.
|
||||
*/
|
||||
|
||||
namespace Drupal\block\Plugin\migrate\process\d6;
|
||||
|
||||
use Drupal\migrate\MigrateExecutableInterface;
|
||||
use Drupal\migrate\ProcessPluginBase;
|
||||
use Drupal\migrate\Row;
|
||||
|
||||
/**
|
||||
* @MigrateProcessPlugin(
|
||||
* id = "d6_block_settings"
|
||||
* )
|
||||
*/
|
||||
class BlockSettings extends ProcessPluginBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* Set the block configuration.
|
||||
*/
|
||||
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
|
||||
list($plugin, $delta, $old_settings) = $value;
|
||||
$settings = array();
|
||||
switch ($plugin) {
|
||||
case 'aggregator_feed_block':
|
||||
list(, $id) = explode('-', $delta);
|
||||
$settings['block_count'] = $old_settings['aggregator']['item_count'];
|
||||
$settings['feed'] = $id;
|
||||
break;
|
||||
case 'book_navigation':
|
||||
$settings['block_mode'] = $old_settings['book']['block_mode'];
|
||||
break;
|
||||
case 'forum_active_block':
|
||||
case 'forum_new_block':
|
||||
$settings['block_count'] = $old_settings['forum']['block_num'];
|
||||
break;
|
||||
case 'statistics_popular_block':
|
||||
$settings['top_day_num'] = $old_settings['statistics']['statistics_block_top_day_num'];
|
||||
$settings['top_all_num'] = $old_settings['statistics']['statistics_block_top_all_num'];
|
||||
$settings['top_last_num'] = $old_settings['statistics']['statistics_block_top_last_num'];
|
||||
break;
|
||||
case 'views_block:who_s_new-block_1':
|
||||
$settings['items_per_page'] = $old_settings['user']['block_whois_new_count'];
|
||||
break;
|
||||
case 'views_block:who_s_online-who_s_online_block':
|
||||
$settings['items_per_page'] = $old_settings['user']['max_list_count'];
|
||||
break;
|
||||
}
|
||||
return $settings;
|
||||
}
|
||||
|
||||
}
|
||||
104
core/modules/block/src/Plugin/migrate/process/d6/BlockTheme.php
Normal file
104
core/modules/block/src/Plugin/migrate/process/d6/BlockTheme.php
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\block\Plugin\migrate\process\d6\BlockTheme.
|
||||
*/
|
||||
|
||||
namespace Drupal\block\Plugin\migrate\process\d6;
|
||||
|
||||
use Drupal\migrate\Entity\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;
|
||||
|
||||
/**
|
||||
* @MigrateProcessPlugin(
|
||||
* id = "d6_block_theme"
|
||||
* )
|
||||
*/
|
||||
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\Entity\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}
|
||||
*
|
||||
* Set the block theme, based on the current default theme.
|
||||
*/
|
||||
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
|
||||
list($theme, $d6_default_theme, $d6_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($d6_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($d6_admin_theme)) {
|
||||
return $this->themeConfig->get('admin');
|
||||
}
|
||||
|
||||
// We couldn't map it to a D8 theme so just return the incoming theme.
|
||||
return $theme;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\block\Plugin\migrate\process\d6\BlockVisibility.
|
||||
*/
|
||||
|
||||
namespace Drupal\block\Plugin\migrate\process\d6;
|
||||
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Drupal\migrate\MigrateExecutableInterface;
|
||||
use Drupal\migrate\ProcessPluginBase;
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate\Entity\MigrationInterface;
|
||||
use Drupal\migrate\Plugin\MigrateProcessInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* @MigrateProcessPlugin(
|
||||
* id = "d6_block_visibility"
|
||||
* )
|
||||
*/
|
||||
class BlockVisibility extends ProcessPluginBase implements ContainerFactoryPluginInterface {
|
||||
|
||||
/**
|
||||
* The migration plugin.
|
||||
*
|
||||
* @var \Drupal\migrate\Plugin\MigrateProcessInterface
|
||||
*/
|
||||
protected $migrationPlugin;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, MigrateProcessInterface $migration_plugin) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||
$this->migration = $migration;
|
||||
$this->migrationPlugin = $migration_plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@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('plugin.manager.migrate.process')->createInstance('migration', array('migration' => 'd6_user_role'), $migration)
|
||||
);
|
||||
}
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* Set the block visibility settings.
|
||||
*/
|
||||
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
|
||||
list($pages, $roles, $old_visibility) = $value;
|
||||
$visibility = array();
|
||||
|
||||
if (!empty($pages)) {
|
||||
$visibility['request_path']['pages'] = $pages;
|
||||
$visibility['request_path']['id'] = 'request_path';
|
||||
$visibility['request_path']['negate'] = !$old_visibility;
|
||||
}
|
||||
|
||||
if (!empty($roles)) {
|
||||
foreach ($roles as $key => $role_id) {
|
||||
$new_role = $this->migrationPlugin->transform($role_id, $migrate_executable, $row, $destination_property);
|
||||
$visibility['user_role']['roles'][$new_role] = $new_role;
|
||||
}
|
||||
$visibility['user_role']['id'] = 'user_role';
|
||||
$visibility['user_role']['context_mapping']['user'] = 'user.current_user';
|
||||
}
|
||||
return $visibility;
|
||||
}
|
||||
|
||||
}
|
||||
139
core/modules/block/src/Plugin/migrate/source/d6/Block.php
Normal file
139
core/modules/block/src/Plugin/migrate/source/d6/Block.php
Normal file
|
|
@ -0,0 +1,139 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\block\Plugin\migrate\source\d6\Block.
|
||||
*/
|
||||
|
||||
namespace Drupal\block\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* Drupal 6 block source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_block"
|
||||
* )
|
||||
*/
|
||||
class Block extends DrupalSqlBase {
|
||||
/**
|
||||
* The default theme name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $defaultTheme;
|
||||
|
||||
/**
|
||||
* The admin theme name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $adminTheme;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('blocks', 'b')
|
||||
->fields('b', array('bid', 'module', 'delta', 'theme', 'status', 'weight', 'region', 'visibility', 'pages', 'title', 'cache'))
|
||||
->orderBy('bid');
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function initializeIterator() {
|
||||
$this->defaultTheme = $this->variableGet('theme_default', 'Garland');
|
||||
$this->adminTheme = $this->variableGet('admin_theme', null);
|
||||
return parent::initializeIterator();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'bid' => $this->t('The block numeric identifier.'),
|
||||
'module' => $this->t('The module providing the block.'),
|
||||
'delta' => $this->t('The block\'s delta.'),
|
||||
'theme' => $this->t('Which theme the block is placed in.'),
|
||||
'status' => $this->t('Whether or not the block is enabled.'),
|
||||
'weight' => $this->t('Weight of the block for ordering within regions.'),
|
||||
'region' => $this->t('Region the block is placed in.'),
|
||||
'visibility' => $this->t('Visibility expression.'),
|
||||
'pages' => $this->t('Pages list.'),
|
||||
'title' => $this->t('Block title.'),
|
||||
'cache' => $this->t('Cache rule.'),
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
$row->setSourceProperty('default_theme', $this->defaultTheme);
|
||||
$row->setSourceProperty('admin_theme', $this->adminTheme);
|
||||
$module = $row->getSourceProperty('module');
|
||||
$delta = $row->getSourceProperty('delta');
|
||||
$roles = $this->select('blocks_roles', 'br')
|
||||
->fields('br', array('rid'))
|
||||
->condition('module', $module)
|
||||
->condition('delta', $delta)
|
||||
->execute()
|
||||
->fetchCol();
|
||||
$row->setSourceProperty('roles', $roles);
|
||||
$settings = array();
|
||||
// Contrib can use hook_migration_d6_block_prepare_row() to add similar
|
||||
// variables via $migration->getSource()->variableGet().
|
||||
switch ($module) {
|
||||
case 'aggregator':
|
||||
list($type, $id) = explode('-', $delta);
|
||||
if ($type == 'feed') {
|
||||
$item_count = $this->database->query('SELECT block FROM {aggregator_feed} WHERE fid = :fid', array(':fid' => $id))->fetchField();
|
||||
}
|
||||
else {
|
||||
$item_count = $this->database->query('SELECT block FROM {aggregator_category} WHERE cid = :cid', array(':cid' => $id))->fetchField();
|
||||
}
|
||||
$settings['aggregator']['item_count'] = $item_count;
|
||||
break;
|
||||
case 'book':
|
||||
$settings['book']['block_mode'] = $this->variableGet('book_block_mode', 'all pages');
|
||||
break;
|
||||
case 'forum':
|
||||
$settings['forum']['block_num'] = $this->variableGet('forum_block_num_'. $delta, 5);
|
||||
break;
|
||||
case 'statistics':
|
||||
foreach (array('statistics_block_top_day_num', 'statistics_block_top_all_num', 'statistics_block_top_last_num') as $name) {
|
||||
$settings['statistics'][$name] = $this->variableGet($name, 0);
|
||||
}
|
||||
break;
|
||||
case 'user':
|
||||
switch ($delta) {
|
||||
case 2:
|
||||
$settings['user']['block_whois_new_count'] = $this->variableGet('user_block_whois_new_count', 5);
|
||||
break;
|
||||
case 3:
|
||||
$settings['user']['block_seconds_online'] = $this->variableGet('user_block_seconds_online', 900);
|
||||
$settings['user']['max_list_count'] = $this->variableGet('user_block_max_list_count', 10);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
$row->setSourceProperty('settings', $settings);
|
||||
return parent::prepareRow($row);
|
||||
}
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['module']['type'] = 'string';
|
||||
$ids['delta']['type'] = 'string';
|
||||
$ids['theme']['type'] = 'string';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in a new issue