contenido\classes\class.cec_hook.php
Description: Includes CEC hook class
Requirements:
- Author
- Murat Purc
- Con_php_req
- 5.0
- Copyright
- four for business AG
- License
- http://www.contenido.org/license/LIZENZ.txt
- Link
- http://www.4fb.de
- Link
- http://www.contenido.org
- Package
- Contenido Backend classes
- Since
- file available since contenido release >= 4.8.8 {@internal created 2008-08-28, Murat Purc, initial implementation, port from Advanced Mod Rewrite Plugin modified 2008-09-10, Murat Purc, bugfix: add further condition handling to prevent overwriting of arguments modified 2008-11-11, Andreas Lindner, when overwriting of arguments is prevented and break condition is set added anoption to return break condition value directly, otherwise the args would be returned, which is not desirable under all circumstances modified 2008-12-26, Murat Purc, bugfix: Not each registered chain function will get the same parameter modified 2009-12-26, Murat Purc, bugfix/redesign of CEC_Hook, see [#CON-256] }}
- Subpackage
- CEC
- Version
- 0.5
\CEC_Hook
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
Constants

int
BREAK_AT_TRUE
= 'true'
- Deprecated
- see CEC_Hook::setConditions()
- int

int
BREAK_AT_FALSE
= 'false'
- Deprecated
- see CEC_Hook::setConditions()
- int
Properties


mixed $_defaultReturnValue = null
null
Details- Type
- mixed


bool $_overwriteArguments = true
true
Details- Type
- bool
- Deprecated
- No more needed


int $_returnArgumentPos = 1
It's used by CEC_Hook::executeAndReturn() to store/extract the return value into/from arguments list.
1
Details- Type
- int
Methods


_debug(mixed $var, string $msg = '') : void
Used to debug some status informations.
Writes the debug value into a logfile (see contenido/logs/cec_hook_debug.log).
Name | Type | Description |
---|---|---|
$var | mixed | The variable to dump |
$msg | string | Additional message |


execute() : void
Method to execute registered functions for Contenido Extension Chainer (CEC).
Gets the desired CEC iterator and executes each registered chain function by passing the achieved arguments to it. There is


executeAndReturn() : mixed
Method to execute registered functions for Contenido Extension Chainer (CEC).
Gets the desired CEC iterator and executes each registered chain function. You can pass as much parameter as you want.
Type | Description |
---|---|
mixed | Parameter changed/processed by chain functions. Note: If no chain function is registered, the first parameter $param after $chainName will be returned |


executeWhileBreakCondition() : mixed
CEC function to process chains untill a break condition occurs.
Gets the desired CEC iterator and executes each registered chain function as long as defined break condition doesn't occur.
Type | Description |
---|---|
mixed | The break condition or it's default value |


setBreakCondition(mixed $condition, mixed $defaultReturnValue = null) : void
Temporaly setting of break condition and optional the default return value.
Name | Type | Description |
---|---|---|
$condition | mixed | |
$defaultReturnValue | mixed |


setConditions(mixed $condition, bool $overwriteArguments = true, bool $returnbreakconditiondirectly = false, mixed $defaultReturnValue = null) : void
Temporaly setting of an execution conditions.
Name | Type | Description |
---|---|---|
$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 |
Exception | Description |
---|---|
\InvalidArgumentException | If passed type is not one of CEC_Hook constants. |
- 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.


setDefaultReturnValue(mixed $defaultReturnValue) : void
Temporaly setting of default return value.
Name | Type | Description |
---|---|---|
$defaultReturnValue | mixed |