Skip to content

Add illuminate dependency version 5.8 #4

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 98 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
55d4acc
Use symfony workflow version ^3.2 and add unit test
brexis Feb 12, 2017
ed6ba67
Update composer dependencies
brexis Feb 12, 2017
2ff6956
Update composer dependencies verion
brexis Feb 12, 2017
e20e468
Update composer dependencies
brexis Feb 12, 2017
8e383c2
Remove test image
brexis Feb 12, 2017
5e585e8
Update composer dependencies
brexis Feb 12, 2017
818a036
Update composer dependencies
brexis Feb 12, 2017
a900d86
User Brexis\LaravelWorkflow as namespace
brexis Feb 12, 2017
e182645
Update composer namespace
brexis Feb 12, 2017
94490fe
Use ::class annotation in readme file
brexis Feb 12, 2017
2a50034
Change package namespace
brexis Feb 12, 2017
68ed3a7
Fix conflict ServiceProvider
brexis Feb 13, 2017
62d8da6
Fix config file path
brexis Feb 13, 2017
905de32
Remove unused namespace
brexis Feb 13, 2017
300795a
Add workflow_can and workflow_transitions blade extensions
brexis Feb 13, 2017
1e28635
Revert "Add workflow_can and workflow_transitions blade extensions"
brexis Feb 13, 2017
082ce53
Add traits
brexis Feb 13, 2017
c9d214a
Simplify Workflow trait
brexis Feb 13, 2017
7783d09
Add apply method to workflow trait
brexis Feb 13, 2017
c09e518
Update readme file
brexis Feb 13, 2017
f95aa03
R/Order/BlogPost
brexis Feb 13, 2017
697380f
Remove composer.lock
brexis Feb 13, 2017
b24ea8c
R/use/uses
brexis Feb 13, 2017
d14a667
Add comments
brexis Feb 13, 2017
c5b4802
Add support for workflow events
brexis Feb 13, 2017
f71b15a
Add events unit test
brexis Feb 13, 2017
306ce74
Add events documentation
brexis Feb 13, 2017
fa8a2ab
Add class option to dumper command
brexis Feb 14, 2017
75969aa
Use a fixture class for test object
brexis Feb 14, 2017
72ff6a5
Change events class name
brexis Feb 17, 2017
1139a61
Add comments
brexis Feb 17, 2017
9f2c8d6
Change event classes in READEME
brexis Feb 17, 2017
f47cefc
Fixed copy/paste error in readme
uniconstructor May 24, 2017
42f5f5e
Merge pull request #1 from uniconstructor/patch-1
brexis May 24, 2017
225d460
fixes deprecated class name warning due to symfony upgrade 3.3
symplworks Jun 6, 2017
fe97374
Merge pull request #2 from kadinho/master
brexis Jun 6, 2017
aaea3b9
-ignores phpstorm files
symplworks Jun 6, 2017
b489f89
emitting symfony-style events to allow for cleaner multiple workflow …
zerodahero Sep 6, 2017
dd59be3
updated unit test
zerodahero Sep 6, 2017
e26cb8c
Merge pull request #4 from zerodahero/master
brexis Nov 17, 2017
1e8cf1f
Merge pull request #3 from kadinho/master
brexis Nov 17, 2017
4b2a203
Fix test classes name
brexis Nov 17, 2017
6b58ee8
Compatibily for laravel version 5.3
brexis Nov 17, 2017
7e4bc82
Merge branch 'master' of github.com:brexis/laravel-workflow
brexis Nov 17, 2017
0c90659
Enable event hook wildcards
brexis Nov 17, 2017
14760cf
Allow multiple transitions with the same name
laurenkt Nov 17, 2017
96c12d0
Add compatibly for laravel 5.4 and 5.5
brexis Nov 17, 2017
05a41c4
Add test for multiple transitions with the same name
laurenkt Nov 17, 2017
99d93e0
Upgrade symfony components versions
brexis Nov 17, 2017
876075f
Make sure to delete dump file before the command test
brexis Nov 17, 2017
18f73ed
Merge pull request #5 from laurenkt/master
brexis Nov 17, 2017
344deb2
Add package auto-discovering feature
brexis Nov 17, 2017
24635a3
Add instruction for laravel <= 5.4
brexis Nov 17, 2017
1b66e31
Update readme file
brexis Nov 17, 2017
d398935
Added entered Event
Nov 29, 2017
0a541d9
added test for entered event
Nov 30, 2017
32b3d15
Merge pull request #8 from bigperson/master
brexis Nov 30, 2017
3c60e8b
Add travis config file
brexis Nov 30, 2017
68fa5c2
Add graphviz installation instruction
brexis Dec 1, 2017
f842117
Fix graphviz installation instruction
brexis Dec 1, 2017
ef70e91
-y
brexis Dec 1, 2017
9845dfc
-y
brexis Dec 1, 2017
5d990f3
travis fix
brexis Dec 1, 2017
df0a01a
Add workflow entered event documentation
brexis Dec 1, 2017
b882c07
Include travis status image
brexis Dec 1, 2017
be4bc58
Add Entered event in the list of events
brexis Dec 3, 2017
a259780
Added more event subscribers to conform to the way Symfony has the ev…
psmeets-devnl Jan 12, 2018
d16750b
Added completed event and fixed using of incorrect event names.
psmeets-devnl Jan 12, 2018
1125c19
Added Laravel 5.6 support
Feb 16, 2018
7919123
Updated the Symfony components to version >= 4.0
Feb 16, 2018
03def8a
Removed PHP 7.0 from the Travis config
Feb 16, 2018
f614d52
Added support for older versions to be backwards compatible
Feb 19, 2018
e4309c7
Changed the single pipes to double pipes as the single pipes are depr…
Feb 19, 2018
105473a
Added missing older version for the symfony/event-dispatcher package
Feb 19, 2018
2af9388
Fixed some typos and styling issues
Feb 19, 2018
08a8126
Added the addFromArray method to allow dynamically adding workflows t…
Feb 19, 2018
c23de94
Fixed some styling issues and made all private methods and properties…
Feb 19, 2018
6b3ed27
Removed unused use clause
Feb 19, 2018
e66ea69
Merge pull request #15 from MyDigitalLife/events
brexis Feb 20, 2018
e0403ea
Refactor event subscriptions
brexis Feb 20, 2018
b9908c5
Merge pull request #18 from willemo/laravel-5-6-support
brexis Feb 20, 2018
cbd47a8
Enable php 7.2 unit tests in travis
brexis Feb 20, 2018
aabd265
Merge pull request #19 from willemo/dynamic-adding-of-workflows-to-th…
brexis Feb 20, 2018
b982bed
#21 Does not work multiple "from"
Mar 13, 2018
eb5856a
Merge pull request #22 from vlsoprun/master
brexis Mar 13, 2018
096dd04
Adds usage of GuardEvent class
lguima Apr 24, 2018
16df47b
Merge pull request #24 from lguima/patch-1
brexis Apr 24, 2018
b38e386
Adds usage of classes
lguima May 9, 2018
efe4e42
Update usage of Workflow
lguima May 9, 2018
5da7adb
Merge pull request #26 from lguima/patch-1
brexis May 17, 2018
be0f526
Add more unit test for dump command
brexis Jun 13, 2018
94878a2
Merge branch 'master' of github.com:brexis/laravel-workflow
brexis Jun 13, 2018
7f4d715
Document --class option
brexis Jun 13, 2018
d5b6ebd
Fix auto discover issue
brexis Jul 25, 2018
3f16611
Fix config path
brexis Jul 25, 2018
8ba7008
Update Illuminate packages to v5.7.*
Nov 8, 2018
89358dc
Merge pull request #37 from willemo/laravel-5-7-support
brexis Jan 3, 2019
924c14e
Update composer.json
Apr 23, 2019
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
17 changes: 3 additions & 14 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
vendor/
node_modules/

# Laravel 4 specific
bootstrap/compiled.php
app/storage/

# Laravel 5 & Lumen specific
bootstrap/cache/
.env.*.php
.env.php
.env

# Rocketeer PHP task runner and deployment package. https://github.com/rocketeers/rocketeer
.rocketeer/
straight.png
composer.lock
.idea
17 changes: 17 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
language: php

php:
- 7.0
- 7.1
- 7.2
before_install:
- sudo apt-get update -q
- sudo apt-get autoremove graphviz -y
- sudo apt-get install graphviz -y

before_script:
- composer self-update
- composer install --no-interaction

script:
- vendor/bin/phpunit
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2016 PICR
Copyright (c) 2016 BREXIS

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
217 changes: 205 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,224 @@
# Laravel workflow
# Laravel workflow [![Build Status](https://travis-ci.org/brexis/laravel-workflow.svg?branch=1.1.2)](https://travis-ci.org/brexis/laravel-workflow)

Use the Symfony Workflow component in Laravel

### Composer Configuration

Include the laravel-workflow package as a dependency in your `composer.json`:

"picr/laravel-workflow": "dev-master"

### Installation

Run `composer install` to download the dependencies.
composer require brexis/laravel-workflow

#### Laravel 5
#### For laravel <= 5.4

Add a ServiceProvider to your providers array in `config/app.php`:

```php
'providers' => [
<?php

'Picr\LaravelWorkflow\LaravelWorkflowServiceProvider',
'providers' => [
...
Brexis\LaravelWorkflow\WorkflowServiceProvider::class,

]
```

Add the `Workflow` facade to your facades array:

```php
'Workflow' => 'Picr\LaravelWorkflow\Facades\WorkflowFacade',
<?php
...
'Workflow' => Brexis\LaravelWorkflow\Facades\WorkflowFacade::class,
```

### Configuration

Publish the config file

```
php artisan vendor:publish --provider="Brexis\LaravelWorkflow\WorkflowServiceProvider"
```

Configure your workflow in `config/workflow.php`

```php
<?php

return [
'straight' => [
'type' => 'workflow', // or 'state_machine'
'marking_store' => [
'type' => 'multiple_state',
'arguments' => ['currentPlace']
],
'supports' => ['App\BlogPost'],
'places' => ['draft', 'review', 'rejected', 'published'],
'transitions' => [
'to_review' => [
'from' => 'draft',
'to' => 'review'
],
'publish' => [
'from' => 'review',
'to' => 'published'
],
'reject' => [
'from' => 'review',
'to' => 'rejected'
]
],
]
];
```

Use the `WorkflowTrait` inside supported classes

```php
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Brexis\LaravelWorkflow\Traits\WorkflowTrait;

class BlogPost extends Model
{
use WorkflowTrait;

}
```
### Usage

```php
<?php

use App\BlogPost;
use Workflow;

$post = BlogPost::find(1);
$workflow = Workflow::get($post);
// if more than one workflow is defined for the BlogPost class
$workflow = Workflow::get($post, $workflowName);

$workflow->can($post, 'publish'); // False
$workflow->can($post, 'to_review'); // True
$transitions = $workflow->getEnabledTransitions($post);

// Apply a transition
$workflow->apply($post, 'to_review');
$post->save(); // Don't forget to persist the state

// Using the WorkflowTrait
$post->workflow_can('publish'); // True
$post->workflow_can('to_review'); // False

// Get the post transitions
foreach ($post->workflow_transitions() as $transition) {
echo $transition->getName();
}

// Apply a transition
$post->workflow_apply('publish');
$post->save();
```

### Use the events
This package provides a list of events fired during a transition

```php
Brexis\LaravelWorkflow\Events\Guard
Brexis\LaravelWorkflow\Events\Leave
Brexis\LaravelWorkflow\Events\Transition
Brexis\LaravelWorkflow\Events\Enter
Brexis\LaravelWorkflow\Events\Entered
```

You can subscribe to an event

```php
<?php

namespace App\Listeners;

use Brexis\LaravelWorkflow\Events\GuardEvent;

class BlogPostWorkflowSubscriber
{
/**
* Handle workflow guard events.
*/
public function onGuard(GuardEvent $event) {
/** Symfony\Component\Workflow\Event\GuardEvent */
$originalEvent = $event->getOriginalEvent();

/** @var App\BlogPost $post */
$post = $originalEvent->getSubject();
$title = $post->title;

if (empty($title)) {
// Posts with no title should not be allowed
$originalEvent->setBlocked(true);
}
}

/**
* Handle workflow leave event.
*/
public function onLeave($event) {}

/**
* Handle workflow transition event.
*/
public function onTransition($event) {}

/**
* Handle workflow enter event.
*/
public function onEnter($event) {}

/**
* Handle workflow entered event.
*/
public function onEntered($event) {}

/**
* Register the listeners for the subscriber.
*
* @param Illuminate\Events\Dispatcher $events
*/
public function subscribe($events)
{
$events->listen(
'Brexis\LaravelWorkflow\Events\GuardEvent',
'App\Listeners\BlogPostWorkflowSubscriber@onGuard'
);

$events->listen(
'Brexis\LaravelWorkflow\Events\LeaveEvent',
'App\Listeners\BlogPostWorkflowSubscriber@onLeave'
);

$events->listen(
'Brexis\LaravelWorkflow\Events\TransitionEvent',
'App\Listeners\BlogPostWorkflowSubscriber@onTransition'
);

$events->listen(
'Brexis\LaravelWorkflow\Events\EnterEvent',
'App\Listeners\BlogPostWorkflowSubscriber@onEnter'
);

$events->listen(
'Brexis\LaravelWorkflow\Events\EnteredEvent',
'App\Listeners\BlogPostWorkflowSubscriber@onEntered'
);
}

}
```

### Dump Workflows
Symfony workflow uses GraphvizDumper to create the workflow image. You may need to install the `dot` command of [Graphviz](http://www.graphviz.org/)

php artisan workflow:dump workflow_name --class App\\BlogPost

You can change the image format with the `--format` option. By default the format is png.

php artisan workflow:dump workflow_name --format=jpg
35 changes: 27 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,41 @@
{
"name": "picr/laravel-workflow",
"name": "brexis/laravel-workflow",
"description": "Integerate Symfony Workflow component into Laravel.",
"keywords": ["workflow", "petri net", "laravel", "laravel5"],
"keywords": ["workflow", "symfony", "laravel", "laravel5"],
"license": "MIT",
"require": {
"php": ">=5.5.0",
"symfony/workflow": "^3.2@dev",
"symfony/property-access": "^3.2@dev"
"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.*",
"illuminate/support": "5.3.* || 5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.*"
},
"autoload": {
"psr-0": {
"Picr\\LaravelWorkflow": "src/"
"psr-4": {
"Brexis\\LaravelWorkflow\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
},
"laravel": {
"providers": [
"Brexis\\LaravelWorkflow\\WorkflowServiceProvider"
],
"aliases": {
"Workflow": "Brexis\\LaravelWorkflow\\Facades\\WorkflowFacade"
}
}
},
"minimum-stability": "dev"
"require-dev": {
"mockery/mockery": "^0.9.8",
"phpunit/phpunit": "^6.0 || ~7.0"
}
}
Loading