1 | <?php |
||
17 | class NotFoundHandler extends Plugin |
||
18 | { |
||
19 | /** |
||
20 | * The dispatch data to forward an invalid handler. |
||
21 | * |
||
22 | * @var array|null |
||
23 | */ |
||
24 | private $forwardHandlerNotFound; |
||
25 | |||
26 | /** |
||
27 | * The dispatch data to forward an invalid action. |
||
28 | * |
||
29 | * @var array|null |
||
30 | */ |
||
31 | private $forwardActionNotFound; |
||
32 | |||
33 | /** |
||
34 | * The dispatch data to forward an uncaught exception. The dispatcher will have an additional |
||
35 | * parameter "exception" that contains the handled dispatch <tt>\Exception</tt>. |
||
36 | * |
||
37 | * @var array|null |
||
38 | */ |
||
39 | private $forwardUnhandledException; |
||
40 | |||
41 | /** |
||
42 | * NotFoundPlugin constructor. |
||
43 | * |
||
44 | * @param array|null $forwardHandlerNotFound The dispatch data to forward an invalid handler. |
||
45 | * @param array|null $forwardActionNotFound The dispatch data to forward an invalid action. |
||
46 | * @param array|null $forwardUnhandledException The dispatch data to forward an uncaught exception. The dispatcher |
||
47 | * will have an additional parameter "exception" that contains the |
||
48 | * handled dispatch <tt>\Exception</tt>. |
||
49 | */ |
||
50 | public function __construct(array $forwardHandlerNotFound = null, array $forwardActionNotFound = null, |
||
57 | |||
58 | /** |
||
59 | * Handled when the dispatcher throws an exception of any kind. |
||
60 | * |
||
61 | * @param \Phalcon\Events\Event $event The beforeDispatchLoop event. |
||
62 | * @param \Phalcon\Mvc\Dispatcher $dispatcher The application dispatcher instance. |
||
63 | * @param \Exception $exception The exception being handled. |
||
64 | * |
||
65 | * @return void|false Returns <tt>false</tt> if the exception is dispatched to a specific error handler; otherwise |
||
66 | * returns <tt>null</tt>. |
||
67 | */ |
||
68 | public function beforeException(Event $event, Dispatcher $dispatcher, Exception $exception) |
||
82 | |||
83 | /** |
||
84 | * Convenience helper method to ensure that only dispatched exceptions return <tt>false</tt>, which is |
||
85 | * important as this stops the current dispatch loop. |
||
86 | * |
||
87 | * @param \Phalcon\Mvc\Dispatcher $dispatcher The application dispatcher instance. |
||
88 | * @param \Exception $exception The exception being handled. |
||
89 | * @param array|null $forward Optional dispatch data. |
||
90 | * |
||
91 | * @return void|false Returns <tt>false</tt> if the exception is dispatched to a specific error handler; otherwise |
||
92 | * returns <tt>null</tt>. |
||
93 | */ |
||
94 | private function forward(Dispatcher $dispatcher, Exception $exception, array $forward = null) |
||
108 | } |
||
109 |