├── CHANGELOG.md ├── Event.php ├── EventDispatcherInterface.php ├── LICENSE ├── README.md └── composer.json /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | CHANGELOG 2 | ========= 3 | 4 | The changelog is maintained for all Symfony contracts at the following URL: 5 | https://github.com/symfony/contracts/blob/main/CHANGELOG.md 6 | -------------------------------------------------------------------------------- /Event.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace Symfony\Contracts\EventDispatcher; 13 | 14 | use Psr\EventDispatcher\StoppableEventInterface; 15 | 16 | /** 17 | * Event is the base class for classes containing event data. 18 | * 19 | * This class contains no event data. It is used by events that do not pass 20 | * state information to an event handler when an event is raised. 21 | * 22 | * You can call the method stopPropagation() to abort the execution of 23 | * further listeners in your event listener. 24 | * 25 | * @author Guilherme Blanco 26 | * @author Jonathan Wage 27 | * @author Roman Borschel 28 | * @author Bernhard Schussek 29 | * @author Nicolas Grekas 30 | */ 31 | class Event implements StoppableEventInterface 32 | { 33 | private bool $propagationStopped = false; 34 | 35 | public function isPropagationStopped(): bool 36 | { 37 | return $this->propagationStopped; 38 | } 39 | 40 | /** 41 | * Stops the propagation of the event to further event listeners. 42 | * 43 | * If multiple event listeners are connected to the same event, no 44 | * further event listener will be triggered once any trigger calls 45 | * stopPropagation(). 46 | */ 47 | public function stopPropagation(): void 48 | { 49 | $this->propagationStopped = true; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /EventDispatcherInterface.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace Symfony\Contracts\EventDispatcher; 13 | 14 | use Psr\EventDispatcher\EventDispatcherInterface as PsrEventDispatcherInterface; 15 | 16 | /** 17 | * Allows providing hooks on domain-specific lifecycles by dispatching events. 18 | */ 19 | interface EventDispatcherInterface extends PsrEventDispatcherInterface 20 | { 21 | /** 22 | * Dispatches an event to all registered listeners. 23 | * 24 | * @template T of object 25 | * 26 | * @param T $event The event to pass to the event handlers/listeners 27 | * @param string|null $eventName The name of the event to dispatch. If not supplied, 28 | * the class of $event should be used instead. 29 | * 30 | * @return T The passed $event MUST be returned 31 | */ 32 | public function dispatch(object $event, ?string $eventName = null): object; 33 | } 34 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018-present Fabien Potencier 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is furnished 8 | to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Symfony EventDispatcher Contracts 2 | ================================= 3 | 4 | A set of abstractions extracted out of the Symfony components. 5 | 6 | Can be used to build on semantics that the Symfony components proved useful and 7 | that already have battle tested implementations. 8 | 9 | See https://github.com/symfony/contracts/blob/main/README.md for more information. 10 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "symfony/event-dispatcher-contracts", 3 | "type": "library", 4 | "description": "Generic abstractions related to dispatching event", 5 | "keywords": ["abstractions", "contracts", "decoupling", "interfaces", "interoperability", "standards"], 6 | "homepage": "https://symfony.com", 7 | "license": "MIT", 8 | "authors": [ 9 | { 10 | "name": "Nicolas Grekas", 11 | "email": "p@tchwork.com" 12 | }, 13 | { 14 | "name": "Symfony Community", 15 | "homepage": "https://symfony.com/contributors" 16 | } 17 | ], 18 | "require": { 19 | "php": ">=8.1", 20 | "psr/event-dispatcher": "^1" 21 | }, 22 | "autoload": { 23 | "psr-4": { "Symfony\\Contracts\\EventDispatcher\\": "" } 24 | }, 25 | "minimum-stability": "dev", 26 | "extra": { 27 | "branch-alias": { 28 | "dev-main": "3.6-dev" 29 | }, 30 | "thanks": { 31 | "name": "symfony/contracts", 32 | "url": "https://github.com/symfony/contracts" 33 | } 34 | } 35 | } 36 | --------------------------------------------------------------------------------