Static CEC Hook class, provides some public methods to process registered chains at CEC (Contenido Extension Chainer).

Usage:

// example of executing a cec without a parameter and return value
CEC_Hook::execute('Contenido.Content.Somewhere');

// example of executing a cec with a parameter but without a return value
$param = 'some value';
CEC_Hook::execute('Contenido.Content.Somewhere', $param);

// example of executing a cec with multiple parameter but without a return value
$param = array('foo' => $bar, 'foo2' => $bar2);
$param = CEC_Hook::execute('Contenido.Content.Somewhere', $param);


// example of executing a cec without a parameter but a return value (with predefined
// default return value)
CEC_Hook::setDefaultReturnValue('this is the default title');
$title = CEC_Hook::executeAndReturn('Contenido.Content.CreateTitletag');

// example of executing a cec with a parameter and a return value
// (usually the modified version of passed parameter)
$baseHref    = $cfgClient[$client]['path']['htmlpath'];
$newBaseHref = CEC_Hook::executeAndReturn('Contenido.Frontend.BaseHrefGeneration', $baseHref);


// example of executing a cec with a break condition and default return value
CEC_Hook::setBreakCondition(false, true); // break condition = "false", default return value = "true"
$allow = CEC_Hook::executeWhileBreakCondition('Contenido.Frontend.AllowEdit', $lang, $idcat, $idart, $auth->auth['uid']);
if ($allow == false) {
    die("You're not coming in!");
}

// another example of executing a cec with a break condition and default return value
CEC_Hook::setBreakCondition(true, false); // break condition = "true", default return value = "false"
$allow = CEC_Hook::executeWhileBreakCondition('Contenido.Frontend.CategoryAccess', $lang, $idcat, $auth->auth['uid']);
if ($allow == false) {
    die("I said, you're not coming in!");
}

author Murat Purc
package Contenido Backend classes
subpackage CEC

 Methods

Method to execute registered functions for Contenido Extension Chainer (CEC).

execute() : void

Gets the desired CEC iterator and executes each registered chain function by passing the achieved arguments to it. There is

Method to execute registered functions for Contenido Extension Chainer (CEC).

executeAndReturn() : mixed

Gets the desired CEC iterator and executes each registered chain function. You can pass as much parameter as you want.

Returns

mixedParameter changed/processed by chain functions. Note: If no chain function is registered, the first parameter $param after $chainName will be returned

CEC function to process chains untill a break condition occurs.

executeWhileBreakCondition() : mixed

Gets the desired CEC iterator and executes each registered chain function as long as defined break condition doesn't occur.

Returns

mixedThe break condition or it's default value

Temporaly setting of break condition and optional the default return value.

setBreakCondition(mixed $condition, mixed $defaultReturnValue) : void

Parameters

$condition

mixed

$defaultReturnValue

mixed

Temporaly setting of an execution conditions.

setConditions(mixed $condition, bool $overwriteArguments, bool $returnbreakconditiondirectly, mixed $defaultReturnValue) 

deprecated Function is no more needed, still exists due to downwards compatibility! This is usefull, if at least on of defined cec functions returns a specific value and the execution of further functions is no more needed. The defined condition will be reset in execute() method.

Parameters

$condition

mixed

One of CEC_Hook constants, with following control mechanism: - CEC_Hook::BREAK_AT_TRUE = Breaks the iteration of cec functions and returns the parameter, if the result of an function is true. - CEC_Hook::BREAK_AT_FALSE = Breaks the iteration of cec functions and returns the parameter, if the result of an function is false. - CEC_Hook::BREAK_AT_NULL = Breaks the iteration of cec functions and returns the parameter, if the result of an function is null.

$overwriteArguments

bool

Flag to prevent overwriting of passed parameter to execute(). Normally the parameter will be overwritten by return value of executed functions, but this is sometimes a not wanted side effect.

$returnbreakconditiondirectly

bool

If a break condition is set and a chain function returns the condition set, setting this option forces the execute method to directly return that condition instead of the args

$defaultReturnValue

mixed

Exceptions

\InvalidArgumentException If passed type is not one of CEC_Hook constants.

Temporaly setting of default return value.

setDefaultReturnValue(mixed $defaultReturnValue) : void

Parameters

$defaultReturnValue

mixed

Temporaly setting of position in argument to return.

setReturnArgumentPos(int $pos) : void

Parameters

$pos

int

Position, feasible value greater 0

Used to debug some status informations.

_debug(mixed $var, string $msg) : void

Writes the debug value into a logfile (see contenido/logs/cec_hook_debug.log).

Parameters

$var

mixed

The variable to dump

$msg

string

Additional message

Resets some properties to defaults

_reset() : void

 Properties

 

Temporaly stored break condition.

$_breakCondition : int

 

Temporaly stored default return value of CEC functions

$_defaultReturnValue : mixed

 

Flag to overwrite arguments.

$_overwriteArguments : bool

deprecated No more needed
 

Temporaly stored position of argument to return. It's used by CEC_Hook::executeAndReturn() to store/extract the return value into/from arguments list.

$_returnArgumentPos : int

 

Flag to return the set break condition directly.

$_returnBreakConditionDirectly : bool

deprecated No more needed

 Constants

 

Value to break the cec execution at a false result

BREAK_AT_FALSE : int

deprecated see CEC_Hook::setConditions()
 

Value to break the cec execution at a null result

BREAK_AT_NULL : int

deprecated see CEC_Hook::setConditions()
 

Value to break the cec execution at a true result

BREAK_AT_TRUE : int

deprecated see CEC_Hook::setConditions()