-
Notifications
You must be signed in to change notification settings - Fork 0
The Dispatcher
The Dispatcher is what handles the request on behalf of your component (be it a web request or an HMVC request). Its job is to decide which controller to create and which task to run. Further to that it works with the TransparentAuthentication object to handle transparent authentication which comes in really handy if you want to perform remote requests to your component, interacting with access-restricted data or actions (viewing items protected behind a login, performing privileged operations such as creating / editing / deleting records and so on).
The class is called Dispatcher and it's placed inside the Dispatcher namespace of your component. For example:
<?php
namespace Acme\MyComponent\Site\Dispatcher;
class Dispatcher extends \FOF30\Dispatcher\Dispatcher
{
}
The file must be called Dispatcher.php and placed inside your component's Dispatcher directory for FOF's PSR-4 autoloader to find it.
If the Dispatcher class cannot be found FOF will fall back to creating a suitably configured instance of \FOF30\Dispatcher\Dispatcher
, using convention over configuration to determine what the Dispatcher object should do.
Unlike plain old Joomla! you are NOT supposed to copy and paste code when dealing with FOF. Our rule of thumb is that if you ever find yourself copying code from Dispatcher into your extension's specialised table class you're doing it wrong.
FOF dispatcher can be customised very easily using the onBeforeDispatch
/ onAfterDispatch
methods. onBeforeDispatch
runs before the dispatcher executes and onAfterDispatch
runs right after the dispatcher executes. Throwing an exception will result in a 403 Forbidden error.
Please note that when your component is running under CLI it will use the onBeforeDispatchCLI
and onAfterDispatchCLI
methods.
FOF (Framework on Framework) and its documentation are Copyright © 2010-2020 Nicholas K. Dionysopoulos / Akeeba Ltd.
FOF is Open Source Software, distributed under the GNU General Public License, version 2 of the license, or (at your option) any later version.
The FOF Wiki content is provided under the GNU Free Documentation License, version 1.3 of the license, or (at your option) any later version.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license can be found on the GNU site.