DEPRECATION WARNING

This documentation is not using the current rendering mechanism and is probably outdated. The extension maintainer should switch to the new system. Details on how to use the rendering mechanism can be found here.

HooksΒΆ

There's one hook available in the parser library. It allows the manipulation of the value resulting from an expression. It must be registered with something like:

$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['expressions']['postprocessReturnValue'][] = 'Vendor\\MyExtension\\Hook\\MyExpressionHook';

It must implement the \Cobweb\Expressions\ValuePostProcessorInterface interface. Here's a sample code:

namespace Vendor\MyExtension\Hook;
class MyExpressionHook implements \Cobweb\Expressions\ValuePostProcessorInterface {
        public function postprocessReturnValue($value) {
                if (is_numeric($value)) {
                        $value += 30;
                }
                return $value;
        }
}

This sample code will add 30 to the given value, if it is numeric.

As can be seen, the hook method receives the value itself and is expected to return it, even if unchanged.