-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1308 from thephpleague/feature/league-event-3
[UPGRADE] Upgrade league/event to version 3.
- Loading branch information
Showing
10 changed files
with
127 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace League\OAuth2\Server\EventEmitting; | ||
|
||
use League\Event\HasEventName; | ||
use Psr\EventDispatcher\StoppableEventInterface; | ||
|
||
class AbstractEvent implements StoppableEventInterface, HasEventName | ||
{ | ||
private bool $propagationStopped = false; | ||
|
||
public function __construct(private string $name) | ||
{ | ||
} | ||
|
||
public function eventName(): string | ||
{ | ||
return $this->name; | ||
} | ||
|
||
/** | ||
* Backwards compatibility method | ||
* | ||
* @deprecated use eventName instead | ||
*/ | ||
public function getName(): string | ||
{ | ||
return $this->name; | ||
} | ||
|
||
public function isPropagationStopped(): bool | ||
{ | ||
return $this->propagationStopped; | ||
} | ||
|
||
public function stopPropagation(): self | ||
{ | ||
$this->propagationStopped = true; | ||
|
||
return $this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace League\OAuth2\Server\EventEmitting; | ||
|
||
interface EmitterAwareInterface | ||
{ | ||
public function getEmitter(): EventEmitter; | ||
|
||
public function setEmitter(EventEmitter $emitter): self; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace League\OAuth2\Server\EventEmitting; | ||
|
||
use League\Event\ListenerRegistry; | ||
use Psr\EventDispatcher\EventDispatcherInterface; | ||
|
||
trait EmitterAwarePolyfill | ||
{ | ||
private EventEmitter $emitter; | ||
|
||
public function getEmitter(): EventEmitter | ||
{ | ||
return $this->emitter ?? new EventEmitter(); | ||
} | ||
|
||
public function setEmitter(EventEmitter $emitter): self | ||
{ | ||
$this->emitter = $emitter; | ||
|
||
return $this; | ||
} | ||
|
||
public function getEventDispatcher(): EventDispatcherInterface | ||
{ | ||
return $this->getEmitter(); | ||
} | ||
|
||
public function getListenerRegistry(): ListenerRegistry | ||
{ | ||
return $this->getEmitter(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace League\OAuth2\Server\EventEmitting; | ||
|
||
use League\Event\EventDispatcher; | ||
use League\Event\ListenerPriority; | ||
|
||
final class EventEmitter extends EventDispatcher | ||
{ | ||
public function addListener(string $event, callable $listener, int $priority = ListenerPriority::NORMAL): self | ||
{ | ||
$this->subscribeTo($event, $listener, $priority); | ||
|
||
return $this; | ||
} | ||
|
||
public function emit(object $event): object | ||
{ | ||
return $this->dispatch($event); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters