Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions commands/web/drupal
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use DrupalCoreDev\Command\LintPhpCsCommand;
use DrupalCoreDev\Command\LintPhpStanCommand;
use DrupalCoreDev\Command\ModuleInstallCommand;
use DrupalCoreDev\Command\TestBrowserCommand;
use DrupalCoreDev\Command\TestExtensionsCommand;
use DrupalCoreDev\Command\TestCommand;
use DrupalCoreDev\Command\UninstallCommand;
use Symfony\Component\Console\Application;
Expand All @@ -46,6 +47,7 @@ $application->add(new CacheCommand($loader));
$application->add(new AdminLoginCommand($loader));
$application->add(new GenerateTheme());
$application->add(new TestCommand());
$application->add(new TestExtensionsCommand());
$application->add(new TestBrowserCommand());
$application->add(new LintPhpCsCommand());
$application->add(new LintPhpStanCommand());
Expand Down
2 changes: 2 additions & 0 deletions core-dev/src/Command/ModuleInstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$module_installer = \Drupal::service('module_installer');
assert($module_installer instanceof ModuleInstallerInterface);
$module_installer->install($modules);
$kernel = \Drupal::service('kernel');
$kernel->rebuildContainer();
}
return 0;
}
Expand Down
65 changes: 65 additions & 0 deletions core-dev/src/Command/TestExtensionsCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php
#ddev-generated

namespace DrupalCoreDev\Command;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Process\Process;

class TestExtensionsCommand extends Command {
/**
* {@inheritdoc}
*/
protected function configure(): void {
$this->setName('test:extensions-enable')
->setDescription('Allow test modules and themes to be installed');
}

/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output): int {
$io = new SymfonyStyle($input, $output);
$setting = "\$settings['extension_discovery_scan_tests'] = TRUE;\n";
$file = __DIR__ . '/../../../../sites/default/settings.php';
$data = file_get_contents($file);
if (str_contains($data, $setting)) {
return 0;
}

$mode = null;
if (!is_writable($file)) {
try {
$stat = stat($file);
chmod($file, 0744);
}
catch (\Error $e) {
$io->getErrorStyle()->error("Could not set $file to writeable");
return 1;
}
$mode = $stat['mode'] & 000777;
}


file_put_contents($file, $setting, FILE_APPEND);
$output->writeln('extension_discovery_scan_tests enabled in settings.php');

if (!is_null($mode)) {
// Reverse the array of unhardened paths because we want to change the
// child item before the parent item.
try {
chmod($file, $mode);
}
catch (\Error $e) {
$io->getErrorStyle()->error("Unable to reharden permissions for $file");
return 1;
}
}

return 0;
}
}
1 change: 1 addition & 0 deletions install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ project_files:
- core-dev/src/Command/CacheCommand.php
- core-dev/src/Command/TestCommand.php
- core-dev/src/Command/TestBrowserCommand.php
- core-dev/src/Command/TestExtensionsCommand.php
- core-dev/src/Command/UninstallCommand.php
- core-dev/src/Command/LintPhpCsCommand.php
- core-dev/src/Command/LintPhpStanCommand.php
Expand Down