Skip to content

Commit 72ff6a5

Browse files
committed
Change events class name
1 parent 75969aa commit 72ff6a5

12 files changed

+79
-90
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,39 +133,39 @@ You can subscribe to an event
133133

134134
namespace App\Listeners;
135135

136-
use Symfony\Component\Workflow\Event\GuardEvent;
137-
use Symfony\Component\Workflow\Event\Event;
138-
139136
class BlogPostWorkflowSubscriber
140137
{
141138
/**
142139
* Handle workflow guard events.
143140
*/
144141
public function onGuard(GuardEvent $event) {
142+
/** Symfony\Component\Workflow\Event\GuardEvent */
143+
$originalEvent = $event->getOriginalEvent();
144+
145145
/** @var App\BlogPost $post */
146-
$post = $event->getSubject();
146+
$post = $originalEvent->getSubject();
147147
$title = $post->title;
148148

149149
if (empty($title)) {
150150
// Posts with no title should not be allowed
151-
$event->setBlocked(true);
151+
$originalEvent->setBlocked(true);
152152
}
153153
}
154154

155155
/**
156156
* Handle workflow leave event.
157157
*/
158-
public function onLeave(Event $event) {}
158+
public function onLeave($event) {}
159159

160160
/**
161161
* Handle workflow transition event.
162162
*/
163-
public function onTransition(Event $event) {}
163+
public function onTransition($event) {}
164164

165165
/**
166166
* Handle workflow enter event.
167167
*/
168-
public function onEnter(Event $event) {}
168+
public function onEnter($event) {}
169169

170170
/**
171171
* Register the listeners for the subscriber.

src/Events/BaseEvent.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace Brexis\LaravelWorkflow\Events;
4+
5+
use Symfony\Component\Workflow\Event\Event;
6+
7+
abstract class BaseEvent
8+
{
9+
/**
10+
* @var Event
11+
*/
12+
protected $originalEvent;
13+
14+
public function __construct(Event $event)
15+
{
16+
$this->originalEvent = $event;
17+
}
18+
19+
/**
20+
* Return the original event
21+
* @return Event
22+
*/
23+
public function getOriginalEvent()
24+
{
25+
return $this->originalEvent;
26+
}
27+
}

src/Events/Enter.php

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/Events/EnterEvent.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
namespace Brexis\LaravelWorkflow\Events;
4+
5+
class EnterEvent extends BaseEvent
6+
{
7+
}

src/Events/Guard.php

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/Events/GuardEvent.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace Brexis\LaravelWorkflow\Events;
4+
5+
use Symfony\Component\Workflow\Event\GuardEvent as SymfonyGuardEvent;
6+
7+
class GuardEvent extends BaseEvent
8+
{
9+
public function __construct(SymfonyGuardEvent $event)
10+
{
11+
$this->originalEvent = $event;
12+
}
13+
}

src/Events/Leave.php

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/Events/LeaveEvent.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
namespace Brexis\LaravelWorkflow\Events;
4+
5+
class LeaveEvent extends BaseEvent
6+
{
7+
}

src/Events/Transition.php

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/Events/TransitionEvent.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
namespace Brexis\LaravelWorkflow\Events;
4+
5+
class TransitionEvent extends BaseEvent
6+
{
7+
}

0 commit comments

Comments
 (0)