core/src/PlufShortcuts.php

Functions

Pluf_Shortcuts_GetRequestParamOr403()

Pluf_Shortcuts_GetRequestParamOr403(  $request,   $id) 

Parameters

$request
$id

Pluf_Shortcuts_GetRequestParam()

Pluf_Shortcuts_GetRequestParam(  $request,   $id) 

Parameters

$request
$id

Pluf_Shortcuts_GetObjectOr404()

Pluf_Shortcuts_GetObjectOr404(  $object,   $id) : \Pluf_Model

Get an object by id or raise a 404 error.

Parameters

$object
$id

Returns

\Pluf_Model

The found object.

Pluf_Shortcuts_GetOneOr404()

Pluf_Shortcuts_GetOneOr404(  $object,   $bsql,   $psql) : Object

Get an object by SQL or raise a 404 error.

Usage:

$obj = Pluf_Shortcuts_GetOneOr404('MyApp_Model',
'path=%s AND status=%s',
array('welcome', 1));

Parameters

$object
$bsql
$psql

Returns

Object —

The found object

Pluf_Shortcuts_RenderToResponse()

Pluf_Shortcuts_RenderToResponse(  $tplfile,   $params,   $request = null) : \Pluf_HTTP_Response

Render a template file and an array as a reponse.

If a none null request object is given, the context used will automatically be a Pluf_Template_Context_Request context and thus the context will be populated using the 'template_context_processors' functions.

Parameters

$tplfile
$params
$request

Returns

\Pluf_HTTP_Response

The response with the rendered template

Pluf_Shortcuts_GetFormForModel()

Pluf_Shortcuts_GetFormForModel(  $model,   $data = null,   $extra = array(),   $label_suffix = null) : \Pluf_Form_Model

Get a given form from a model.

Parameters

$model
$data
$extra
$label_suffix

Returns

\Pluf_Form_Model

Form for this model.

Pluf_Shortcuts_GetFormForUpdateModel()

Pluf_Shortcuts_GetFormForUpdateModel(  $model,   $data = null,   $extra = array(),   $label_suffix = null) : Object

Get a given form from a model to update.

Parameters

$model
$data
$extra
$label_suffix

Returns

Object —

Form to update for this model.

Pluf_Shortcuts_folderSize()

Pluf_Shortcuts_folderSize(string  $dir) : \number

Compute folder size

Parameters

string $dir

Returns

\number

Pluf_Shortcuts_GetAssociationTableName()

Pluf_Shortcuts_GetAssociationTableName(string  $modelName1, string  $modelName2) : string

Returns association table name (without prefix) for given models.

Parameters

string $modelName1

name of model (of type Pluf_Model)

string $modelName2

name of model (of type Pluf_Model)

Returns

string —

name of association table for given modeles.

Pluf_Shortcuts_GetForeignKeyName()

Pluf_Shortcuts_GetForeignKeyName(string  $modelName) : string

Returns column name for given model as foreign key in an association table.

Parameters

string $modelName

name of model (of type Pluf_Model)

Returns

string —

column name for given model as foreign key in an association table.

Pluf_Shortcuts_GetListCount()

Pluf_Shortcuts_GetListCount(\Pluf_HTTP_Request  $request) : \number

Returns list count for given request.

If count is not set in request or count is more than a threshold (50) returns a default value (50).

Parameters

\Pluf_HTTP_Request $request

Returns

\number