Skip to content
Permalink
Browse files

Add source_module to the template. Improve code: fix comments and ord…

…er use statements alphabetically (#3858)
  • Loading branch information...
LOBsTerr committed Apr 10, 2019
1 parent a6d97a2 commit c179f09cfc0ba105aadb71bfdd2e5296ee5284c6
@@ -2,30 +2,32 @@
/**
* @file
* Contains \Drupal\Console\Command\Generate\PluginBlockCommand.
* Contains \Drupal\Console\Command\Generate\PluginMigrateSourceCommand.
*/
namespace Drupal\Console\Command\Generate;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Drupal\Console\Core\Command\ContainerAwareCommand;
use Drupal\Console\Generator\PluginMigrateSourceGenerator;
use Drupal\Console\Command\Shared\ModuleTrait;
use Drupal\Console\Command\Shared\ArrayInputTrait;
use Drupal\Console\Command\Shared\ConfirmationTrait;
use Drupal\Console\Extension\Manager;
use Drupal\Console\Utils\Validator;
use Drupal\Console\Command\Shared\ModuleTrait;
use Drupal\Console\Core\Utils\StringConverter;
use Drupal\Console\Core\Utils\ChainQueue;
use Drupal\Console\Extension\Manager;
use Drupal\Console\Generator\PluginMigrateSourceGenerator;
use Drupal\Console\Utils\Validator;
use Drupal\Core\Config\ConfigFactory;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Render\ElementInfoManagerInterface;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
class PluginMigrateSourceCommand extends ContainerAwareCommand
{
use ModuleTrait;
use ArrayInputTrait;
use ConfirmationTrait;
use ModuleTrait;
/**
* @var ConfigFactory
@@ -68,7 +70,7 @@ class PluginMigrateSourceCommand extends ContainerAwareCommand
protected $elementInfoManager;
/**
* PluginBlockCommand constructor.
* PluginMigrateSourceCommand constructor.
*
* @param ConfigFactory $configFactory
* @param ChainQueue $chainQueue
@@ -167,6 +169,11 @@ protected function execute(InputInterface $input, OutputInterface $output)
$alias = $input->getOption('alias');
$group_by = $input->getOption('group-by');
$fields = $input->getOption('fields');
$no_interaction = $input->getOption('no-interaction');
// Parse nested data.
if ($no_interaction) {
$fields = $this->explodeInlineArray($fields);
}
$this->generator->generate([
'module' => $module,
@@ -17,7 +17,8 @@ use Drupal\migrate\Plugin\migrate\source\SqlBase;
* Provides a '{{class_name}}' migrate source.
*
* @MigrateSource(
* id = "{{plugin_id}}"
* id = "{{plugin_id}}",
* source_module = "{{module}}"
* )
*/
class {{class_name}} extends SqlBase {% endblock %}
@@ -26,30 +27,29 @@ class {{class_name}} extends SqlBase {% endblock %}
* {@inheritdoc}
*/
public function query() {

return $this->select('{{table}}', '{{alias}}')
->fields('{{alias}}'){% if group_by %}
->fields('{{alias}}')
{% if group_by %}
->groupBy('{{alias}}.{{group_by}}')
{% endif %};
{% endif %};
}

/**
* {@inheritdoc}
*/
public function fields() {
$fields = [
{% for field in fields %}
'{{field.id}}' => $this->t('{{field.description}}'),
{% endfor %}
];
{% for field in fields %}
'{{field.id}}' => $this->t('{{field.description}}'),
{% endfor %}
];
return $fields;
}

/**
* {@inheritdoc}
*/
public function getIds() {
return [
];
return [];
}
{% endblock %}

0 comments on commit c179f09

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