Skip to content
Snippets Groups Projects

Added an events to the drush tome-aws:deploy

Merged Taggart Jensen requested to merge feature/add-event into 2.0.x
Files
3
+ 16
2
@@ -4,7 +4,9 @@ namespace Drupal\tome_aws\Commands;
@@ -4,7 +4,9 @@ namespace Drupal\tome_aws\Commands;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\tome_aws\DeployBatch;
use Drupal\tome_aws\DeployBatch;
 
use Drupal\tome_aws\Event\TomeAwsEvents;
use Drush\Commands\DrushCommands;
use Drush\Commands\DrushCommands;
 
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
/**
/**
* Contains the tome-aws:deploy command.
* Contains the tome-aws:deploy command.
@@ -20,14 +22,24 @@ class Deploy extends DrushCommands {
@@ -20,14 +22,24 @@ class Deploy extends DrushCommands {
*/
*/
protected $batch;
protected $batch;
 
/**
 
* The event dispatcher.
 
*
 
* @var \Symfony\Component\EventDispatcher\EventDispatcherInterface
 
*/
 
protected $eventDispatcher;
 
/**
/**
* TomeAwsDeployCommand constructor.
* TomeAwsDeployCommand constructor.
*
*
* @param \Drupal\tome_aws\DeployBatch $batch
* @param \Drupal\tome_aws\DeployBatch $batch
* The batch service.
* The batch service.
 
* @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher
 
* Event dispatcher service.
*/
*/
public function __construct(DeployBatch $batch) {
public function __construct(DeployBatch $batch, EventDispatcherInterface $event_dispatcher) {
$this->batch = $batch;
$this->batch = $batch;
 
$this->eventDispatcher = $event_dispatcher;
}
}
/**
/**
@@ -37,7 +49,6 @@ class Deploy extends DrushCommands {
@@ -37,7 +49,6 @@ class Deploy extends DrushCommands {
* @option title A title to identify this build.
* @option title A title to identify this build.
*/
*/
public function deploy(array $options = ['title' => 'Sent from Tome AWS']) {
public function deploy(array $options = ['title' => 'Sent from Tome AWS']) {
if (!$this->batch->checkConfiguration()) {
if (!$this->batch->checkConfiguration()) {
$this->io()->error('Tome AWS has not been configured.');
$this->io()->error('Tome AWS has not been configured.');
return 1;
return 1;
@@ -46,6 +57,8 @@ class Deploy extends DrushCommands {
@@ -46,6 +57,8 @@ class Deploy extends DrushCommands {
$this->io()->error('No static build available for deploy.');
$this->io()->error('No static build available for deploy.');
return 1;
return 1;
}
}
 
$event = new TomeAwsEvents();
 
$this->eventDispatcher->dispatch($event, TomeAwsEvents::DEPLOY_START);
$batch_builder = $this->batch->getBatch($options['title']);
$batch_builder = $this->batch->getBatch($options['title']);
batch_set($batch_builder->toArray());
batch_set($batch_builder->toArray());
@@ -75,6 +88,7 @@ class Deploy extends DrushCommands {
@@ -75,6 +88,7 @@ class Deploy extends DrushCommands {
}
}
else {
else {
$this->io()->success($this->t("Deploy complete!"));
$this->io()->success($this->t("Deploy complete!"));
 
$this->eventDispatcher->dispatch($event, TomeAwsEvents::DEPLOY_FINISHED);
}
}
}
}
}
}
Loading