Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Events processing #7

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ composer-install:
phpcs:
@rm -rf phpcs-reports
@mkdir phpcs-reports
@touch phpcs-reports/.empty
@docker exec ${CID} /bin/sh -c 'vendor/bin/phpcs -p --colors --report-full=./phpcs-reports/phpcs-report-full.txt --report-gitblame=./phpcs-reports/phpcs-report-gitblame.txt --report-info=./phpcs-reports/phpcs-report-info.txt --standard=phpcs.xml .'

aws-config:
Expand Down
34 changes: 34 additions & 0 deletions demo/BakingPasta/BakingPastaDecider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace Continuous\Demo\Swf\BakingPasta;

use Continuous\Swf\DataTypes\Decision\CompleteWorkflowExecutionDecision;
use Continuous\Swf\DataTypes\Decision\DecisionTrait;
use Continuous\Swf\DeciderInterface;

/**
* Class BakingPastaDecider
* @package Continuous\Demo\Swf\BakingPasta
*/
class BakingPastaDecider extends BakingPastaWorkflow implements DeciderInterface
{
use DecisionTrait;

protected $events;

/**
* @param array $events
*/
public function setEvents(array $events)
{
$this->events = $events;
}

/**
* Process event for schedule decisions
*/
public function process()
{
$this->addDecisionTask(new CompleteWorkflowExecutionDecision());
}
}
53 changes: 45 additions & 8 deletions demo/BakingPasta/BakingPastaWorkflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Continuous\Demo\Swf\BakingPasta;

use Aws\Result;
use Continuous\Swf\Entity\Workflow;

/**
Expand All @@ -11,26 +10,64 @@
*/
class BakingPastaWorkflow extends Workflow
{
public function process(Result $result)
const NAME = 'bakingpasta';
const VERSION = '0.1.0';

protected $pasta;
protected $weight;

public function getName() : string
{
// TODO: Implement process() method.
return static::NAME;
}

public function setResult()
public function getVersion() : string
{
// TODO: Implement setResult() method.
return static::VERSION;
}

public function extract() :array
/**
* Type of pasta
*
* @param $pasta
* @return $this
* @throws \Exception
*/
public function setPasta($pasta)
{
if ('spaghetti' !== $pasta) {
throw new \Exception('Only spaghetti pasta is supported');
}

$this->pasta = $pasta;
return $this;
}

/**
* Gram of pasta
*
* @param int $weight
* @return $this
*/
public function setWeight(int $weight)
{
// TODO: Implement extract() method.
$this->weight = $weight;
return $this;
}

public function extract() :array
{
return [
'parent' => $this->parent,
'pasta' => $this->pasta,
'weight' => $this->weight,
];
}

public function hydrate(array $data)
{
// TODO: Implement hydrate() method.
$this->parent = $data['parent'];
$this->pasta = $data['pasta'];
$this->weight = $data['weight'];
}
}
24 changes: 24 additions & 0 deletions demo/Sauce/SauceDecider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace Continuous\Demo\Swf\Sauce;

use Continuous\Swf\DataTypes\Decision\CompleteWorkflowExecutionDecision;
use Continuous\Swf\DataTypes\Decision\DecisionTrait;
use Continuous\Swf\DeciderInterface;

class SauceDecider extends SauceWorkflow implements DeciderInterface
{
use DecisionTrait;

protected $events;

public function setEvents(array $events)
{
$this->events = $events;
}

public function process()
{
$this->addDecisionTask(new CompleteWorkflowExecutionDecision());
}
}
34 changes: 26 additions & 8 deletions demo/Sauce/SauceWorkflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Continuous\Demo\Swf\Sauce;

use Aws\Result;
use Continuous\Swf\Entity\Workflow;

/**
Expand All @@ -11,26 +10,45 @@
*/
class SauceWorkflow extends Workflow
{
public function process(Result $result)
const NAME = 'sauce';
const VERSION = '0.1.0';

/**
* @var bool
*/
protected $onions = false;

public function getName() : string
{
// TODO: Implement process() method.
return static::NAME;
}

public function setResult()
public function getVersion() : string
{
// TODO: Implement setResult() method.
return static::VERSION;
}

public function extract() :array
/**
* @param bool $wantOnions
* @return $this
*/
public function setOnions(bool $wantOnions)
{
// TODO: Implement extract() method.
$this->onions = $wantOnions;
return $this;
}

public function extract() :array
{
return [
'parent' => $this->parent,
'onions' => $this->onions,
];
}

public function hydrate(array $data)
{
// TODO: Implement hydrate() method.
$this->parent = $data['parent'];
$this->onions = $data['onions'];
}
}
24 changes: 18 additions & 6 deletions demo/Spaghetti/CompileActivity.php
Original file line number Diff line number Diff line change
@@ -1,23 +1,35 @@
<?php

namespace Continuous\Demo\Swf\BakingPasta;
namespace Continuous\Demo\Swf\Spaghetti;

use Continuous\Swf\Entity\Activity;

class BoilingWaterActivity extends Activity
class CompileActivity extends Activity
{
public function setResult()
const NAME = 'spaghetti.compile';
const VERSION = '0.1.0';

public function getName() : string
{
return static::NAME;
}

public function getVersion() : string
{
// TODO: Implement setResult() method.
return static::VERSION;
}

public function extract() : array
{
// TODO: Implement extract() method.
return [];
}

public function hydrate(array $data)
{
// TODO: Implement hydrate() method.
}

public function process()
{
$this->completed();
}
}
24 changes: 18 additions & 6 deletions demo/Spaghetti/EatActivity.php
Original file line number Diff line number Diff line change
@@ -1,23 +1,35 @@
<?php

namespace Continuous\Demo\Swf\BakingPasta;
namespace Continuous\Demo\Swf\Spaghetti;

use Continuous\Swf\Entity\Activity;

class BoilingWaterActivity extends Activity
class EatActivity extends Activity
{
public function setResult()
const NAME = 'spaghetti.eat';
const VERSION = '0.1.0';

public function getName() : string
{
return static::NAME;
}

public function getVersion() : string
{
// TODO: Implement setResult() method.
return static::VERSION;
}

public function extract() : array
{
// TODO: Implement extract() method.
return [];
}

public function hydrate(array $data)
{
// TODO: Implement hydrate() method.
}

public function process()
{
$this->completed();
}
}
Loading