class SyncCommand in FormAssembly 8
FormAssembly Drupal Console Sync Command.
@author Shawn P. Duncan <code@sd.shawnduncan.org>
Copyright 2019 by Shawn P. Duncan. This code is released under the GNU General Public License. Which means that it is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. http://www.gnu.org/licenses/gpl.html
@DrupalCommand ( extension="formassembly", extensionType="module" )
Hierarchy
- class \Drupal\formassembly\Command\SyncCommand extends \Drupal\Console\Core\Command\ContainerAwareCommand
Expanded class hierarchy of SyncCommand
1 string reference to 'SyncCommand'
1 service uses SyncCommand
File
- src/
Command/ SyncCommand.php, line 30
Namespace
Drupal\formassembly\CommandView source
class SyncCommand extends ContainerAwareCommand {
/**
* Injected Sync service.
*
* @var \Drupal\formassembly\FormAssemblyBatchProcessor
*/
protected $batchProcessor;
/**
* Symfony progress bar component.
*
* @var \Symfony\Component\Console\Helper\ProgressBar
*/
protected $progressBar;
/**
* {@inheritdoc}
*/
public function __construct(FormAssemblyBatchProcessor $batchProcessor) {
$this->batchProcessor = $batchProcessor;
parent::__construct();
}
/**
* {@inheritdoc}
*/
protected function configure() {
$this
->setName('formassembly:sync')
->setDescription($this
->trans('commands.formassembly.sync.description'));
}
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output) {
$finished = FALSE;
$batchConfig = [];
$this->batchProcessor
->configureBatch($batchConfig);
$this->progressBar = $this
->getIo()
->createProgressBar();
while (!$finished) {
$this->batchProcessor
->iterateBatch($batchConfig);
$this->progressBar
->advance();
$finished = $batchConfig['finished'] === 1;
}
$this->progressBar
->finish();
$this
->getIo()
->text($this
->trans('commands.formassembly.sync.messages.processing'));
$this->batchProcessor
->batchPostProcess($batchConfig['sandbox']['sync_id']);
$this
->getIo()
->success($this
->trans('commands.formassembly.sync.messages.success'));
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
SyncCommand:: |
protected | property | Injected Sync service. | |
SyncCommand:: |
protected | property | Symfony progress bar component. | |
SyncCommand:: |
protected | function | ||
SyncCommand:: |
protected | function | ||
SyncCommand:: |
public | function |