Issue #3442365 by catch, Sandeep Sanwale: Removed deprecated code in taxonomy module
parent
6d733889cc
commit
5a8f40dacd
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\taxonomy\Plugin\views\argument;
|
||||
|
||||
use Drupal\Core\Entity\EntityStorageInterface;
|
||||
use Drupal\Core\Entity\EntityRepositoryInterface;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
|
@ -25,28 +24,11 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
|||
class IndexTidDepth extends ArgumentPluginBase implements ContainerFactoryPluginInterface {
|
||||
use TaxonomyIndexDepthQueryTrait;
|
||||
|
||||
/**
|
||||
* @var \Drupal\Core\Entity\EntityStorageInterface
|
||||
*
|
||||
* @deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. There is no
|
||||
* replacement.
|
||||
*
|
||||
* @see https://www.drupal.org/node/3427843
|
||||
*/
|
||||
protected $termStorage;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, protected EntityStorageInterface|EntityRepositoryInterface $entityRepository) {
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, protected EntityRepositoryInterface $entityRepository) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||
|
||||
if ($entityRepository instanceof EntityStorageInterface) {
|
||||
// @phpstan-ignore-next-line
|
||||
$this->termStorage = $entityRepository;
|
||||
@trigger_error('Calling ' . __CLASS__ . '::__construct() with the $termStorage argument as \Drupal\Core\Entity\EntityStorageInterface is deprecated in drupal:10.3.0 and it will require Drupal\Core\Entity\EntityRepositoryInterface in drupal:11.0.0. See https://www.drupal.org/node/3427843', E_USER_DEPRECATED);
|
||||
$this->entityRepository = \Drupal::service('entity.repository');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -129,7 +111,7 @@ class IndexTidDepth extends ArgumentPluginBase implements ContainerFactoryPlugin
|
|||
if (!empty($term)) {
|
||||
return $term->label();
|
||||
}
|
||||
// TODO review text
|
||||
// @todo review text
|
||||
return $this->t('No name');
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
namespace Drupal\taxonomy\Plugin\views\argument;
|
||||
|
||||
use Drupal\Core\Entity\EntityRepositoryInterface;
|
||||
use Drupal\Core\Entity\EntityStorageInterface;
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Drupal\views\Attribute\ViewsArgument;
|
||||
use Drupal\views\Plugin\views\argument\NumericArgument;
|
||||
|
@ -19,27 +18,11 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
|||
)]
|
||||
class Taxonomy extends NumericArgument implements ContainerFactoryPluginInterface {
|
||||
|
||||
/**
|
||||
* @var \Drupal\Core\Entity\EntityStorageInterface
|
||||
*
|
||||
* @deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. There is no
|
||||
* replacement.
|
||||
*
|
||||
* @see https://www.drupal.org/node/3427843
|
||||
*/
|
||||
protected $termStorage;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, protected EntityStorageInterface|EntityRepositoryInterface $entityRepository) {
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, protected EntityRepositoryInterface $entityRepository) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||
if ($entityRepository instanceof EntityStorageInterface) {
|
||||
// @phpstan-ignore-next-line
|
||||
$this->termStorage = $this->entityRepository;
|
||||
@trigger_error('Calling ' . __CLASS__ . '::__construct() with the $termStorage argument as \Drupal\Core\Entity\EntityStorageInterface is deprecated in drupal:10.3.0 and it will require Drupal\Core\Entity\EntityRepositoryInterface in drupal:11.0.0. See https://www.drupal.org/node/3427843', E_USER_DEPRECATED);
|
||||
$this->entityRepository = \Drupal::service('entity.repository');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Drupal\Tests\taxonomy\Kernel\Views;
|
||||
|
||||
use Drupal\KernelTests\KernelTestBase;
|
||||
use Drupal\taxonomy_test\Plugin\views\argument\TaxonomyViewsArgumentTest;
|
||||
|
||||
/**
|
||||
* Tests deprecation messages in views argument plugins.
|
||||
*
|
||||
* @group taxonomy
|
||||
*/
|
||||
class ViewsArgumentDeprecationTest extends KernelTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $modules = [
|
||||
'system',
|
||||
'taxonomy',
|
||||
'taxonomy_test',
|
||||
'views',
|
||||
];
|
||||
|
||||
/**
|
||||
* Test the deprecation message in ViewsArgument plugin.
|
||||
*
|
||||
* @group legacy
|
||||
*/
|
||||
public function testDeprecation(): void {
|
||||
$this->expectDeprecation('Calling Drupal\taxonomy\Plugin\views\argument\Taxonomy::__construct() with the $termStorage argument as \Drupal\Core\Entity\EntityStorageInterface is deprecated in drupal:10.3.0 and it will require Drupal\Core\Entity\EntityRepositoryInterface in drupal:11.0.0. See https://www.drupal.org/node/3427843');
|
||||
$plugin = \Drupal::service('plugin.manager.views.argument')->createInstance('taxonomy_views_argument_test', []);
|
||||
$this->assertInstanceOf(TaxonomyViewsArgumentTest::class, $plugin);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue