Skip to content

Commit

Permalink
[console] Fix #3505: Too few arguments to function on hook updates. (#…
Browse files Browse the repository at this point in the history
…3510)

* [console] Fix #3505: Too few arguments to function on hook updates.

* [console] Reoder command chain call.

* [console] Rework obtain pending updates.
  • Loading branch information
jmolivas authored Sep 4, 2017
1 parent 3ee47c1 commit f784757
Show file tree
Hide file tree
Showing 3 changed files with 242 additions and 100 deletions.
32 changes: 25 additions & 7 deletions src/Bootstrap/Drupal.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,31 @@ public function boot()
$io->writeln('➤ Creating Drupal kernel');
}

$drupalKernel = DrupalKernel::createFromRequest(
$request,
$this->autoload,
'prod',
false,
$this->drupalFinder->getDrupalRoot()
);
$updateCommands = [
'update:execute',
'upex',
'updb',
'update:entities',
'upe'
];

if (!in_array($command, $updateCommands)) {
$drupalKernel = DrupalKernel::createFromRequest(
$request,
$this->autoload,
'prod',
false,
$this->drupalFinder->getDrupalRoot()
);
} else {
$drupalKernel = DrupalUpdateKernel::createFromRequest(
$request,
$this->autoload,
'prod',
false,
$this->drupalFinder->getDrupalRoot()
);
}

if ($debug) {
$io->writeln("\r\033[K\033[1A\r<info>✔</info>");
Expand Down
53 changes: 53 additions & 0 deletions src/Bootstrap/DrupalUpdateKernel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

namespace Drupal\Console\Bootstrap;

use Symfony\Component\HttpFoundation\Request;
use Drupal\Core\Update\UpdateKernel as DrupalKernelBase;
use Drupal\Core\DependencyInjection\ServiceModifierInterface;

/**
* Class DrupalUpdateKernel
*
* @package Drupal\Console\Utils
*/
class DrupalUpdateKernel extends DrupalKernelBase
{
/**
* @var ServiceModifierInterface[]
*/
protected $serviceModifiers = [];

/**
* @inheritdoc
*/
public static function createFromRequest(Request $request, $class_loader, $environment, $allow_dumping = true, $app_root = null)
{
$kernel = new static($environment, $class_loader, $allow_dumping, $app_root);
static::bootEnvironment($app_root);
$kernel->initializeSettings($request);
$kernel->handle($request);
return $kernel;
}

/**
* @param \Drupal\Core\DependencyInjection\ServiceModifierInterface $serviceModifier
*/
public function addServiceModifier(ServiceModifierInterface $serviceModifier)
{
$this->serviceModifiers[] = $serviceModifier;
}

/**
* @inheritdoc
*/
protected function getContainerBuilder()
{
$container = parent::getContainerBuilder();
foreach ($this->serviceModifiers as $serviceModifier) {
$serviceModifier->alter($container);
}

return $container;
}
}
Loading

0 comments on commit f784757

Please sign in to comment.