Skip to content

Commit d292c94

Browse files
LOBsTerrsimonf7
andauthored
Remove deprecated code. (#4324)
* Feat: replace system_rebuild_module_data() * Feat: replace REQUEST_TIME * Feat: replace format_date() * Feat: remove update_fix_compatibility() https://www.drupal.org/node/3026100 * Feat: replace user_load() * Feat: replace CONFIG_SYNC_DIRECTORY * Feat: replace drupal_get_profile() * Feat: replace config_get_config_directory() * Feat: replace prepareLegacyRequest() * Feat: replace ResourcePluginManager->getInstance() * Feat: replace Drupal\simpletest\TestDiscovery * Feat: replace db_insert() * Fix: module installed detection using module_handler service * Remove the interaction part, because in Drupal 9 we have only one config folder. * Use imports of the classes instead of full classified name of the class. * Use dependency injection instead of direct call of \Drupal::service. * Use dependency injection instead of direct call of \Drupal::service in Uninstall command class. * Move vars outside loops. * Use dependency injection instead of direct call of \Drupal::service in Manager class. * Set Drupal console version 1.9.8. Co-authored-by: Simon <s.foster@tabs-software.co.uk>
1 parent 21342d8 commit d292c94

34 files changed

+109
-81
lines changed

config/services/debug.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ services:
6767
- { name: drupal.command }
6868
console.module_debug:
6969
class: Drupal\Console\Command\Debug\ModuleCommand
70-
arguments: ['@console.configuration_manager', '@console.site']
70+
arguments: ['@console.configuration_manager', '@console.site', '@extension.list.module']
7171
tags:
7272
- { name: drupal.command }
7373
console.image_styles_debug:

config/services/module.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ services:
2121
- { name: drupal.command }
2222
console.module_uninstall:
2323
class: Drupal\Console\Command\Module\UninstallCommand
24-
arguments: ['@console.site','@module_installer', '@console.chain_queue', '@config.factory', '@console.extension_manager']
24+
arguments: ['@console.site','@module_installer', '@console.chain_queue', '@config.factory', '@console.extension_manager', '@extension.list.module']
2525
tags:
2626
- { name: drupal.command }
2727
console.module_update:

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.7';
28+
const VERSION = '1.9.8';
2929

3030
public function __construct(ContainerInterface $container)
3131
{

src/Command/Config/DiffCommand.php

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
use Drupal\Core\Config\FileStorage;
1010
use Drupal\Core\Config\StorageComparer;
11+
use Drupal\Core\Site\Settings;
1112
use Symfony\Component\Console\Input\InputArgument;
1213
use Symfony\Component\Console\Input\InputInterface;
1314
use Symfony\Component\Console\Input\InputOption;
@@ -78,36 +79,13 @@ protected function configure()
7879
)->setAliases(['cdi']);
7980
}
8081

81-
/**
82-
* {@inheritdoc}
83-
*/
84-
protected function interact(InputInterface $input, OutputInterface $output)
85-
{
86-
global $config_directories;
87-
88-
$directory = $input->getArgument('directory');
89-
if (!$directory) {
90-
$directory = $this->getIo()->choice(
91-
$this->trans('commands.config.diff.questions.directories'),
92-
$config_directories,
93-
CONFIG_SYNC_DIRECTORY
94-
);
95-
96-
$input->setArgument('directory', $config_directories[$directory]);
97-
}
98-
}
99-
10082
/**
10183
* {@inheritdoc}
10284
*/
10385
protected function execute(InputInterface $input, OutputInterface $output)
10486
{
105-
global $config_directories;
106-
$directory = $input->getArgument('directory') ?: CONFIG_SYNC_DIRECTORY;
107-
if (array_key_exists($directory, $config_directories)) {
108-
$directory = $config_directories[$directory];
109-
}
110-
$source_storage = new FileStorage($directory);
87+
$config_directory = Settings::get('config_sync_directory');
88+
$source_storage = new FileStorage($config_directory);
11189

11290
if ($input->getOption('reverse')) {
11391
$config_comparer = new StorageComparer($source_storage, $this->configStorage, $this->configManager);

src/Command/Config/ExportCommand.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Drupal\Component\Serialization\Yaml;
1212
use Drupal\Core\Config\ConfigManagerInterface;
1313
use Drupal\Core\Config\StorageInterface;
14+
use Drupal\Core\Site\Settings;
1415
use Symfony\Component\Console\Input\InputInterface;
1516
use Symfony\Component\Console\Input\InputOption;
1617
use Symfony\Component\Console\Output\OutputInterface;
@@ -83,7 +84,7 @@ protected function interact(InputInterface $input, OutputInterface $output)
8384
if (!$input->getOption('directory')) {
8485
$directory = $this->getIo()->ask(
8586
$this->trans('commands.config.export.questions.directory'),
86-
config_get_config_directory(CONFIG_SYNC_DIRECTORY)
87+
Settings::get('config_sync_directory')
8788
);
8889
$input->setOption('directory', $directory);
8990
}
@@ -102,7 +103,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
102103
$drupal_root = $this->drupalFinder->getComposerRoot();
103104

104105
if (!$directory) {
105-
$directory = config_get_config_directory(CONFIG_SYNC_DIRECTORY);
106+
$directory = Settings::get('config_sync_directory') ;
106107
}
107108

108109
$fileSystem = new Filesystem();

src/Command/Config/ExportSingleCommand.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace Drupal\Console\Command\Config;
99

1010
use Drupal\Component\Serialization\Yaml;
11+
use Drupal\Core\Site\Settings;
1112
use Symfony\Component\Console\Input\InputArgument;
1213
use Symfony\Component\Console\Input\InputInterface;
1314
use Symfony\Component\Console\Input\InputOption;
@@ -304,7 +305,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
304305
return 0;
305306
}
306307

307-
$directory = $directory_copy = config_get_config_directory(CONFIG_SYNC_DIRECTORY);
308+
$directory = $directory_copy = Settings::get('config_sync_directory') ;
308309
if (!is_dir($directory)) {
309310
if ($value) {
310311
$directory = $directory_copy .'/' . str_replace('.', '/', $value);

src/Command/Config/ImportCommand.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
namespace Drupal\Console\Command\Config;
88

9+
use Drupal\Core\Site\Settings;
910
use Symfony\Component\Console\Input\InputOption;
1011
use Symfony\Component\Console\Input\InputInterface;
1112
use Symfony\Component\Console\Output\OutputInterface;
@@ -87,7 +88,7 @@ protected function interact(InputInterface $input, OutputInterface $output)
8788
if (!$input->getOption('directory')) {
8889
$directory = $this->getIo()->ask(
8990
$this->trans('commands.config.import.questions.directory'),
90-
config_get_config_directory(CONFIG_SYNC_DIRECTORY)
91+
Settings::get('config_sync_directory')
9192
);
9293
$input->setOption('directory', $directory);
9394
}

src/Command/Create/CommentsCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ protected function interact(InputInterface $input, OutputInterface $output)
130130
protected function execute(InputInterface $input, OutputInterface $output)
131131
{
132132
$nodeId = $input->getArgument('node-id')?:1;
133-
$node = \Drupal\node\Entity\Node::load($nodeId);
133+
$node = Node::load($nodeId);
134134
if (empty($node)) {
135135
throw new \InvalidArgumentException(
136136
$this->trans(

src/Command/Cron/ExecuteCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
108108
}
109109
}
110110

111-
$this->state->set('system.cron_last', REQUEST_TIME);
111+
$this->state->set('system.cron_last', \Drupal::time()->getRequestTime());
112112
$this->lock->release('cron');
113113

114114
$this->getIo()->success($this->trans('commands.cron.execute.messages.success'));

src/Command/Debug/ModuleCommand.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Drupal\Console\Core\Command\Command;
1515
use Drupal\Console\Utils\Site;
1616
use Drupal\Console\Core\Utils\ConfigurationManager;
17+
use Drupal\Core\Extension\ModuleExtensionList;
1718

1819
class ModuleCommand extends Command
1920
{
@@ -27,18 +28,31 @@ class ModuleCommand extends Command
2728
*/
2829
protected $site;
2930

31+
/**
32+
* @var Site
33+
*/
34+
protected $module;
35+
36+
/**
37+
* @var Drupal\Core\Extension\ModuleExtensionList
38+
*/
39+
protected $extensionList;
40+
3041
/**
3142
* ChainDebugCommand constructor.
3243
*
3344
* @param ConfigurationManager $configurationManager
3445
* @param Site $site
46+
* @param ModuleExtensionList $extensionList
3547
*/
3648
public function __construct(
3749
ConfigurationManager $configurationManager,
38-
Site $site
50+
Site $site,
51+
ModuleExtensionList $extensionList
3952
) {
4053
$this->configurationManager = $configurationManager;
4154
$this->site = $site;
55+
$this->extensionList = $extensionList;
4256
parent::__construct();
4357
}
4458

@@ -117,7 +131,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
117131
private function getModules($status, $type, $modules) {
118132

119133
$result = [];
120-
$modulesData = system_rebuild_module_data();
134+
$modulesData = $this->extensionList->reset()->getList();
121135

122136
if(!$modules) {
123137
$modules = array_keys($modulesData) ;

0 commit comments

Comments
 (0)