Events::prefix()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
/**
4
 * This file is part of the Kdyby (http://www.kdyby.org)
5
 *
6
 * Copyright (c) 2008 Filip Procházka ([email protected])
7
 *
8
 * For the full copyright and license information, please view the file license.txt that was distributed with this source code.
9
 */
10
11
namespace Kdyby\Doctrine;
12
13
use Kdyby;
14
use Nette;
15
16
17
18
/**
19
 * @author Filip Procházka <[email protected]>
20
 */
21
final class Events
22
{
23
24
	/**
25
	 * The namespace for listeners on Doctrine events.
26
	 */
27
	const NS = \Doctrine\ORM\Events::class;
28
29
	/**
30
	 * @deprecated
31
	 */
32
	const postLoadRelations = \Doctrine\ORM\Events::class . '::postLoadRelations';
33
34
	/**
35
	 * The preRemove event occurs for a given entity before the respective
36
	 * EntityManager remove operation for that entity is executed.
37
	 *
38
	 * This is an entity lifecycle event.
39
	 *
40
	 * @var string
41
	 */
42
	const preRemove = \Doctrine\ORM\Events::class . '::preRemove';
43
44
	/**
45
	 * The postRemove event occurs for an entity after the entity has
46
	 * been deleted. It will be invoked after the database delete operations.
47
	 *
48
	 * This is an entity lifecycle event.
49
	 *
50
	 * @var string
51
	 */
52
	const postRemove = \Doctrine\ORM\Events::class . '::postRemove';
53
54
	/**
55
	 * The prePersist event occurs for a given entity before the respective
56
	 * EntityManager persist operation for that entity is executed.
57
	 *
58
	 * This is an entity lifecycle event.
59
	 *
60
	 * @var string
61
	 */
62
	const prePersist = \Doctrine\ORM\Events::class . '::prePersist';
63
64
	/**
65
	 * The postPersist event occurs for an entity after the entity has
66
	 * been made persistent. It will be invoked after the database insert operations.
67
	 * Generated primary key values are available in the postPersist event.
68
	 *
69
	 * This is an entity lifecycle event.
70
	 *
71
	 * @var string
72
	 */
73
	const postPersist = \Doctrine\ORM\Events::class . '::postPersist';
74
75
	/**
76
	 * The preUpdate event occurs before the database update operations to
77
	 * entity data.
78
	 *
79
	 * This is an entity lifecycle event.
80
	 *
81
	 * @var string
82
	 */
83
	const preUpdate = \Doctrine\ORM\Events::class . '::preUpdate';
84
85
	/**
86
	 * The postUpdate event occurs after the database update operations to
87
	 * entity data.
88
	 *
89
	 * This is an entity lifecycle event.
90
	 *
91
	 * @var string
92
	 */
93
	const postUpdate = \Doctrine\ORM\Events::class . '::postUpdate';
94
95
	/**
96
	 * The postLoad event occurs for an entity after the entity has been loaded
97
	 * into the current EntityManager from the database or after the refresh operation
98
	 * has been applied to it.
99
	 *
100
	 * Note that the postLoad event occurs for an entity before any associations have been
101
	 * initialized. Therefore it is not safe to access associations in a postLoad callback
102
	 * or event handler.
103
	 *
104
	 * This is an entity lifecycle event.
105
	 *
106
	 * @var string
107
	 */
108
	const postLoad = \Doctrine\ORM\Events::class . '::postLoad';
109
110
	/**
111
	 * The loadClassMetadata event occurs after the mapping metadata for a class
112
	 * has been loaded from a mapping source (annotations/xml/yaml).
113
	 *
114
	 * @var string
115
	 */
116
	const loadClassMetadata = \Doctrine\ORM\Events::class . '::loadClassMetadata';
117
118
	/**
119
	 * The onClassMetadataNotFound event occurs whenever loading metadata for a class
120
	 * failed.
121
	 *
122
	 * @var string
123
	 */
124
	const onClassMetadataNotFound = \Doctrine\ORM\Events::class . '::onClassMetadataNotFound';
125
126
	/**
127
	 * The preFlush event occurs when the EntityManager#flush() operation is invoked,
128
	 * but before any changes to managed entities have been calculated. This event is
129
	 * always raised right after EntityManager#flush() call.
130
	 */
131
	const preFlush = \Doctrine\ORM\Events::class . '::preFlush';
132
133
	/**
134
	 * The onFlush event occurs when the EntityManager#flush() operation is invoked,
135
	 * after any changes to managed entities have been determined but before any
136
	 * actual database operations are executed. The event is only raised if there is
137
	 * actually something to do for the underlying UnitOfWork. If nothing needs to be done,
138
	 * the onFlush event is not raised.
139
	 *
140
	 * @var string
141
	 */
142
	const onFlush = \Doctrine\ORM\Events::class . '::onFlush';
143
144
	/**
145
	 * The postFlush event occurs when the EntityManager#flush() operation is invoked and
146
	 * after all actual database operations are executed successfully. The event is only raised if there is
147
	 * actually something to do for the underlying UnitOfWork. If nothing needs to be done,
148
	 * the postFlush event is not raised. The event won't be raised if an error occurs during the
149
	 * flush operation.
150
	 *
151
	 * @var string
152
	 */
153
	const postFlush = \Doctrine\ORM\Events::class . '::postFlush';
154
155
	/**
156
	 * The onClear event occurs when the EntityManager#clear() operation is invoked,
157
	 * after all references to entities have been removed from the unit of work.
158
	 *
159
	 * @var string
160
	 */
161
	const onClear = \Doctrine\ORM\Events::class . '::onClear';
162
163
164
165
	/**
166
	 * Private constructor. This class is not meant to be instantiated.
167
	 */
168
	private function __construct()
169
	{
170
	}
171
172
173
174
	/**
175
	 * @param string $eventName
176
	 * @return string
177
	 */
178
	public static function prefix($eventName)
179
	{
180
		return self::NS . '::' . $eventName;
181
	}
182
183
}
184