2018-07-31 11:54:00 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
/**
|
2019-05-28 20:46:36 +03:00
|
|
|
* @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
|
|
|
|
*
|
2019-12-03 21:57:53 +03:00
|
|
|
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
|
2018-07-31 11:54:00 +03:00
|
|
|
*
|
|
|
|
* @license GNU AGPL version 3 or any later version
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
2019-12-03 21:57:53 +03:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
2018-07-31 11:54:00 +03:00
|
|
|
*/
|
|
|
|
|
2019-05-28 20:46:36 +03:00
|
|
|
namespace OCP\EventDispatcher;
|
2018-07-31 11:54:00 +03:00
|
|
|
|
2021-02-10 11:13:02 +03:00
|
|
|
use Psr\EventDispatcher\StoppableEventInterface;
|
2018-07-31 11:54:00 +03:00
|
|
|
|
2019-05-28 20:46:36 +03:00
|
|
|
/**
|
|
|
|
* Base event class for the event dispatcher service
|
|
|
|
*
|
|
|
|
* Typically this class isn't instantiated directly but sub classed for specific
|
|
|
|
* event types
|
|
|
|
*
|
2021-02-10 11:13:02 +03:00
|
|
|
* This class extended \Symfony\Contracts\EventDispatcher\Event until 21.0, since
|
|
|
|
* 22.0.0 this class directly implements the PSR StoppableEventInterface and no
|
|
|
|
* longer relies on Symfony. This transition does not come with any changes in API,
|
|
|
|
* the class has the same methods and behavior before and after this change.
|
|
|
|
*
|
2019-05-28 20:46:36 +03:00
|
|
|
* @since 17.0.0
|
|
|
|
*/
|
2021-02-10 11:13:02 +03:00
|
|
|
class Event implements StoppableEventInterface {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var bool
|
|
|
|
*
|
|
|
|
* @since 22.0.0
|
|
|
|
*/
|
|
|
|
private $propagationStopped = false;
|
2019-09-10 12:37:53 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Compatibility constructor
|
|
|
|
*
|
|
|
|
* In Nextcloud 17.0.0 this event class used a now deprecated/removed Symfony base
|
|
|
|
* class that had a constructor (with default arguments). To lower the risk of
|
|
|
|
* a breaking change (PHP won't allow parent constructor calls if there is none),
|
|
|
|
* this empty constructor's only purpose is to hopefully not break existing sub-
|
|
|
|
* classes of this class.
|
|
|
|
*
|
|
|
|
* @since 18.0.0
|
|
|
|
*/
|
|
|
|
public function __construct() {
|
|
|
|
}
|
2021-02-10 11:13:02 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Stops the propagation of the event to further event listeners
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*
|
|
|
|
* @since 22.0.0
|
|
|
|
*/
|
|
|
|
public function stopPropagation(): void {
|
|
|
|
$this->propagationStopped = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*
|
|
|
|
* @since 22.0.0
|
|
|
|
* @see \Psr\EventDispatcher\StoppableEventInterface
|
|
|
|
*/
|
|
|
|
public function isPropagationStopped(): bool {
|
|
|
|
return $this->propagationStopped;
|
|
|
|
}
|
2018-07-31 11:54:00 +03:00
|
|
|
}
|