Skip to content

Commit

Permalink
[generate:ajax:command] Change command extend Command not ContainerAw…
Browse files Browse the repository at this point in the history
…areCommand. (#3706)
  • Loading branch information
jmolivas authored Jan 19, 2018
1 parent 80cde77 commit c3a8b53
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 21 deletions.
31 changes: 16 additions & 15 deletions src/Command/Generate/AjaxCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,17 @@
use Drupal\Console\Command\Shared\ConfirmationTrait;
use Drupal\Console\Command\Shared\ModuleTrait;
use Drupal\Console\Generator\AjaxCommandGenerator;
use Drupal\Console\Core\Command\ContainerAwareCommand;
use Drupal\Console\Core\Command\Command;
use Drupal\Console\Core\Utils\ChainQueue;
use Drupal\Console\Extension\Manager;
use Drupal\Console\Utils\Validator;

class AjaxCommand extends ContainerAwareCommand
/**
* Class AjaxCommand
*
* @package Drupal\Console\Command\Generate
*/
class AjaxCommand extends Command
{
use ModuleTrait;
use ServicesTrait;
Expand All @@ -31,11 +36,10 @@ class AjaxCommand extends ContainerAwareCommand
protected $extensionManager;

/**
* @var ControllerGenerator
* @var AjaxCommandGenerator
*/
protected $generator;


/**
* @var Validator
*/
Expand Down Expand Up @@ -67,6 +71,9 @@ public function __construct(
parent::__construct();
}

/**
* {@inheritdoc}
*/
protected function configure()
{
$this
Expand Down Expand Up @@ -109,9 +116,11 @@ protected function execute(InputInterface $input, OutputInterface $output)
$method = $input->getOption('method');

$this->generator->generate(
$module,
$class,
$method
[
'module' => $module,
'class' => $class,
'$method' => $method
]
);

// Run cache rebuild to see changes in Web UI
Expand Down Expand Up @@ -151,12 +160,4 @@ function ($class) {
$input->setOption('method', $method);
}
}

/**
* @return \Drupal\Console\Generator\AjaxCommandGenerator
*/
protected function createGenerator()
{
return new AjaxCommandGenerator();
}
}
17 changes: 11 additions & 6 deletions src/Generator/AjaxCommandGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
use Drupal\Console\Core\Generator\Generator;
use Drupal\Console\Extension\Manager;

/**
* Class AjaxCommandGenerator
*
* @package Drupal\Console\Generator
*/
class AjaxCommandGenerator extends Generator
{
/**
Expand All @@ -28,13 +33,13 @@ public function __construct(
$this->extensionManager = $extensionManager;
}

public function generate($module, $class, $method)
/**
* @param $parameters array
*/
public function generate($parameters)
{
$parameters = [
'class_name' => $class,
'module' => $module,
'method' => $method
];
$class = $parameters['class_name'];
$module = $parameters['module'];

$this->renderFile(
'module/src/Ajax/ajax-command.php.twig',
Expand Down

0 comments on commit c3a8b53

Please sign in to comment.