Class Controller
The master controller class for the Alpha Framework.
Direct known subclasses
Alpha\Controller\ActiveRecordController
,
Alpha\Controller\AttachmentController
,
Alpha\Controller\LogController
,
Alpha\Controller\LoginController
,
Alpha\Controller\LogoutController
,
Alpha\Controller\MetricController
,
Alpha\Controller\PhpinfoController
,
Alpha\Controller\RecordSelectorController
,
Alpha\Controller\SearchController
,
Alpha\Controller\CacheController
,
Alpha\Controller\ExcelController
,
Alpha\Controller\FeedController
,
Alpha\Controller\GenSecureQueryStringController
,
Alpha\Controller\ImageController
,
Alpha\Controller\IndexController
,
Alpha\Controller\InstallController
,
Alpha\Controller\ListActiveRecordsController
Indirect known subclasses
Alpha\Controller\ArticleController
,
Alpha\Controller\DEnumController
,
Alpha\Controller\SequenceController
,
Alpha\Controller\TagController
Namespace: Alpha\Controller
Copyright:
Copyright (c) 2018, John Collins (founder of Alpha Framework). All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the Alpha Framework nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
License: The BSD License
Author: John Collins dev@alphaframework.org
Since: 1.0
Located at Controller/Controller.php
Methods summary
public
|
#
__construct( string $visibility = 'Public' )
Constructor for the Controller that starts a new session if required, and handles the population of new/dirty objects from the session when available. Accepts the name of the rights group that has access to this controller, 'Public' by default. |
public
|
|
public
|
|
public
string
|
|
public
|
|
public
string
|
|
public
|
#
setVisibility( string $visibility )
Setter for the name of the rights group that has access to this controller. |
public
string
|
|
public
string
|
|
public
string
|
|
public
string
|
|
public
|
#
setUnitOfWork( array $jobs )
Sets the name of the controller job sequence to the values in the supplied array (and stores the array in the session). |
public
|
|
public
|
#
setUnitStartTime( integer $year, integer $month, integer $day, integer $hour, integer $minute, integer $second )
Setter for the unit start time (value will be stored in the session as key unitStartTime). |
public
|
|
public
|
#
setUnitEndTime( integer $year, integer $month, integer $day, integer $hour, integer $minute, integer $second )
Setter for the unit end time (value will be stored in the session as key unitEndTime). |
public
|
|
public
|
|
public
integer
|
|
public
|
#
markDirty(
Adds the supplied business object to the dirtyObjects array in the session. |
public
array
|
|
public
|
#
markNew(
Adds a newly created business object to the newObjects array in the session. |
public
array
|
|
public
|
|
public
|
|
public
|
#
clearUnitOfWorkAttributes( )
Clears the session and object attributes related to unit of work sessions. |
public
string
|
|
public
|
|
public
string
|
|
public
|
|
public
string
|
|
public
|
#
setKeywords( string $keywords )
Setter for the page keywords, should pass a comma-seperated list as a string. |
public
|
#
accessError( )
Method to return an access error for trespassing users. HTTP response header code will be 403. |
public
boolean
|
#
checkRights( )
Checks the user rights of the currently logged-in person against the page visibility set for this controller. Will return false if the user has not got the correct rights. |
public
boolean
|
#
checkSecurityFields( )
Method to check the validity of the two hidden form security fields which aim to ensure that a post to the controller is being sent from the same server that is hosting it. |
public static
string[]
|
|
public static
string
|
#
getCustomControllerName( string $ActiveRecordType )
Returns the name of a custom controller if one is found, otherwise returns null. |
public
|
|
public
string
|
#
getStatusMessage( )
Gets the current status message for this controller. Note that by getting the current status message, you clear out the value stored in the session so this method can only be used to get the status message once for display purposes. |
public static
boolean
|
#
checkControllerDefExists( string $controllerName )
Checks that the definition for the controller classname provided exists. Will also return true if you pass "/" for the root of the web application. |
public static
|
#
loadControllerDef( string $controllerName )
Loads the definition for the controller classname provided. |
public
boolean
|
#
checkIfAccessingFromSecureURL( )
Method for determining if the current request URL is a secure one (has a tk string or not). |
public static
string
|
#
generateURLSlug( string $URLPart, string $seperator = '-', array $filter = array(), boolean $crc32Prefix = false )
Converts the supplied string to a "slug" that is URL safe and suitable for SEO. |
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
#
process(
Maps the supplied request with the appropiate method to run on this controller, for example GET to doGET(), POST to doPOST() etc. Returns the response generated by the method called. |
public
|
|
public
|
|
public
string
|
#
after_displayPageHead_callback( )
Use this callback to inject in the admin menu template fragment. |
Properties summary
protected
string
|
$name
The name of the controller. |
|
protected
string
|
$visibility
Used to set access privileages for the controller to the name of the rights group allowed to access it. 'Public' by default. |
#
'Public'
|
protected
|
$record
Optionally, the main record object that this controller is currently working with. |
#
null
|
protected
string
|
$unitOfWork
Used to determine if the controller is part of a unit of work sequence (either empty or the name of the unit). |
|
protected
|
$unitStartTime
Stores the start time of a unit of work transaction. |
|
protected
|
$unitEndTime
Stores the end time of a unit of work transaction. |
|
protected
|
$unitMAXDuration
Stores the maximum allowed time duration (in seconds) of the unit of work. |
|
protected
string
|
$firstJob
The name of the first controller that is used in this unit of work. |
|
protected
string
|
$nextJob
The name of the next controller that is used in this unit of work. |
|
protected
string
|
$previousJob
The name of the previous controller that is used in this unit of work. |
|
protected
string
|
$lastJob
The name of the last controller that is used in this unit of work. |
|
protected
array
|
$dirtyObjects
An array for storing dirty record objects in a session (i.e. persistent business objects that have not been updated in the database yet). |
#
array()
|
protected
array
|
$newObjects
An array for storing new reord objects in a session (transient business objects that have no ID yet). |
#
array()
|
protected
string
|
$title
The title to be displayed on the controller page. |
|
protected
string
|
$keywords
Meta keywords for the controller page, generally populated from tags. |
|
protected
string
|
$description
Meta description for the controller page. |
|
protected
string
|
$statusMessage
Used to set status update messages to display to the user (messages stored between requests in session). Useful for when you want to display a message to a user after POSTing a request, or when moving from one page to the next. |
|
protected
|
$request
The request that has been passed to this controller for processing. |