Stud.IP  6.0
Controller Class Reference
Inheritance diagram for Controller:
Admin_InstallController StudipController Accessibility_FormsController AuthenticatedController BannerController Calendar_ContentboxController CaptchaController CasController Course_LtiController Courseware_PublicController DocumentController ExternController ForumController iCalController IliasAuthController MediaProxyController NewPasswordController NewsController OAuth2Controller Oer_EndpointsController Oer_MarketController Oer_OaiController PluginController PluginsController SiteinfoController StudipControllerTestController WebMigrateController

Public Member Functions

 __construct (Dispatcher $dispatcher)
 
 erase_response ()
 
 get_response ()
 
 perform ($unconsumed)
 
 extract_action_and_args ($string)
 
 default_action_and_args ()
 
 map_action ($action)
 
 before_filter (&$action, &$args)
 
 after_filter ($action, $args)
 
 does_not_understand ($action, $args)
 
 redirect ($to)
 
 render_text ($text=' ')
 
 render_nothing ()
 
 render_action ($action)
 
 get_default_template ($action)
 
 render_template ($template_name, $layout=null)
 
 get_template_factory ()
 
 get_assigned_variables ()
 
 set_layout ($layout)
 
 url_for ($to)
 
 set_status ($status, $reason_phrase=null)
 
 set_content_type ($type)
 
 rescue ($exception)
 
 respond_to ($ext)
 

Protected Attributes

Dispatcher $dispatcher
 
Response $response
 
bool $performed = false
 
Template string null $layout = null
 

Constructor & Destructor Documentation

◆ __construct()

__construct ( Dispatcher  $dispatcher)
Parameters
Dispatcher$dispatcherthe dispatcher who creates this instance

Member Function Documentation

◆ after_filter()

after_filter (   $action,
  $args 
)

Callback function being called after an action is executed.

Parameters
string$actionName of the action to perform.
array$argsAn array of arguments to the action.
Returns
void

◆ before_filter()

before_filter ( $action,
$args 
)

Callback function being called before an action is executed. If this function does not return FALSE, the action will be called, otherwise an error will be generated and processing will be aborted. If this function already #rendered or #redirected, further processing of the action is withheld.

Parameters
string$actionName of the action to perform.
array$argsAn array of arguments to the action.
Returns
bool|void

◆ default_action_and_args()

default_action_and_args ( )

Return the default action and arguments

Returns
array containing the action, an array of args and the format

◆ does_not_understand()

does_not_understand (   $action,
  $args 
)
Parameters
string$action
array$args
Returns
void
Exceptions
UnknownAction

◆ erase_response()

erase_response ( )

Resets the response of the controller

Returns
void

◆ extract_action_and_args()

extract_action_and_args (   $string)

Extracts action and args from a string.

Parameters
string$stringthe processed string
Returns
array an array with two elements - a string containing the action and an array of strings representing the args

◆ get_assigned_variables()

get_assigned_variables ( )

This method returns all the set instance variables to be used as attributes for a template. This controller is returned too as value for key 'controller'.

Returns
array an associative array of variables for the template

◆ get_default_template()

get_default_template (   $action)

◆ get_response()

get_response ( )

Return this controller's response

Returns
Response the controller's response

◆ get_template_factory()

get_template_factory ( )

Create and return a template factory for this controller.

Returns
Factory

◆ map_action()

map_action (   $action)

Maps the action to an actual method name.

Parameters
string$action
Returns
array the mapped method name

◆ perform()

perform (   $unconsumed)

This method extracts an action string and further arguments from it's parameter. The action string is mapped to a method being called afterwards using the said arguments. That method is called and a response object is generated, populated and sent back to the dispatcher.

Parameters
string$unconsumed
Returns
Response
Exceptions
UnknownAction

◆ redirect()

redirect (   $to)
Parameters
string$to
Returns
void
Exceptions
DoubleRenderError

◆ render_action()

render_action (   $action)

Renders the template of the given action as the response's body.

Parameters
string$actionthe action
Returns
void

◆ render_nothing()

render_nothing ( )

Renders the empty string as the response's body.

Returns
void
Exceptions
DoubleRenderError

◆ render_template()

render_template (   $template_name,
  $layout = null 
)

Renders a template using an optional layout template.

Parameters
Template | string$template_namea flexi template
Template | string | null$layouta flexi template which is used as layout
Returns
void
Exceptions
DoubleRenderError
TemplateNotFoundException

◆ render_text()

render_text (   $text = ' ')

Renders the given text as the body of the response.

Parameters
string$textthe text to be rendered
Returns
void
Exceptions
DoubleRenderError

◆ rescue()

rescue (   $exception)

Exception handler called when the performance of an action raises an exception.

Parameters
\Throwable$exceptionthe thrown exception
Returns
Response a response object

◆ respond_to()

respond_to (   $ext)

◆ set_content_type()

set_content_type (   $type)

Sets the content type of the controller's response.

Parameters
string$typethe content type
Returns
void

◆ set_layout()

set_layout (   $layout)

Sets the layout to be used by this controller per default.

Parameters
Template | string | null$layouta flexi template to be used as layout
Returns
void

◆ set_status()

set_status (   $status,
  $reason_phrase = null 
)
Parameters
int$status
Returns
void

◆ url_for()

url_for (   $to)

Returns a URL to a specified route to your Trails application.

Example: Your Trails application is located at 'http://example.com/dispatch.php'. So your dispatcher's trails_uri is set to 'http://example.com/dispatch.php' If you want the URL to your 'wiki' controller with action 'show' and parameter 'page' you should send:

$url = $controller->url_for('wiki/show', 'page');

$url should then contain 'http://example.com/dispatch.php/wiki/show/page'.

The first parameter is a string containing the controller and optionally an action:

  • "{controller}/{action}"
  • "path/to/controller/action"
  • "controller"

This "controller/action" string is not url encoded. You may provide additional parameter which will be urlencoded and concatenated with slashes:

$controller->url_for('wiki/show', 'page');
-> 'wiki/show/page'

$controller->url_for('wiki/show', 'page', 'one and a half');
-> 'wiki/show/page/one+and+a+half'
Parameters
string$toa string containing a controller and optionally an action
Returns
string a URL to this route

Field Documentation

◆ $dispatcher

Dispatcher $dispatcher
protected

◆ $layout

Template string null $layout = null
protected

◆ $performed

bool $performed = false
protected

◆ $response

Response $response
protected

The documentation for this class was generated from the following file: