diff --git a/.travis.yml b/.travis.yml index 9dd51e9..04e93f9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ language: php php: - 7.1 - 7.2 + - 7.3 before_install: - sudo apt-get update -q - sudo apt-get autoremove graphviz -y diff --git a/README.md b/README.md index 90314b0..84d12fe 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Laravel workflow [![Build Status](https://travis-ci.org/brexis/laravel-workflow.svg?branch=1.1.2)](https://travis-ci.org/brexis/laravel-workflow) +# Laravel workflow [![Build Status](https://travis-ci.org/brexis/laravel-workflow.svg?branch=1.3.3)](https://travis-ci.org/brexis/laravel-workflow) Use the Symfony Workflow component in Laravel diff --git a/composer.json b/composer.json index 8b2e0a3..c77d9af 100644 --- a/composer.json +++ b/composer.json @@ -1,15 +1,15 @@ { "name": "brexis/laravel-workflow", "description": "Integerate Symfony Workflow component into Laravel.", - "keywords": ["workflow", "symfony", "laravel", "laravel5", "laravel6"], + "keywords": ["workflow", "symfony", "laravel", "laravel5", "laravel6", "laravel7", "laravel8"], "license": "MIT", "require": { "php": ">=5.5.9", - "symfony/workflow": "^3.3 || ^4.0", - "symfony/process": "^3.3 || ^4.0", - "symfony/event-dispatcher": "^3.3 || ^4.0", - "illuminate/console": "5.3.* || 5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.* || 6.*", - "illuminate/support": "5.3.* || 5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.* || 6.*" + "symfony/workflow": "^3.3 || ^4.0 || ^5.0", + "symfony/process": "^3.3 || ^4.0 || ^5.0", + "symfony/event-dispatcher": "^3.3 || ^4.0 || ^5.0", + "illuminate/console": "5.3.* || 5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.* || 6.* || 7.* || 8.*", + "illuminate/support": "5.3.* || 5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.* || 6.* || 7.* || 8.*" }, "autoload": { "psr-4": { @@ -36,6 +36,6 @@ }, "require-dev": { "mockery/mockery": "^1.0", - "phpunit/phpunit": "^6.0 || ~7.0 || ^8.0" + "phpunit/phpunit": "^6.0 || ~7.0 || ^8.0 || ^9.0" } } diff --git a/src/Traits/WorkflowTrait.php b/src/Traits/WorkflowTrait.php index 8edecc1..b2eb60f 100644 --- a/src/Traits/WorkflowTrait.php +++ b/src/Traits/WorkflowTrait.php @@ -9,6 +9,8 @@ */ trait WorkflowTrait { + protected $markingProperty = 'status'; + public function workflow_apply($transition, $workflow = null) { return Workflow::get($this, $workflow)->apply($this, $transition); @@ -23,4 +25,26 @@ public function workflow_transitions($workflow = null) { return Workflow::get($this, $workflow)->getEnabledTransitions($this); } + + /** + * Get the marking property for class + * + * @return string + */ + public function getMarking() + { + return $this->{$this->markingProperty}; + } + + /** + * Set the marking property for class + * + * @param [type] $currentPlace + * @param array $context + * @return void + */ + public function setMarking($currentPlace, $context = []) + { + $this->{$this->markingProperty} = $currentPlace; + } } diff --git a/src/WorkflowRegistry.php b/src/WorkflowRegistry.php index a1c9d88..c757248 100644 --- a/src/WorkflowRegistry.php +++ b/src/WorkflowRegistry.php @@ -7,8 +7,7 @@ use Symfony\Component\Workflow\Definition; use Symfony\Component\Workflow\DefinitionBuilder; use Symfony\Component\Workflow\MarkingStore\MarkingStoreInterface; -use Symfony\Component\Workflow\MarkingStore\MultipleStateMarkingStore; -use Symfony\Component\Workflow\MarkingStore\SingleStateMarkingStore; +use Symfony\Component\Workflow\MarkingStore\MethodMarkingStore; use Symfony\Component\Workflow\Registry; use Symfony\Component\Workflow\StateMachine; use Symfony\Component\Workflow\SupportStrategy\InstanceOfSupportStrategy; @@ -148,10 +147,8 @@ protected function getMarkingStoreInstance(array $workflowData) if (isset($markingStoreData['class'])) { $className = $markingStoreData['class']; - } elseif (isset($markingStoreData['type']) && $markingStoreData['type'] === 'multiple_state') { - $className = MultipleStateMarkingStore::class; } else { - $className = SingleStateMarkingStore::class; + $className = MethodMarkingStore::class; } $class = new \ReflectionClass($className);