Skip to content

Commit fccd9f4

Browse files
authored
Drupal 9 Support (#4259)
* update symfony dependencies * update deprecation in UserDebug commands * update deprecation in RestEnable command * update Statistics command * update UserDelete command * update views commands * remove deprecations * update DC version
1 parent 04522b6 commit fccd9f4

File tree

15 files changed

+46
-93
lines changed

15 files changed

+46
-93
lines changed

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,17 @@
3636
"docs": "https://docs.drupalconsole.com/"
3737
},
3838
"require": {
39-
"php": "^5.5.9 || ^7.0",
39+
"php": ">=7.0.8",
4040
"alchemy/zippy": "~0.4",
4141
"composer/installers": "~1.0",
4242
"doctrine/annotations": "^1.2",
4343
"doctrine/collections": "^1.3",
44-
"drupal/console-core": "1.9.4",
44+
"drupal/console-core": "1.9.5",
4545
"drupal/console-extend-plugin": "~0",
4646
"psy/psysh": "0.6.* || ~0.8",
47-
"symfony/css-selector": "~2.8|~3.0",
48-
"symfony/dom-crawler": "~2.8|~3.0",
49-
"symfony/http-foundation": "~2.8|~3.0"
47+
"symfony/css-selector": "~3.0|~4.0",
48+
"symfony/dom-crawler": "~3.0|~4.0",
49+
"symfony/http-foundation": "~3.0|~4.0"
5050
},
5151
"suggest": {
5252
"symfony/thanks": "Thank your favorite PHP projects on GitHub using the CLI",

config/services/debug.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ services:
2323
- { name: drupal.command }
2424
console.user_debug:
2525
class: Drupal\Console\Command\Debug\UserCommand
26-
arguments: ['@entity_type.manager','@entity.query', '@console.drupal_api']
26+
arguments: ['@entity_type.manager', '@console.drupal_api']
2727
tags:
2828
- { name: drupal.command }
2929
console.views_debug:

config/services/rest.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,5 @@ services:
1010
- '@entity_type.manager'
1111
- '@?plugin.manager.rest'
1212
- '@authentication_collector'
13-
- '@entity.manager'
1413
tags:
1514
- { name: drupal.command }

config/services/site.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ services:
1616
- { name: drupal.command }
1717
console.site_statistics:
1818
class: Drupal\Console\Command\Site\StatisticsCommand
19-
arguments: ['@console.drupal_api', '@entity.query', '@console.extension_manager', '@module_handler']
19+
arguments: ['@console.drupal_api', '@entity_type.manager', '@console.extension_manager', '@module_handler']
2020
tags:
2121
- { name: drupal.command }
2222
console.site_status:

config/services/user.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
services:
22
console.user_delete:
33
class: Drupal\Console\Command\User\DeleteCommand
4-
arguments: ['@entity_type.manager','@entity.query', '@console.drupal_api']
4+
arguments: ['@entity_type.manager', '@console.drupal_api']
55
tags:
66
- { name: drupal.command }
77
console.user_login_clear_attempts:

config/services/views.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
services:
22
console.views_disable:
33
class: Drupal\Console\Command\Views\DisableCommand
4-
arguments: ['@entity_type.manager', '@entity.query']
4+
arguments: ['@entity_type.manager']
55
tags:
66
- { name: drupal.command }
77
console.views_enable:
88
class: Drupal\Console\Command\Views\EnableCommand
9-
arguments: ['@entity_type.manager', '@entity.query']
9+
arguments: ['@entity_type.manager']
1010
tags:
1111
- { name: drupal.command }

src/Application.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Application extends BaseApplication
2525
/**
2626
* @var string
2727
*/
28-
const VERSION = '1.9.4';
28+
const VERSION = '1.9.5';
2929

3030
public function __construct(ContainerInterface $container)
3131
{

src/Command/Debug/UserCommand.php

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use Symfony\Component\Console\Output\OutputInterface;
1313
use Drupal\Console\Core\Command\Command;
1414
use Drupal\Core\Entity\EntityTypeManagerInterface;
15-
use Drupal\Core\Entity\Query\QueryFactory;
1615
use Drupal\Console\Utils\DrupalApi;
1716

1817
/**
@@ -27,11 +26,6 @@ class UserCommand extends Command
2726
*/
2827
protected $entityTypeManager;
2928

30-
/**
31-
* @var QueryFactory
32-
*/
33-
protected $entityQuery;
34-
3529
/**
3630
* @var DrupalApi
3731
*/
@@ -41,16 +35,13 @@ class UserCommand extends Command
4135
* DebugCommand constructor.
4236
*
4337
* @param EntityTypeManagerInterface $entityTypeManager
44-
* @param QueryFactory $entityQuery
4538
* @param DrupalApi $drupalApi
4639
*/
4740
public function __construct(
4841
EntityTypeManagerInterface $entityTypeManager,
49-
QueryFactory $entityQuery,
5042
DrupalApi $drupalApi
5143
) {
5244
$this->entityTypeManager = $entityTypeManager;
53-
$this->entityQuery = $entityQuery;
5445
$this->drupalApi = $drupalApi;
5546
parent::__construct();
5647
}
@@ -110,7 +101,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
110101
$userStorage = $this->entityTypeManager->getStorage('user');
111102
$systemRoles = $this->drupalApi->getRoles();
112103

113-
$query = $this->entityQuery->get('user');
104+
$query = $this->entityTypeManager->getStorage('user')->getQuery();
114105
$query->condition('uid', 0, '>');
115106
$query->sort('uid');
116107

src/Command/Rest/EnableCommand.php

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use Drupal\Console\Command\Shared\RestTrait;
1717
use Drupal\rest\Plugin\Type\ResourcePluginManager;
1818
use Drupal\Core\Authentication\AuthenticationCollector;
19-
use Drupal\Core\Entity\EntityManager;
2019
use Drupal\Core\Entity\EntityTypeManagerInterface;
2120

2221
/**
@@ -44,32 +43,21 @@ class EnableCommand extends ContainerAwareCommand
4443
*/
4544
protected $authenticationCollector;
4645

47-
/**
48-
* The entity manager.
49-
*
50-
* @var EntityManager
51-
*/
52-
protected $entityManager;
53-
5446
/**
5547
* EnableCommand constructor.
5648
*
5749
* @param EntityTypeManagerInterface $entityTypeManager
5850
* @param ResourcePluginManager $pluginManagerRest
5951
* @param AuthenticationCollector $authenticationCollector
60-
* @param EntityManager $entity_manager
61-
* The entity manager.
6252
*/
6353
public function __construct(
6454
EntityTypeManagerInterface $entityTypeManager,
6555
ResourcePluginManager $pluginManagerRest,
66-
AuthenticationCollector $authenticationCollector,
67-
EntityManager $entity_manager
56+
AuthenticationCollector $authenticationCollector
6857
) {
6958
$this->entityTypeManager = $entityTypeManager;
7059
$this->pluginManagerRest = $pluginManagerRest;
7160
$this->authenticationCollector = $authenticationCollector;
72-
$this->entityManager = $entity_manager;
7361
parent::__construct();
7462
}
7563

@@ -146,9 +134,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
146134
);
147135

148136
$format_resource_id = str_replace(':', '.', $resource_id);
149-
$config = $this->entityManager->getStorage('rest_resource_config')->load($format_resource_id);
137+
$config = $this->entityTypeManager->getStorage('rest_resource_config')->load($format_resource_id);
150138
if (!$config) {
151-
$config = $this->entityManager->getStorage('rest_resource_config')->create(
139+
$config = $this->entityTypeManager->getStorage('rest_resource_config')->create(
152140
[
153141
'id' => $format_resource_id,
154142
'granularity' => RestResourceConfigInterface::METHOD_GRANULARITY,

src/Command/Site/StatisticsCommand.php

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
use Drupal\Console\Core\Command\Command;
1111
use Drupal\Console\Extension\Manager;
1212
use Drupal\Console\Utils\DrupalApi;
13-
use Drupal\Core\Entity\Query\QueryFactory;
1413
use Drupal\Core\Extension\ModuleHandlerInterface;
1514
use Symfony\Component\Console\Input\InputInterface;
1615
use Symfony\Component\Console\Output\OutputInterface;
16+
use Drupal\Core\Entity\EntityTypeManagerInterface;
1717

1818
/**
1919
* Class StatisticsCommand
@@ -27,11 +27,6 @@ class StatisticsCommand extends Command
2727
*/
2828
protected $drupalApi;
2929

30-
/**
31-
* @var QueryFactory
32-
*/
33-
protected $entityQuery;
34-
3530
/**
3631
* @var Manager
3732
*/
@@ -42,22 +37,26 @@ class StatisticsCommand extends Command
4237
*/
4338
protected $moduleHandler;
4439

40+
/**
41+
* @var EntityTypeManagerInterface
42+
*/
43+
protected $entityTypeManager;
44+
4545
/**
4646
* StatisticsCommand constructor.
4747
*
4848
* @param DrupalApi $drupalApi
49-
* @param QueryFactory $entityQuery ;
5049
* @param Manager $extensionManager
5150
* @param ModuleHandlerInterface $moduleHandler
5251
*/
5352
public function __construct(
5453
DrupalApi $drupalApi,
55-
QueryFactory $entityQuery,
54+
EntityTypeManagerInterface $entityTypeManager,
5655
Manager $extensionManager,
5756
ModuleHandlerInterface $moduleHandler
5857
) {
5958
$this->drupalApi = $drupalApi;
60-
$this->entityQuery = $entityQuery;
59+
$this->entityTypeManager = $entityTypeManager;
6160
$this->extensionManager = $extensionManager;
6261
$this->moduleHandler = $moduleHandler;
6362
parent::__construct();
@@ -131,7 +130,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
131130

132131
private function getEntitiesCount($entity_type, $condition = [])
133132
{
134-
$entityQuery = $this->entityQuery->get($entity_type)->count();
133+
$entityQuery = $this->entityTypeManager->getStorage($entity_type)->getQuery()->count();
135134
if (!empty($condition)) {
136135
$entityQuery->condition($condition['name'], $condition['value'], $condition['condition']);
137136
}

0 commit comments

Comments
 (0)