During normal process flow, a controller is run at the middle of the process (as shown in the Presentation). However, you may want to run code before and/or after a controller. Some possible cases are:

- you don’t know beforehand which node should be run : a node ID can be computed just before it’s run
- you want to encapsulate a controller, to control its conditions
- you want to capture the controller output

The basic idea is that a deferred is called before and after an existing controller is run, like this:

1 – $nodeRef = $deferred->reduce()
2 – $navigation->checkNode($node)
3 – $node->executeController()
4 – $deferred->failure() and exception handling
OR $deferred->success()
5 – theme output

Reduce

You can see here that $deferred->reduce() has the chance to run before authorization checks are done, therefore it can alter the environment, for example to allow access based on other criteria (IP, time, …).

Failure

In case of failure, $deferred->failure() is run after the controller but before exception handling, giving you the opportunity to alter the exception, add info, change the behavior, etc.

Success

If the controller runs ok, $deferred->success() can capture or alter the output data before it’s displayed by the theme.

Réaction

Était-ce utile?

Oui Non
Vous avez indiqué que ce sujet ne vous a pas été utile ...
Pouvez-vous SVP laisser un commentaire nous disant pourquoi? Merci!
Merci pour vos commentaires.

Laissez votre avis sur ce sujet.

Valider