Issue #3425492 by smustgrave, Keshav Patel, Spokje: Remove deprecated code from block module
parent
29b3847f9f
commit
d641102d8b
|
@ -73,13 +73,6 @@ class BlockForm extends EntityForm {
|
|||
*/
|
||||
protected $pluginFormFactory;
|
||||
|
||||
/**
|
||||
* The block repository service.
|
||||
*
|
||||
* @var \Drupal\block\BlockRepositoryInterface
|
||||
*/
|
||||
protected $blockRepository;
|
||||
|
||||
/**
|
||||
* Constructs a BlockForm object.
|
||||
*
|
||||
|
@ -95,21 +88,16 @@ class BlockForm extends EntityForm {
|
|||
* The theme handler.
|
||||
* @param \Drupal\Core\Plugin\PluginFormFactoryInterface $plugin_form_manager
|
||||
* The plugin form manager.
|
||||
* @param \Drupal\block\BlockRepositoryInterface|null $block_repository
|
||||
* @param \Drupal\block\BlockRepositoryInterface $blockRepository
|
||||
* The block repository service.
|
||||
*/
|
||||
public function __construct(EntityTypeManagerInterface $entity_type_manager, ExecutableManagerInterface $manager, ContextRepositoryInterface $context_repository, LanguageManagerInterface $language, ThemeHandlerInterface $theme_handler, PluginFormFactoryInterface $plugin_form_manager, ?BlockRepositoryInterface $block_repository = NULL) {
|
||||
if ($block_repository === NULL) {
|
||||
@trigger_error('Calling ' . __METHOD__ . ' without the $block_repository argument is deprecated in drupal:10.2.0 and will be required in drupal:11.0.0. See https://www.drupal.org/node/3333575', E_USER_DEPRECATED);
|
||||
$block_repository = \Drupal::service('block.repository');
|
||||
}
|
||||
public function __construct(EntityTypeManagerInterface $entity_type_manager, ExecutableManagerInterface $manager, ContextRepositoryInterface $context_repository, LanguageManagerInterface $language, ThemeHandlerInterface $theme_handler, PluginFormFactoryInterface $plugin_form_manager, protected BlockRepositoryInterface $blockRepository) {
|
||||
$this->storage = $entity_type_manager->getStorage('block');
|
||||
$this->manager = $manager;
|
||||
$this->contextRepository = $context_repository;
|
||||
$this->language = $language;
|
||||
$this->themeHandler = $theme_handler;
|
||||
$this->pluginFormFactory = $plugin_form_manager;
|
||||
$this->blockRepository = $block_repository;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,7 +4,6 @@ namespace Drupal\block\Plugin\migrate\process;
|
|||
|
||||
use Drupal\Core\Config\Config;
|
||||
use Drupal\migrate\MigrateExecutableInterface;
|
||||
use Drupal\migrate\Plugin\MigrationInterface;
|
||||
use Drupal\migrate\ProcessPluginBase;
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
|
@ -38,18 +37,13 @@ class BlockTheme extends ProcessPluginBase implements ContainerFactoryPluginInte
|
|||
* The plugin ID for the plugin instance.
|
||||
* @param mixed $plugin_definition
|
||||
* The plugin implementation definition.
|
||||
* @param \Drupal\Core\Config\Config|\Drupal\migrate\Plugin\MigrationInterface $theme_config
|
||||
* @param \Drupal\Core\Config\Config $theme_config
|
||||
* The system.theme configuration factory object.
|
||||
* @param string[]|\Drupal\Core\Config\Config $themes
|
||||
* @param array $themes
|
||||
* The list of themes available on the destination.
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, Config|MigrationInterface $theme_config, array|Config $themes) {
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, Config $theme_config, array $themes) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||
if ($theme_config instanceof MigrationInterface) {
|
||||
@trigger_error('Calling ' . __CLASS__ . '::__construct() with the $migration argument is deprecated in drupal:10.1.0 and is removed in drupal:11.0.0. See https://www.drupal.org/node/3323212', E_USER_DEPRECATED);
|
||||
$theme_config = func_get_arg(4);
|
||||
$themes = func_get_arg(5);
|
||||
}
|
||||
$this->themeConfig = $theme_config;
|
||||
$this->themes = $themes;
|
||||
}
|
||||
|
|
|
@ -33,23 +33,4 @@ trait AssertBlockAppearsTrait {
|
|||
$this->assertSession()->elementNotExists('xpath', "//div[@id = 'block-{$block->id()}']");
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a block instance on the page.
|
||||
*
|
||||
* @param \Drupal\block\Entity\Block $block
|
||||
* The block entity to find on the page.
|
||||
*
|
||||
* @return array
|
||||
* The result from the xpath query.
|
||||
*
|
||||
* @deprecated in drupal:9.5.0 and is removed from drupal:11.0.0. There is no
|
||||
* replacement.
|
||||
*
|
||||
* @see https://www.drupal.org/node/3293310
|
||||
*/
|
||||
protected function findBlockInstance(Block $block) {
|
||||
@trigger_error(__METHOD__ . '() is deprecated in drupal:9.5.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/node/3293310', E_USER_DEPRECATED);
|
||||
return $this->xpath('//div[@id = :id]', [':id' => 'block-' . $block->id()]);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Drupal\Tests\block\Unit\Plugin\migrate\process;
|
||||
|
||||
use Drupal\block\Plugin\migrate\process\BlockTheme;
|
||||
use Drupal\Core\Config\Config;
|
||||
use Drupal\migrate\Plugin\MigrationInterface;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
|
||||
/**
|
||||
* Tests the deprecation notices of the block theme.
|
||||
*
|
||||
* @group legacy
|
||||
*/
|
||||
class BlockThemeDeprecationTest extends UnitTestCase {
|
||||
|
||||
/**
|
||||
* Tests the deprecation in the constructor.
|
||||
*/
|
||||
public function testConstructorDeprecation(): void {
|
||||
$this->expectDeprecation('Calling Drupal\block\Plugin\migrate\process\BlockTheme::__construct() with the $migration argument is deprecated in drupal:10.1.0 and is removed in drupal:11.0.0. See https://www.drupal.org/node/3323212');
|
||||
$migration = $this->prophesize(MigrationInterface::class);
|
||||
$config = $this->prophesize(Config::class);
|
||||
new BlockTheme(
|
||||
[],
|
||||
'',
|
||||
[],
|
||||
$migration->reveal(),
|
||||
$config->reveal(),
|
||||
[]
|
||||
);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue