Stud.IP  5.4
StudipController Class Reference
Inheritance diagram for StudipController:
Accessibility_FormsController Api_OauthController AuthenticatedController BannerController Calendar_ContentboxController 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

 before_filter (&$action, &$args)
 
 erase_response ()
 
 perform ($unconsumed_path)
 
 after_filter ($action, $args)
 
 validate_args (&$args, $types=null)
 
 url_for ($to='')
 
 link_for ($to='')
 
 redirect ($to)
 
 relocate ($to)
 
 rescue ($exception)
 
 render_json ($data)
 
 render_csv ($data, $filename=null, $delimiter=';', $enclosure='"')
 
 render_file ( $file, $filename=null, $content_type=null, $content_disposition='attachment', Closure $callback=null, $chunk_size=262144)
 
 render_temporary_file ( $file, $filename=null, $content_type=null, $content_disposition='attachment', Closure $callback=null, $chunk_size=262144)
 
 render_form (\Studip\Forms\Form $form)
 
 relay ($to_uri)
 
 relayWithRedirect (... $args)
 
 perform_relayed ($unconsumed)
 
 render_template_as_string ($template, $layout=null)
 
 __call ($method, $arguments)
 
 has_action ($action)
 
 action_url ($action)
 
 action_link ($action)
 
 validate_datetime ($datetime, $format='H:i')
 
 render_spreadsheet (array $header, array $data, string $format, string $filename, ?string $filepath=null)
 

Protected Member Functions

 render_pdf (TCPDF $pdf, $filename, $inline=false)
 
 controller_path ()
 
 getBodyElementIdForControllerAndAction ($unconsumed_path)
 

Protected Attributes

 $with_session = false
 
 $allow_nobody = true
 
 $_autobind = false
 

Member Function Documentation

◆ __call()

__call (   $method,
  $arguments 
)

Magic methods that intercepts all unknown method calls. If a method is called that matches an action on this controller, an url to that action is generated.

Basically, this:

$controller->url_for('foo/bar/baz/' . $param)

is equal to calling this on the Foo_BarController:

$controller->baz($param)

Parameters
String$methodCalled method name
array$argumetnsProvided arguments
Returns
url to the requested action
Exceptions
Trails_UnknownActionif no action matches the method

◆ action_link()

action_link (   $action)

Generates the link for an action on this controller without the neccessity to provide the full "path" to the action (since it is implicitely known).

Basically, this:

$controller->link_for('foo/bar/baz/' . $param)

is equal to calling this on the Foo_BarController:

$controller->action_link('baz/' . $param)

Parameters
string$actionName of the action
Returns
string to the requested action

◆ action_url()

action_url (   $action)

Generates the url for an action on this controller without the neccessity to provide the full "path" to the action (since it is implicitely known).

Basically, this:

$controller->url_for('foo/bar/baz/' . $param)

is equal to calling this on the Foo_BarController:

$controller->action_url('baz/' . $param)

Parameters
string$actionName of the action
Returns
string url to the requested action

◆ after_filter()

after_filter (   $action,
  $args 
)

Callback function being called after an action is executed.

Parameters
stringName of the action to perform.
arrayAn array of arguments to the action.
Returns
void

◆ before_filter()

before_filter ( $action,
$args 
)
Returns
false|void

◆ controller_path()

controller_path ( )
protected

Returns the url path to this controller.

Returns
string url path to this controller

◆ erase_response()

erase_response ( )

Extended method to inject extended response object.

◆ getBodyElementIdForControllerAndAction()

getBodyElementIdForControllerAndAction (   $unconsumed_path)
protected

Creates the body element id for this controller a given action.

Parameters
string$unconsumed_pathUnconsumed path to extract action from
Returns
string

◆ has_action()

has_action (   $action)

Returns whether this controller has the specificed action.

Parameters
string$actionName of the action
Returns
true if action is defined, false otherwise

◆ link_for()

link_for (   $to = '')

Returns an escaped URL to a specified route to your Trails application. without first parameter the current action is used if route begins with a / then the current controller ist prepended if second parameter is an array it is passed to URLHeper

Parameters
stringa string containing a controller and optionally an action
stringsoptional arguments
Returns
string a URL to this route

◆ perform()

perform (   $unconsumed_path)

Hooked perform method in order to inject body element id creation.

In order to avoid clashes, these body element id will be joined with a minus sign. Otherwise the controller "x" with action "y_z" would be given the same id as the controller "x/y" with the action "z", namely "x_y_z". With the minus sign this will result in the ids "x-y_z" and "x_y-z".

Plugins will always have a leading 'plugin-' and the decamelized plugin name in front of the id.

Parameters
String$unconsumed_pathPath segment containing action and optionally arguments or format
Returns
Trails_Response from parent controller

◆ perform_relayed()

perform_relayed (   $unconsumed)

perform a given action/parameter string from an relayed request before_filter and after_filter methods are not called

See also
perform
Parameters
string$unconsumed
Returns
Trails_Response

◆ redirect()

redirect (   $to)

Redirects the user another page. Accepts multiple parameters just like url_for().

Parameters
string$to
See also
StudipController::url_for()

◆ relay()

relay (   $to_uri)

relays current request to another controller and returns the response the other controller is given all assigned properties, additional parameters are passed through

Parameters
string$to_uria trails route
Returns
Trails_Response

◆ relayWithRedirect()

relayWithRedirect (   $args)

Relays current request and performs redirect if neccessary.

Parameters
string$to_uria trails route
Returns
Trails_Response
See also
StudipController::relay()

◆ relocate()

relocate (   $to)

Relocate the user to another location. This is a specialized version of redirect that differs in two points:

Parameters
String$toLocation to redirect to

◆ render_csv()

render_csv (   $data,
  $filename = null,
  $delimiter = ';',
  $enclosure = '"' 
)

Render given data as csv, data is assumed to be utf-8. The first row of data may contain column titles.

Parameters
array$datadata as two dimensional array
string$filenamedownload file name (optional)
string$delimiterfield delimiter char (optional)
string$enclosurefield enclosure char (optional)

◆ render_file()

render_file (   $file,
  $filename = null,
  $content_type = null,
  $content_disposition = 'attachment',
Closure  $callback = null,
  $chunk_size = 262144 
)

Renders a file

Parameters
string$filePath of the file to render
string$filenameName of the file displayed to user (will equal $file when missing)
string$content_typeOptional content type (will be determined if missing)
string$content_dispositionEither attachment (default) or inline
Closure$callbackOptional callback when download has finished
int$chunk_sizeOptional size of chunks to send (default: 256k)

◆ render_form()

render_form ( \Studip\Forms\Form  $form)

◆ render_json()

render_json (   $data)

render given data as json, data is converted to utf-8

Parameters
mixed$data

◆ render_pdf()

render_pdf ( TCPDF  $pdf,
  $filename,
  $inline = false 
)
protected

Renders a pdf file given by a TCPDF/ExportPDF object.

Parameters
TCPDF$pdfTCPDF object to render
string$filenameFilename
bool$inlineShould the pdf be displayed inline (default: no)

◆ render_spreadsheet()

render_spreadsheet ( array  $header,
array  $data,
string  $format,
string  $filename,
?string  $filepath = null 
)

Export xlsx and csv files via PhpSpreadsheet

Exceptions

◆ render_template_as_string()

render_template_as_string (   $template,
  $layout = null 
)

Renders a given template and returns the resulting string.

Parameters
string$templateName of the template file
mixed$layoutOptional layout
Returns
string

◆ render_temporary_file()

render_temporary_file (   $file,
  $filename = null,
  $content_type = null,
  $content_disposition = 'attachment',
Closure  $callback = null,
  $chunk_size = 262144 
)

Renders a temporary file which will be deleted after transmission. This is just a convenience method so you don't have to write the delete callback.

Parameters
string$filePath of the file to render
string$filenameName of the file displayed to user (will equal $file when missing)
string$content_typeOptional content type (will be determined if missing)
string$content_dispositionEither attachment (default) or inline
Closure$callbackOptional callback when download has finished
int$chunk_sizeOptional size of chunks to send (default: 256k)

◆ rescue()

rescue (   $exception)

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

Parameters
objectthe thrown exception

◆ url_for()

url_for (   $to = '')

Returns a URL to a specified route to your Trails application. without first parameter the current action is used if route begins with a / then the current controller ist prepended if second parameter is an array it is passed to URLHeper

Parameters
stringa string containing a controller and optionally an action
string[]optional arguments
Returns
string a URL to this route

◆ validate_args()

validate_args ( $args,
  $types = null 
)

Validate arguments based on a list of given types. The types are: 'int', 'float', 'option' and 'string'. If the list of types is NULL or shorter than the argument list, 'option' is assumed for all remaining arguments. 'option' differs from Request::option() in that it also accepts the charaters '-' and ',' in addition to all word characters.

Since Stud.IP 4.0 it is also possible to directly inject SimpleORMap objects. If types is NULL, the signature of the called action is analyzed and any type hint that matches a sorm class will be used to create an object using the argument as the id that is passed to the object's constructor.

If $_autobind is set to true, the created object is also assigned to the controller so that it is available in a view.

Parameters
array$argsan array of arguments to the action
array$typeslist of argument types (optional)

◆ validate_datetime()

validate_datetime (   $datetime,
  $format = 'H:i' 
)

Validate the datetime according to specific format.

Parameters
string$datetimethe datetime which should be validate
string$formatthe format that the datetime should have by default H:i for time
Returns
bool result of validation

Field Documentation

◆ $_autobind

$_autobind = false
protected

◆ $allow_nobody

$allow_nobody = true
protected

◆ $with_session

$with_session = false
protected

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