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
cApiCecHook::execute('Contenido.Content.Somewhere');

// example of executing a cec with a parameter but without a return value
$param = 'some value';
cApiCecHook::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 = cApiCecHook::execute('Contenido.Content.Somewhere', $param);


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

// example of executing a cec with a parameter and a return value
// (usually the modified version of passed parameter)
$baseHref = cRegistry::getFrontendUrl();
$newBaseHref =
cApiCecHook::executeAndReturn('Contenido.Frontend.BaseHrefGeneration',
$baseHref);


// example of executing a cec with a break condition and default return value
cApiCecHook::setBreakCondition(false, true); // break condition = "false",
default return value = "true"
$allow = cApiCecHook::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
cApiCecHook::setBreakCondition(true, false); // break condition = "true",
default return value = "false"
$allow =
cApiCecHook::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
Static

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
Static

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
Static

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
Static

Parameters

$condition

mixed

$defaultReturnValue

mixed

Temporaly setting of default return value.

setDefaultReturnValue(mixed $defaultReturnValue) : void
Static

Parameters

$defaultReturnValue

mixed

Temporaly setting of position in argument to return.

setReturnArgumentPos(int $pos) : void
Static

Parameters

$pos

int

Position, feasible value greater 0

Exceptions

\cInvalidArgumentException if the given position is less than 1

Used to debug some status informations.

_debug(mixed $var, string $msg) : void
Static
todo : Implement cec_hook debug mode for automatic logging when activated. Writes the debug value into a logfile (see contenido/data/log/cec_hook_debug.log).

Parameters

$var

mixed

The variable to dump

$msg

string

Additional message

Resets some properties to defaults

_reset() : void
Static

 Properties

 

$_breakCondition : int
 

$_defaultReturnValue : mixed
 

$_returnArgumentPos : int

It's used by cApiCecHook::executeAndReturn() to store/extract the return value into/from arguments list.