You are here

public function TestEnvironment::preDeploymentTrigger in Build Hooks 3.x

React before a build is triggered.

Parameters

\Drupal\build_hooks\Event\BuildTrigger $trigger: The build trigger.

Overrides FrontendEnvironmentBase::preDeploymentTrigger

File

tests/modules/build_hooks_test/src/Plugin/FrontendEnvironment/TestEnvironment.php, line 98

Class

TestEnvironment
Defines a test environment plugin.

Namespace

Drupal\build_hooks_test\Plugin\FrontendEnvironment

Code

public function preDeploymentTrigger(BuildTrigger $trigger) : void {
  if ($this->configuration['whiz'] === 'no deploy for you') {
    $trigger
      ->setShouldNotBuild(new TranslatableMarkup('No deploy today'));
  }
  if ($trigger
    ->getDeployment()->contents->entity) {
    $entity = $trigger
      ->getDeployment()->contents->entity;
    if ($entity
      ->label() === "can't let you do that dave") {
      $trigger
        ->setShouldNotBuild(new TranslatableMarkup('No deploy for this item'));
    }
  }
}