Skip to content

Commit

Permalink
inyect services in generate:form [NOT WORKING YET] (#2855)
Browse files Browse the repository at this point in the history
  • Loading branch information
novia713 authored and enzolutions committed Nov 1, 2016
1 parent c156d8f commit 57cc9a7
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
5 changes: 5 additions & 0 deletions config/services/drupal-console/generate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ services:
arguments: ['@console.help_generator', '@console.site', '@console.extension_manager', '@console.chain_queue']
tags:
- { name: drupal.command }
console.generate_form:
class: Drupal\Console\Command\Generate\FormBaseCommand
arguments: ['@console.extension_manager', '@console.form_generator', '@console.chain_queue']
tags:
- { name: drupal.command }
console.generate_form_alter:
class: Drupal\Console\Command\Generate\FormAlterCommand
arguments: ['@console.extension_manager', '@console.form_alter_generator', '@console.string_converter', '@module_handler', '@plugin.manager.element_info', '@?profiler', '@app.root', '@console.chain_queue']
Expand Down
34 changes: 32 additions & 2 deletions src/Command/Generate/FormCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,49 @@
use Drupal\Console\Command\Shared\FormTrait;
use Symfony\Component\Console\Command\Command;
use Drupal\Console\Style\DrupalStyle;
use Drupal\Console\Command\Shared\ContainerAwareCommandTrait;
use Drupal\Console\Command\Shared\CommandTrait;
use Drupal\Console\Generator\FormGenerator;
use Drupal\Console\Extension\Manager;
use Drupal\Console\Utils\ChainQueue;

abstract class FormCommand extends Command
{
use CommandTrait;
use ModuleTrait;
use ServicesTrait;
use FormTrait;
use MenuTrait;
use ContainerAwareCommandTrait;

private $formType;
private $commandName;

/** @var Manager */
protected $extensionManager;

/** @var FormGenerator */
protected $generator;

/** @var ChainQueue */
protected $chainQueue;


/**
* FormCommand constructor.
* @param Manager $extensionManager
* @param FormGenerator $generator
* @param ChainQueue $chainQueue
*/
public function __construct(
Manager $extensionManager,
FormGenerator $generator,
ChainQueue $chainQueue
) {
$this->extensionManager = $extensionManager;
$this->generator = $generator;
$this->chainQueue = $chainQueue;
parent::__construct();
}

protected function setFormType($formType)
{
return $this->formType = $formType;
Expand Down

0 comments on commit 57cc9a7

Please sign in to comment.