This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component/EventDispatcher/Event.php

122 lines
2.7 KiB
PHP
Raw Normal View History

2010-01-04 14:26:20 +00:00
<?php
/*
* This file is part of the Symfony package.
2010-04-07 02:07:59 +01:00
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
2010-01-04 14:26:20 +00:00
*/
namespace Symfony\Component\EventDispatcher;
2010-01-04 14:26:20 +00:00
/**
* Event is the base class for classes containing event data.
2010-01-04 14:26:20 +00:00
*
* This class contains no event data. It is used by events that do not pass
* state information to an event handler when an event is raised.
*
* You can call the method stopPropagation() to abort the execution of
* further listeners in your event listener.
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
* @author Bernhard Schussek <bschussek@gmail.com>
2011-06-14 13:40:48 +01:00
*
* @api
2010-01-04 14:26:20 +00:00
*/
class Event
2010-01-04 14:26:20 +00:00
{
/**
2014-04-16 11:30:19 +01:00
* @var bool Whether no further event listeners should be triggered
*/
private $propagationStopped = false;
/**
* @var EventDispatcher Dispatcher that dispatched this event
*/
private $dispatcher;
2011-12-18 13:33:54 +00:00
/**
* @var string This event's name
*/
private $name;
/**
* Returns whether further event listeners should be triggered.
*
* @see Event::stopPropagation
2014-04-16 11:30:19 +01:00
* @return bool Whether propagation was already stopped for this event.
2011-06-14 13:40:48 +01:00
*
* @api
*/
public function isPropagationStopped()
{
return $this->propagationStopped;
}
/**
* Stops the propagation of the event to further event listeners.
*
* If multiple event listeners are connected to the same event, no
* further event listener will be triggered once any trigger calls
* stopPropagation().
2011-06-14 13:40:48 +01:00
*
* @api
*/
public function stopPropagation()
{
$this->propagationStopped = true;
}
/**
* Stores the EventDispatcher that dispatches this Event
*
* @param EventDispatcherInterface $dispatcher
*
* @api
*/
public function setDispatcher(EventDispatcherInterface $dispatcher)
{
$this->dispatcher = $dispatcher;
}
/**
* Returns the EventDispatcher that dispatches this Event
*
* @return EventDispatcherInterface
*
* @api
*/
public function getDispatcher()
{
return $this->dispatcher;
}
2011-12-18 13:33:54 +00:00
/**
* Gets the event's name.
2011-12-18 13:33:54 +00:00
*
* @return string
2011-12-18 13:33:54 +00:00
*
* @api
*/
public function getName()
{
return $this->name;
}
2011-12-18 13:33:54 +00:00
/**
* Sets the event's name property.
2011-12-18 13:33:54 +00:00
*
* @param string $name The event name.
2011-12-18 13:33:54 +00:00
*
* @api
*/
public function setName($name)
{
$this->name = $name;
}
2010-01-04 14:26:20 +00:00
}