4
4
The Generic Event Object
5
5
========================
6
6
7
- The base :class: `Symfony\\ Component\\ EventDispatcher\\ Event ` class provided by the
8
- EventDispatcher component is deliberately sparse to allow the creation of
9
- API specific event objects by inheritance using OOP. This allows for elegant and
10
- readable code in complex applications.
7
+ The base :class: `Symfony\\ Component\\ EventDispatcher\\ Event ` class provided
8
+ by the EventDispatcher component is deliberately sparse to allow the creation
9
+ of API specific event objects by inheritance using OOP. This allows for
10
+ elegant and readable code in complex applications.
11
11
12
12
The :class: `Symfony\\ Component\\ EventDispatcher\\ GenericEvent ` is available
13
- for convenience for those who wish to use just one event object throughout their
14
- application. It is suitable for most purposes straight out of the box, because
15
- it follows the standard observer pattern where the event object
13
+ for convenience for those who wish to use just one event object throughout
14
+ their application. It is suitable for most purposes straight out of the
15
+ box, because it follows the standard observer pattern where the event object
16
16
encapsulates an event 'subject', but has the addition of optional extra
17
17
arguments.
18
18
19
- :class: `Symfony\\ Component\\ EventDispatcher\\ GenericEvent ` has a simple API in
20
- addition to the base class :class: `Symfony\\ Component\\ EventDispatcher\\ Event `
19
+ :class: `Symfony\\ Component\\ EventDispatcher\\ GenericEvent ` has a simple
20
+ API in addition to the base class
21
+ :class: `Symfony\\ Component\\ EventDispatcher\\ Event `
21
22
22
23
* :method: `Symfony\\ Component\\ EventDispatcher\\ GenericEvent::__construct `:
23
24
Constructor takes the event subject and any arguments;
@@ -41,8 +42,8 @@ addition to the base class :class:`Symfony\\Component\\EventDispatcher\\Event`
41
42
Returns true if the argument key exists;
42
43
43
44
The ``GenericEvent `` also implements :phpclass: `ArrayAccess ` on the event
44
- arguments which makes it very convenient to pass extra arguments regarding the
45
- event subject.
45
+ arguments which makes it very convenient to pass extra arguments regarding
46
+ the event subject.
46
47
47
48
The following examples show use-cases to give a general idea of the flexibility.
48
49
The examples assume event listeners have been added to the dispatcher.
@@ -64,8 +65,8 @@ Simply passing a subject::
64
65
}
65
66
}
66
67
67
- Passing and processing arguments using the :phpclass: `ArrayAccess ` API to access
68
- the event arguments::
68
+ Passing and processing arguments using the :phpclass: `ArrayAccess ` API to
69
+ access the event arguments::
69
70
70
71
use Symfony\Component\EventDispatcher\GenericEvent;
71
72
0 commit comments