/** * Registers services on the given container. * * This method should only be used to configure services and parameters. * It should not get services. * * @param Container $pimple An Container instance */ public function register(Container $pimple) { $pimple['deployment.deployer'] = function () use($pimple) { $runner = new Runner(); $runner->setLogger($pimple['logger']); $factory = new Deployer($runner, $pimple['project.projectDirectoryHelper'], $pimple['environment.mapping.mappingConverter'], $pimple['interpolator.interpolator']); $factory->setLogger($pimple['logger']); return $factory; }; $pimple['deployment.deploymentOutputHandler'] = function () use($pimple) { $handler = new DeploymentOutputHandler($pimple['output.handler.consoleOutputHandler']); return $handler; }; }
<?php /* * This file is part of the andreas-weber/php-runner library. * * (c) Andreas Weber <*****@*****.**> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ use AndreasWeber\Runner\Example\Task1; use AndreasWeber\Runner\Example\Task2; use AndreasWeber\Runner\Example\TaskFail; use AndreasWeber\Runner\Payload\ArrayPayload; use AndreasWeber\Runner\Runner; use AndreasWeber\Runner\Task\Collection; use AndreasWeber\Runner\Task\Retries\Retries; require_once __DIR__ . '/../resources/bootstrap.php'; $collection = new Collection(); $collection->addTask(new Task1()); $collection->addTask(new Task2()); $retryTask = new TaskFail(2); // task will fail 2 times, just for demonstration ;-) $retryTask->setMaxRetries(new Retries(3)); // task will get retried 3 times $collection->addTask($retryTask); $payload = new ArrayPayload(); $runner = new Runner($collection, $logger); $runner->run($payload); // dump payload var_export($payload);
public function testSetTaskCollectionByConstructor() { $runner = new Runner($this->collection); $this->assertEquals($this->collection, $runner->getTaskCollection()); }
public function run(PayloadInterface $payload) { $this->invoked = true; return parent::run($payload); }
<?php /* * This file is part of the andreas-weber/php-runner library. * * (c) Andreas Weber <*****@*****.**> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ use AndreasWeber\Runner\Example\Task1; use AndreasWeber\Runner\Example\Task2; use AndreasWeber\Runner\Payload\ArrayPayload; use AndreasWeber\Runner\Runner; use AndreasWeber\Runner\Task\Collection; require_once __DIR__ . '/../resources/bootstrap.php'; $collection = new Collection(); $collection->addTask(new Task1()); $collection->addTask(new Task2()); $payload = new ArrayPayload(); $runner = new Runner($collection, $logger); $runner->onSuccess(function () { echo 'Success-Callback triggered!' . PHP_EOL; }); $runner->run($payload); // dump payload var_export($payload);
* This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ use AndreasWeber\Runner\Example\Task1; use AndreasWeber\Runner\Example\Task2; use AndreasWeber\Runner\Payload\ArrayPayload; use AndreasWeber\Runner\Runner; use AndreasWeber\Runner\Task\Collection; require_once __DIR__ . '/../resources/bootstrap.php'; // // Runner 1 // $collection1 = new Collection(); $collection1->addTask(new Task1()); $collection1->addTask(new Task2()); $runner1 = new Runner($collection1, $logger); // // Runner 2 // $collection2 = new Collection(); $collection2->addTask(new Task1()); $collection2->addTask(new Task2()); $runner2 = new Runner($collection2, $logger); // // Chaining // $runner1->attach($runner2); // // Invoke execution // $payload = new ArrayPayload();