2010-01-04 14:26:20 +00:00
< ? php
/*
2011-08-21 13:32:21 +01:00
* This file is part of the Symfony package .
2010-04-07 02:07:59 +01:00
*
2011-08-21 13:32:21 +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
*/
2011-01-15 13:29:43 +00:00
namespace Symfony\Component\EventDispatcher ;
2010-01-04 14:26:20 +00:00
/**
2011-03-13 18:03:18 +00:00
* Event is the base class for classes containing event data .
2010-01-04 14:26:20 +00:00
*
2011-03-13 18:03:18 +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 .
*
2014-12-07 17:02:39 +00:00
* @ 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 >
2010-01-04 14:26:20 +00:00
*/
2011-03-13 18:03:18 +00:00
class Event
2010-01-04 14:26:20 +00:00
{
2010-05-06 12:25:53 +01:00
/**
2014-12-20 17:15:52 +00:00
* @ var bool Whether no further event listeners should be triggered
2010-05-06 12:25:53 +01:00
*/
2011-03-13 18:03:18 +00:00
private $propagationStopped = false ;
2010-05-06 12:25:53 +01:00
2011-11-06 12:48:47 +00:00
/**
* @ var EventDispatcher Dispatcher that dispatched this event
*/
private $dispatcher ;
2011-12-18 13:33:54 +00:00
2011-11-11 05:13:54 +00:00
/**
* @ var string This event ' s name
*/
private $name ;
2011-11-06 12:48:47 +00:00
2010-05-06 12:25:53 +01:00
/**
2011-03-13 18:03:18 +00:00
* Returns whether further event listeners should be triggered .
2010-05-06 12:25:53 +01:00
*
2014-12-21 16:36:15 +00:00
* @ see Event :: stopPropagation ()
2014-12-21 17:00:50 +00:00
*
2014-11-30 13:33:44 +00:00
* @ return bool Whether propagation was already stopped for this event .
2010-05-06 12:25:53 +01:00
*/
2011-03-13 18:03:18 +00:00
public function isPropagationStopped ()
2010-05-06 12:25:53 +01:00
{
2011-03-13 18:03:18 +00:00
return $this -> propagationStopped ;
2010-05-06 12:25:53 +01:00
}
/**
2011-03-13 18:03:18 +00:00
* Stops the propagation of the event to further event listeners .
2010-05-06 12:25:53 +01:00
*
2011-03-13 18:03:18 +00:00
* If multiple event listeners are connected to the same event , no
* further event listener will be triggered once any trigger calls
* stopPropagation () .
2010-05-06 12:25:53 +01:00
*/
2011-03-13 18:03:18 +00:00
public function stopPropagation ()
2010-05-06 12:25:53 +01:00
{
2011-03-13 18:03:18 +00:00
$this -> propagationStopped = true ;
2010-05-06 12:25:53 +01:00
}
2011-11-06 12:48:47 +00:00
/**
2014-12-21 17:00:50 +00:00
* Stores the EventDispatcher that dispatches this Event .
2011-11-06 12:48:47 +00:00
*
2012-07-18 17:23:30 +01:00
* @ param EventDispatcherInterface $dispatcher
2011-11-06 12:48:47 +00:00
*
2014-12-29 19:15:36 +00:00
* @ deprecated since version 2.4 , to be removed in 3.0 . The event dispatcher is passed to the listener call .
2011-11-06 12:48:47 +00:00
*/
2012-07-18 17:23:30 +01:00
public function setDispatcher ( EventDispatcherInterface $dispatcher )
2011-11-06 12:48:47 +00:00
{
$this -> dispatcher = $dispatcher ;
}
/**
2014-12-21 17:00:50 +00:00
* Returns the EventDispatcher that dispatches this Event .
2011-11-06 12:48:47 +00:00
*
2012-07-18 17:23:30 +01:00
* @ return EventDispatcherInterface
2011-11-06 12:48:47 +00:00
*
2014-12-29 19:15:36 +00:00
* @ deprecated since version 2.4 , to be removed in 3.0 . The event dispatcher is passed to the listener call .
2011-11-06 12:48:47 +00:00
*/
public function getDispatcher ()
{
2015-06-07 07:33:05 +01:00
@ trigger_error ( 'The ' . __METHOD__ . ' method is deprecated since version 2.4 and will be removed in 3.0. The event dispatcher instance can be received in the listener call instead.' , E_USER_DEPRECATED );
2014-12-21 11:39:54 +00:00
2011-11-06 12:48:47 +00:00
return $this -> dispatcher ;
}
2011-12-18 13:33:54 +00:00
2011-11-11 05:13:54 +00:00
/**
* Gets the event ' s name .
2011-12-18 13:33:54 +00:00
*
2011-11-11 05:13:54 +00:00
* @ return string
2011-12-18 13:33:54 +00:00
*
2014-12-29 19:15:36 +00:00
* @ deprecated since version 2.4 , to be removed in 3.0 . The event name is passed to the listener call .
2011-11-11 05:13:54 +00:00
*/
public function getName ()
{
2015-06-07 07:33:05 +01:00
@ trigger_error ( 'The ' . __METHOD__ . ' method is deprecated since version 2.4 and will be removed in 3.0. The event name can be received in the listener call instead.' , E_USER_DEPRECATED );
2014-12-21 11:39:54 +00:00
2011-11-11 05:13:54 +00:00
return $this -> name ;
}
2011-12-18 13:33:54 +00:00
2011-11-11 05:13:54 +00:00
/**
* Sets the event ' s name property .
2011-12-18 13:33:54 +00:00
*
2011-11-11 05:13:54 +00:00
* @ param string $name The event name .
2011-12-18 13:33:54 +00:00
*
2014-12-29 19:15:36 +00:00
* @ deprecated since version 2.4 , to be removed in 3.0 . The event name is passed to the listener call .
2011-11-11 05:13:54 +00:00
*/
public function setName ( $name )
{
$this -> name = $name ;
}
2010-01-04 14:26:20 +00:00
}