ILIAS
Release_5_0_x_branch Revision 61816
|
Public Member Functions | |
__construct ($userSettings=array()) | |
Constructor. | |
getMode () | |
Get application mode. | |
setName ($name) | |
Set Slim application name. | |
getName () | |
Get Slim application name. | |
getLog () | |
Get application Log (lazy-loaded) | |
configureMode ($mode, $callable) | |
Configure Slim for a given mode. | |
config ($name, $value=null) | |
Configure Slim Settings. | |
map () | |
Add generic route without associated HTTP method. | |
get () | |
Add GET route. | |
post () | |
Add POST route. | |
put () | |
Add PUT route. | |
delete () | |
Add DELETE route. | |
options () | |
Add OPTIONS route. | |
notFound ($callable=null) | |
Not Found Handler. | |
error ($argument=null) | |
Error Handler. | |
request () | |
Get the Request object. | |
response () | |
Get the Response object. | |
router () | |
Get the Router object. | |
view ($viewClass=null) | |
Get and/or set the View. | |
render ($template, $data=array(), $status=null) | |
Render a template. | |
lastModified ($time) | |
Set Last-Modified HTTP Response Header. | |
etag ($value, $type= 'strong') | |
Set ETag HTTP Response Header. | |
setCookie ($name, $value, $time=null, $path=null, $domain=null, $secure=null, $httponly=null) | |
Set a normal, unencrypted Cookie. | |
getCookie ($name) | |
Get the value of a Cookie from the current HTTP Request. | |
setEncryptedCookie ($name, $value, $time=null, $path=null, $domain=null, $secure=null, $httponly=null) | |
Set an encrypted Cookie. | |
getEncryptedCookie ($name) | |
Get the value of an encrypted Cookie from the current HTTP request. | |
deleteCookie ($name, $path=null, $domain=null, $secure=null, $httponly=null) | |
Delete a Cookie (for both normal or encrypted Cookies) | |
root () | |
Get the Slim application's absolute directory path. | |
stop () | |
Stop. | |
halt ($status, $message= '') | |
Halt. | |
pass () | |
Pass. | |
contentType ($type) | |
Set the HTTP response Content-Type. | |
status ($code) | |
Set the HTTP response status code. | |
urlFor ($name, $params=array()) | |
Get the URL for a named Route. | |
redirect ($url, $status=302) | |
Redirect. | |
flash ($key, $value) | |
Set flash message for subsequent request. | |
flashNow ($key, $value) | |
Set flash message for current request. | |
flashKeep () | |
Keep flash messages from previous request for subsequent request. | |
hook ($name, $callable, $priority=10) | |
Assign hook. | |
applyHook ($name, $hookArg=null) | |
Invoke hook. | |
getHooks ($name=null) | |
Get hook listeners. | |
clearHooks ($name=null) | |
Clear hook listeners. | |
run () | |
Run the Slim application. |
Static Public Member Functions | |
static | autoload ($class) |
Slim auto-loader. | |
static | getInstance ($name= 'default') |
Get Slim application with name. | |
static | handleErrors ($errno, $errstr= '', $errfile= '', $errline= '') |
Handle errors. |
Protected Member Functions | |
mapRoute ($args) | |
Add GET|POST|PUT|DELETE route. | |
defaultNotFound () | |
Default Not Found handler. | |
defaultError () | |
Default Error handler. |
Static Protected Member Functions | |
static | generateErrorMarkup ($message, $file= '', $line= '', $trace= '') |
Generate markup for error message. | |
static | generateTemplateMarkup ($title, $body) |
Generate default template markup. |
Protected Attributes | |
$name | |
$request | |
$response | |
$router | |
$view | |
$log | |
$settings | |
$mode | |
$hooks |
Static Protected Attributes | |
static | $apps = array() |
Slim::__construct | ( | $userSettings = array() | ) |
Constructor.
array | $userSettings |
Definition at line 156 of file Slim.php.
References config(), getMode(), request(), response(), router(), setName(), and view().
Slim::applyHook | ( | $name, | |
$hookArg = null |
|||
) |
Invoke hook.
string | $name | The hook name |
mixed | $hookArgs | (Optional) Argument for hooked functions |
Definition at line 957 of file Slim.php.
References $name.
Referenced by run().
|
static |
Slim::clearHooks | ( | $name = null | ) |
Slim::config | ( | $name, | |
$value = null |
|||
) |
Configure Slim Settings.
This method defines application settings and acts as a setter and a getter.
If only one argument is specified and that argument is a string, the value of the setting identified by the first argument will be returned, or NULL if that setting does not exist.
If only one argument is specified and that argument is an associative array, the array will be merged into the existing application settings.
If two arguments are provided, the first argument is the name of the setting to be created or updated, and the second argument is the setting value.
string | array | $name | If a string, the name of the setting to set or retrieve. Else an associated array of setting names and values |
mixed | $value | If name is a string, the value of the setting identified by $name |
Definition at line 335 of file Slim.php.
References $name.
Referenced by __construct(), deleteCookie(), getLog(), getMode(), run(), setCookie(), setEncryptedCookie(), and view().
Slim::configureMode | ( | $mode, | |
$callable | |||
) |
Configure Slim for a given mode.
This method will immediately invoke the callable if the specified mode matches the current application mode. Otherwise, the callable is ignored. This should be called only after you initialize your Slim app.
string | $mode | |
mixed | $callable |
Definition at line 310 of file Slim.php.
References $mode, and getMode().
Slim::contentType | ( | $type | ) |
Set the HTTP response Content-Type.
string | $type | The Content-Type for the Response (ie. text/html) |
Definition at line 855 of file Slim.php.
References response().
|
protected |
Default Error handler.
Definition at line 1165 of file Slim.php.
References generateTemplateMarkup().
|
protected |
Default Not Found handler.
Definition at line 1157 of file Slim.php.
References generateTemplateMarkup(), and request().
Slim::delete | ( | ) |
Add DELETE route.
Definition at line 434 of file Slim.php.
References mapRoute(), and Slim_Http_Request\METHOD_DELETE.
Slim::deleteCookie | ( | $name, | |
$path = null , |
|||
$domain = null , |
|||
$secure = null , |
|||
$httponly = null |
|||
) |
Delete a Cookie (for both normal or encrypted Cookies)
Remove a Cookie from the client. This method will overwrite an existing Cookie with a new, empty, auto-expiring Cookie. This method's arguments must match the original Cookie's respective arguments for the original Cookie to be removed. If any of this method's arguments are omitted or set to NULL, the default Cookie setting values (set during Slim::init) will be used instead.
string | $name | The cookie name |
string | $path | The path on the server in which the cookie will be available on |
string | $domain | The domain that the cookie is available to |
bool | $secure | Indicates that the cookie should only be transmitted over a secure HTTPS connection from the client |
bool | $httponly | When TRUE the cookie will be made accessible only through the HTTP protocol |
Definition at line 766 of file Slim.php.
References $name, $path, config(), and response().
Slim::error | ( | $argument = null | ) |
Error Handler.
This method defines or invokes the application-wide Error handler. There are two contexts in which this method may be invoked:
If the $argument parameter is callable, this method will register the callable to be invoked when an uncaught Exception is detected, or when otherwise explicitly invoked. The handler WILL NOT be invoked in this context.
If the $argument parameter is not callable, Slim assumes you want to invoke an already-registered handler. If the handler has been registered and is callable, it is invoked and passed the caught Exception as its one and only argument. The error handler's output is captured into an output buffer and sent as the body of a 500 HTTP Response.
mixed | $argument | Callable|Exception |
Definition at line 510 of file Slim.php.
References halt(), and router().
Referenced by run().
Slim::etag | ( | $value, | |
$type = 'strong' |
|||
) |
Set ETag HTTP Response Header.
Set the etag header and stop if the conditional GET request matches. The value
argument is a unique identifier for the current resource. The type
argument indicates whether the etag should be used as a strong or weak cache validator.
When the current request includes an 'If-None-Match' header with a matching etag, execution is immediately stopped. If the request method is GET or HEAD, a '304 Not Modified' response is sent.
string | $value | The etag value |
string | $type | The type of etag to create; either "strong" or "weak" |
InvalidArgumentException | If provided type is invalid |
Definition at line 649 of file Slim.php.
References halt(), request(), and response().
Slim::flash | ( | $key, | |
$value | |||
) |
Slim::flashKeep | ( | ) |
Slim::flashNow | ( | $key, | |
$value | |||
) |
|
staticprotected |
Generate markup for error message.
This method accepts details about an error or exception and generates HTML markup for the 500 response body that will be sent to the client.
string | $message | The error message |
string | $file | The absolute file path to the affected file |
int | $line | The line number in the affected file |
string | $trace | A stack trace of the error |
Definition at line 1125 of file Slim.php.
References $file, and generateTemplateMarkup().
|
staticprotected |
Generate default template markup.
This method accepts a title and body content to generate an HTML page. This is primarily used to generate the layout markup for Error handlers and Not Found handlers.
string | $title | The title of the HTML template |
string | $body | The body content of the HTML template |
Definition at line 1145 of file Slim.php.
Referenced by defaultError(), defaultNotFound(), and generateErrorMarkup().
Slim::get | ( | ) |
Add GET route.
Definition at line 404 of file Slim.php.
References mapRoute(), Slim_Http_Request\METHOD_GET, and Slim_Http_Request\METHOD_HEAD.
Slim::getCookie | ( | $name | ) |
Get the value of a Cookie from the current HTTP Request.
Return the value of a cookie from the current HTTP request, or return NULL if cookie does not exist. Cookies created during the current request will not be available until the next request.
string | $name |
Definition at line 705 of file Slim.php.
References $name, and request().
Slim::getEncryptedCookie | ( | $name | ) |
Get the value of an encrypted Cookie from the current HTTP request.
Return the value of an encrypted cookie from the current HTTP request, or return NULL if cookie does not exist. Encrypted cookies created during the current request will not be available until the next request.
string | $name |
Definition at line 744 of file Slim.php.
References $name, and response().
Slim::getHooks | ( | $name = null | ) |
Get hook listeners.
Return an array of registered hooks. If $name
is a valid hook name, only the listeners attached to that hook are returned. Else, all listeners are returned as an associative array whose keys are hook names and whose values are arrays of listeners.
string | $name | A hook name (Optional) |
|
static |
Get Slim application with name.
string | $name | The name of the Slim application to fetch |
Definition at line 254 of file Slim.php.
References $name.
Referenced by ilRestFileStorage\createFile(), and ilRestFileStorage\getFile().
Slim::getLog | ( | ) |
Get application Log (lazy-loaded)
Definition at line 282 of file Slim.php.
References $log, and config().
Referenced by run().
Slim::getMode | ( | ) |
Get application mode.
Definition at line 231 of file Slim.php.
References $mode, and config().
Referenced by __construct(), and configureMode().
Slim::getName | ( | ) |
Slim::halt | ( | $status, | |
$message = '' |
|||
) |
Halt.
Halt the application and immediately send an HTTP response with a specific status code and body. This may be used to send any type of response: info, success, redirect, client error, or server error. If you need to render a template AND customize the response status, you should use Slim::render() instead.
int | $status | The HTTP response status |
string | $message | The HTTP response body |
Definition at line 823 of file Slim.php.
References response(), and stop().
Referenced by error(), etag(), lastModified(), notFound(), redirect(), and run().
|
static |
Handle errors.
This is the global Error handler that will catch reportable Errors and convert them into ErrorExceptions that are caught and handled by each Slim application.
int | $errno | The numeric type of the Error |
string | $errstr | The error message |
string | $errfile | The absolute path to the affected file |
int | $errline | The line number of the error in the affected file |
ErrorException |
Definition at line 1105 of file Slim.php.
Slim::hook | ( | $name, | |
$callable, | |||
$priority = 10 |
|||
) |
Slim::lastModified | ( | $time | ) |
Set Last-Modified HTTP Response Header.
Set the HTTP 'Last-Modified' header and stop if a conditional GET request's If-Modified-Since
header matches the last modified time of the resource. The time
argument is a UNIX timestamp integer value. When the current request includes an 'If-Modified-Since' header that matches the specified last modified time, the application will stop and send a '304 Not Modified' response to the client.
int | $time | The last modified UNIX timestamp |
SlimException | Returns HTTP 304 Not Modified response if resource last modified time matches If-Modified-Since header |
InvalidArgumentException | If provided timestamp is not an integer |
Definition at line 623 of file Slim.php.
References halt(), request(), and response().
Slim::map | ( | ) |
Add generic route without associated HTTP method.
Definition at line 394 of file Slim.php.
References mapRoute().
|
protected |
Add GET|POST|PUT|DELETE route.
Adds a new route to the router with associated callable. This route will only be invoked when the HTTP request's method matches this route's method.
ARGUMENTS:
First: string The URL pattern (REQUIRED) In-Between: mixed Anything that returns TRUE for is_callable
(OPTIONAL) Last: mixed Anything that returns TRUE for is_callable
(REQUIRED)
The first argument is required and must always be the route pattern (ie. '/books/:id').
The last argument is required and must always be the callable object to be invoked when the route matches an HTTP request.
You may also provide an unlimited number of in-between arguments; each interior argument must be callable and will be invoked in the order specified before the route's callable is invoked.
USAGE:
Slim::get('/foo'[, middleware, middleware, ...], callable);
array | (See notes above) |
Definition at line 379 of file Slim.php.
References router().
Referenced by delete(), get(), map(), options(), post(), and put().
Slim::notFound | ( | $callable = null | ) |
Not Found Handler.
This method defines or invokes the application-wide Not Found handler. There are two contexts in which this method may be invoked:
If the $callable parameter is not null and is callable, this method will register the callable to be invoked when no routes match the current HTTP request. It WILL NOT invoke the callable.
If the $callable parameter is null, Slim assumes you want to invoke an already-registered handler. If the handler has been registered and is callable, it is invoked and sends a 404 HTTP Response whose body is the output of the Not Found handler.
mixed | $callable | Anything that returns true for is_callable() |
Definition at line 471 of file Slim.php.
References halt(), and router().
Referenced by run().
Slim::options | ( | ) |
Add OPTIONS route.
Definition at line 444 of file Slim.php.
References mapRoute(), and Slim_Http_Request\METHOD_OPTIONS.
Slim::pass | ( | ) |
Pass.
This method will cause the Router::dispatch method to ignore the current route and continue to the next matching route in the dispatch loop. If no subsequent mathing routes are found, a 404 Not Found response will be sent to the client.
Slim_Exception_Pass |
Slim::post | ( | ) |
Add POST route.
Definition at line 414 of file Slim.php.
References mapRoute(), and Slim_Http_Request\METHOD_POST.
Referenced by ilRestServer\init().
Slim::put | ( | ) |
Add PUT route.
Definition at line 424 of file Slim.php.
References mapRoute(), and Slim_Http_Request\METHOD_PUT.
Slim::redirect | ( | $url, | |
$status = 302 |
|||
) |
Redirect.
This method immediately redirects to a new URL. By default, this issues a 302 Found response; this is considered the default generic redirect response. You may also specify another valid 3xx status code if you want. This method will automatically set the HTTP Location header for you using the URL parameter and place the destination URL into the response body.
string | $url | The destination URL |
int | $status | The HTTP redirect status code (Optional) |
InvalidArgumentException | If status parameter is not a valid 3xx status code |
Definition at line 894 of file Slim.php.
References halt(), and response().
Referenced by run().
Slim::render | ( | $template, | |
$data = array() , |
|||
$status = null |
|||
) |
Render a template.
Call this method within a GET, POST, PUT, DELETE, NOT FOUND, or ERROR callable to render a template whose output is appended to the current HTTP response body. How the template is rendered is delegated to the current View.
string | $template | The name of the template passed into the View::render method |
array | $data | Associative array of data made available to the View |
int | $status | The HTTP response status code to use (Optional) |
Definition at line 598 of file Slim.php.
References response(), and view().
Slim::request | ( | ) |
Get the Request object.
Definition at line 533 of file Slim.php.
References $request.
Referenced by __construct(), defaultNotFound(), etag(), getCookie(), lastModified(), root(), and run().
Slim::response | ( | ) |
Get the Response object.
Definition at line 541 of file Slim.php.
References $response.
Referenced by __construct(), contentType(), deleteCookie(), etag(), getEncryptedCookie(), halt(), lastModified(), redirect(), render(), run(), setCookie(), setEncryptedCookie(), status(), and stop().
Slim::root | ( | ) |
Get the Slim application's absolute directory path.
This method returns the absolute path to the Slim application's directory. If the Slim application is installed in a public-accessible sub-directory, the sub-directory path will be included. This method will always return an absolute path WITH a trailing slash.
Definition at line 786 of file Slim.php.
References request().
Slim::router | ( | ) |
Get the Router object.
Definition at line 549 of file Slim.php.
References $router.
Referenced by __construct(), error(), mapRoute(), notFound(), run(), and urlFor().
Slim::run | ( | ) |
Run the Slim application.
This method is the "meat and potatoes" of Slim and should be the last method called. This fires up Slim, invokes the Route that matches the current request, and returns the response to the client.
This method will invoke the Not Found handler if no matching routes are found.
This method will also catch any unexpected Exceptions thrown by this application; the Exceptions will be logged to this application's log and rethrown to the global Exception handler.
Definition at line 1034 of file Slim.php.
References applyHook(), config(), error(), getLog(), halt(), notFound(), redirect(), request(), response(), router(), and view().
Slim::setCookie | ( | $name, | |
$value, | |||
$time = null , |
|||
$path = null , |
|||
$domain = null , |
|||
$secure = null , |
|||
$httponly = null |
|||
) |
Set a normal, unencrypted Cookie.
string | $name | The cookie name |
mixed | $value | The cookie value |
mixed | $time | The duration of the cookie; If integer, should be UNIX timestamp; If string, converted to UNIX timestamp with strtotime ; |
string | $path | The path on the server in which the cookie will be available on |
string | $domain | The domain that the cookie is available to |
bool | $secure | Indicates that the cookie should only be transmitted over a secure HTTPS connection to/from the client |
bool | $httponly | When TRUE the cookie will be made accessible only through the HTTP protocol |
Definition at line 686 of file Slim.php.
References $name, $path, config(), and response().
Slim::setEncryptedCookie | ( | $name, | |
$value, | |||
$time = null , |
|||
$path = null , |
|||
$domain = null , |
|||
$secure = null , |
|||
$httponly = null |
|||
) |
Set an encrypted Cookie.
string | $name | The cookie name |
mixed | $value | The cookie value |
mixed | $time | The duration of the cookie; If integer, should be UNIX timestamp; If string, converted to UNIX timestamp with strtotime ; |
string | $path | The path on the server in which the cookie will be available on |
string | $domain | The domain that the cookie is available to |
bool | $secure | Indicates that the cookie should only be transmitted over a secure HTTPS connection from the client |
bool | $httponly | When TRUE the cookie will be made accessible only through the HTTP protocol |
Definition at line 724 of file Slim.php.
References $name, $path, config(), and response().
Slim::setName | ( | $name | ) |
Slim::status | ( | $code | ) |
Set the HTTP response status code.
int | $status | The HTTP response status code |
Definition at line 864 of file Slim.php.
References response().
Slim::stop | ( | ) |
Stop.
Send the current Response as is and stop executing the Slim application. The thrown exception will be caught by the Slim custom exception handler which exits this script.
Slim_Exception_Stop |
Definition at line 800 of file Slim.php.
References response(), and view().
Referenced by halt().
Slim::urlFor | ( | $name, | |
$params = array() |
|||
) |
Slim::view | ( | $viewClass = null | ) |
Get and/or set the View.
This method declares the View to be used by the Slim application. If the argument is a string, Slim will instantiate a new object of the same class. If the argument is an instance of View or a subclass of View, Slim will use the argument as the View.
If a View already exists and this method is called to create a new View, data already set in the existing View will be transferred to the new View.
Definition at line 569 of file Slim.php.
References $view, and config().
Referenced by __construct(), flash(), flashKeep(), flashNow(), render(), run(), and stop().
|
protected |
Definition at line 121 of file Slim.php.
Referenced by getHooks().
|
protected |
Definition at line 116 of file Slim.php.
Referenced by configureMode(), and getMode().
|
protected |
Definition at line 81 of file Slim.php.
Referenced by applyHook(), clearHooks(), config(), deleteCookie(), getCookie(), getEncryptedCookie(), getHooks(), getInstance(), getName(), hook(), setCookie(), setEncryptedCookie(), setName(), and urlFor().
|
protected |
Definition at line 91 of file Slim.php.
Referenced by response().