Recommend this page to a friend! |
Classes of Fernando Val | Springy | documentation/en/library/Controller.md | Download |
|
DownloadControllerAboutController is a simple class you can extend to create controllers for your application. PropertiesAll 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| Examples:
In below example, no authenticated users will be redirected to /login page.
Methods|Name|Type|Description| |---|---|---| |__construct()|public|The constructor method.| |authorizationCheck()|protected|Check the user permission for the called method.| |createTemplate()|protected|Template initialization 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.| |userSpecialVerifications()|protected|Do all user special verifications.| Methods Details__construct()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.
authorizationCheck()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.
createTemplate()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.
forbidden()This method verify if neeed redirect user to another page ($redirectUnsigned property) and if not send a error 403 - Forbidden to the user.
pageNotFound()This method only send a 404 - Page Not Found to the user.
redirect()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.
userSpecialVerifications()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
|