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 |
execute() : void
Gets the desired CEC iterator and executes each registered chain function by passing the achieved arguments to it. There is
executeAndReturn() : mixed
Gets the desired CEC iterator and executes each registered chain function. You can pass as much parameter as you want.
mixed
Parameter changed/processed by chain functions.
Note: If no chain function is registered, the first parameter
$param after
$chainName will be returnedexecuteWhileBreakCondition() : mixed
Gets the desired CEC iterator and executes each registered chain function as long as defined break condition doesn't occur.
mixed
The break condition or it's default valuesetBreakCondition(mixed $condition, mixed $defaultReturnValue) : void
mixed
mixed
setDefaultReturnValue(mixed $defaultReturnValue) : void
mixed
setReturnArgumentPos(int $pos) : void
int
Position, feasible value greater 0
\cInvalidArgumentException |
if the given position is less than 1 |
---|
_debug(mixed $var, string $msg) : void
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). |
---|
mixed
The variable to dump
string
Additional message
_reset() : void
$_breakCondition : int
$_defaultReturnValue : mixed
$_returnArgumentPos : int
It's used by cApiCecHook::executeAndReturn() to store/extract the return value into/from arguments list.