File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
src/Symfony/Component/Scheduler Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -141,20 +141,32 @@ public function getSchedule(): static
141
141
142
142
public function before (callable $ listener , int $ priority = 0 ): static
143
143
{
144
+ if (!$ this ->dispatcher ) {
145
+ throw new LogicException (sprintf ('To register a listener with "%s()", you need to set an event dispatcher on the Schedule. ' , __METHOD__ ));
146
+ }
147
+
144
148
$ this ->dispatcher ->addListener (PreRunEvent::class, $ listener , $ priority );
145
149
146
150
return $ this ;
147
151
}
148
152
149
153
public function after (callable $ listener , int $ priority = 0 ): static
150
154
{
155
+ if (!$ this ->dispatcher ) {
156
+ throw new LogicException (sprintf ('To register a listener with "%s()", you need to set an event dispatcher on the Schedule. ' , __METHOD__ ));
157
+ }
158
+
151
159
$ this ->dispatcher ->addListener (PostRunEvent::class, $ listener , $ priority );
152
160
153
161
return $ this ;
154
162
}
155
163
156
164
public function onFailure (callable $ listener , int $ priority = 0 ): static
157
165
{
166
+ if (!$ this ->dispatcher ) {
167
+ throw new LogicException (sprintf ('To register a listener with "%s()", you need to set an event dispatcher on the Schedule. ' , __METHOD__ ));
168
+ }
169
+
158
170
$ this ->dispatcher ->addListener (FailureEvent::class, $ listener , $ priority );
159
171
160
172
return $ this ;
You can’t perform that action at this time.
0 commit comments