|Classes of Fernando Val||>||Springy||>||documentation/en/library/Controller.md||>||Download|
Controller is a simple class you can extend to create controllers for your application.
All properties are protected and can be changed by child classes.
|Property|Type|Description|Default Value| |---|---|---|---| |$authNeeded|boolean|Define if the controller is restricted to signed in users.|false| |$redirectUnsigned|mixed|Define a URL to redirect the user if it is not signed ($authNeeded must be true). Can be a string or an array used by URI::buildUrl();|*false| |$signedUser|object|The current user signed in object.|null| |$tplIsCached|boolean|Define if the template's page must be cached.|false| |$tplCacheTime|integer|Define the live time (in seconds) of the cache.|1800| |$tplCacheId|string|Define an identificator to the template cache.|null|
In below example, no authenticated users will be redirected to /login page.
|Name|Type|Description| |---|---|---| |__construct()|public|The constructor method.| |_authorizationCheck()|protected|Check the user permission for the called method.| |_forbidden()|protected|Ends application with a 403 - Forbidden page error.| |_pageNotFound()|protected|Ends with a 404 - Page not found error.| |_redirect()|protected|Redirect the user to another URL.| |_template()|protected|Template initialization method.| |_userSpecialVerifications()|protected|Do all user special verifications.|
This method is called by PHP when the object is created. All default verification is made by this method, before other methos been called by the framework.
This is an internal method you can use to check the user permission. By default it calls the method isPermitted() of the Security/AclManager class who calls the method getPermissionFor() of your user model class. The the user has no access grant to the module, the method _forbidden() is invoked.
This method verify if neeed redirect user to another page ($redirectUnsigned property) and if not send a error 403 - Forbidden to the user.
This method only send a 404 - Page Not Found to the user.
This method redirect the user to the given URL. The parameter $url must be a string or an array with segments that will be contatenated by URI::buildURL() method.
This method can be used to start your controller's view template. A new Template object is created, it's cache is validated and then it is returned.
The $template parameter can be a string or an array. If not $template parameter if defined, the framework will elect one correspondent to the controller.
This method can be changed in child controller to extends all verification you need to do on user account to grant access to page. Example: if you need to check the user account is suspended.
They will return