———

 
Translations of this page:

Controller

Built in controller

Built in controller includes following classes

  • controller/PageControllerUrl
  • controller/AbstractAction
  • controller/IndirectAction

Initializing the controller

$controller = new PageControllerUrl(__DIR__.'/action');
$controller->setErrorReporter($errorReporter);
 
$content = $controller->runActions();

URL to class mapping

Each url maps to corresponding class where directories are namespaces and files are classes. For example url /users/add.html maps to class add in namespace \action\users (assuming that root directory for action classes is named action).

Directory url like '/users/' is the same as '/users/index.html'.

Namespaces

Action directory is the PSR-4 base for actions.

i.e. if actions directory is 'action/', the /users/add.html action will go to 'action/users/' directory, the file will be 'add.php', the name space is 'action\users' and the class name is add:

action/users/add.php
namespace action\users;
 
class add extends nsfw\controller\AbstractAction{
 //....
}
 
nsfw3/tutorials/controller.txt · Last modified: 07.04.2017 14:55 by npelov
 
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki