Skip to content

Add support for laravel 7 and 8 #82

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

Open
wants to merge 9 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 .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand All @@ -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"
}
}
24 changes: 24 additions & 0 deletions src/Traits/WorkflowTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
*/
trait WorkflowTrait
{
protected $markingProperty = 'status';

public function workflow_apply($transition, $workflow = null)
{
return Workflow::get($this, $workflow)->apply($this, $transition);
Expand All @@ -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;
}
}
7 changes: 2 additions & 5 deletions src/WorkflowRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down