Skip to content
Permalink
Browse files

[database] Run database commands without Drupal bootstrap (#4038)

  • Loading branch information...
harold20 authored and enzolutions committed May 15, 2019
1 parent 62faf57 commit 5fdb4881b6c6b23b1b62e8e9c4601d46d5b74a5d
@@ -1,21 +1,8 @@
services:
console.database_add:
class: Drupal\Console\Command\Database\AddCommand
arguments: ['@console.database_settings_generator']
tags:
- { name: drupal.command }
console.database_client:
class: Drupal\Console\Command\Database\ClientCommand
tags:
- { name: drupal.command }
console.database_query:
class: Drupal\Console\Command\Database\QueryCommand
tags:
- { name: drupal.command }
console.database_connect:
class: Drupal\Console\Command\Database\ConnectCommand
tags:
- { name: drupal.command }
console.database_drop:
class: Drupal\Console\Command\Database\DropCommand
tags:
@@ -201,11 +201,6 @@ services:
arguments: ['@console.extension_manager']
tags:
- { name: drupal.generator }
console.database_settings_generator:
class: Drupal\Console\Generator\DatabaseSettingsGenerator
arguments: ['@kernel']
tags:
- { name: drupal.generator }
console.entitycontent_generator:
class: Drupal\Console\Generator\EntityContentGenerator
arguments: ['@console.extension_manager', '@console.site', '@console.renderer']
@@ -8,32 +8,21 @@
namespace Drupal\Console\Generator;
use Drupal\Console\Core\Generator\Generator;
use Drupal\Core\DrupalKernelInterface;
class DatabaseSettingsGenerator extends Generator
{
/**
* @var DrupalKernelInterface
*/
protected $kernel;
/**
* DatabaseSettingsGenerator constructor.
*
* @param DrupalKernelInterface $kernel
*/
public function __construct(
DrupalKernelInterface $kernel
) {
$this->kernel = $kernel;
}
public function __construct() {}
/**
* {@inheritdoc}
*/
public function generate(array $parameters)
{
$settingsFile = $this->kernel->getSitePath() . '/settings.php';
$uri = parse_url($parameters['uri'], PHP_URL_HOST);
$settingsFile = 'sites/'.$uri.'/settings.php';
if (!is_writable($settingsFile)) {
return false;
}
@@ -11,6 +11,19 @@ services:
arguments: ['@app.root', '@console.configuration_manager']
tags:
- { name: drupal.command }
console.database_add:
class: Drupal\Console\Command\Database\AddCommand
arguments: ['@console.database_settings_generator']
tags:
- { name: drupal.command }
console.database_query:
class: Drupal\Console\Command\Database\QueryCommand
tags:
- { name: drupal.command }
console.database_connect:
class: Drupal\Console\Command\Database\ConnectCommand
tags:
- { name: drupal.command }
console.database_restore:
class: Drupal\Console\Command\Database\RestoreCommand
arguments: ['@app.root']
@@ -55,6 +68,10 @@ services:
class: Drupal\Console\Generator\DockerInitGenerator
tags:
- { name: drupal.generator }
console.database_settings_generator:
class: Drupal\Console\Generator\DatabaseSettingsGenerator
tags:
- { name: drupal.generator }
# Drupal services
http_client:
class: GuzzleHttp\Client

0 comments on commit 5fdb488

Please sign in to comment.
You can’t perform that action at this time.