RegisterStack

final class \TYPO3\CMS\Frontend\ContentObject\RegisterStack

Contains TypoScript "Register" state together with class Register.

An instance of this class is created during frontend rendering and registered as Request attribute "frontend.register.stack".

The TypoScript "register" is a key-value store (implemented by class Register) combined with a stack. This has probably been invented for menu rendering back then: content objects in general and TypoScript based menu rendering specifically can be nested when multiple menu depths/layers are rendered. Each of those layers may need own values within their scope.

The two main usages are TypoScript data/getText to access register entries along with content objects LOAD_REGISTER and RESTORE_REGISTER which push and pop register objects from the stack and store key/value entries.

There is one quirk in comparison to a "classic" stack: New Register instances are typically clones of the underlying Register instance plus new key/values, see class LoadRegisterContentObject for an implementation: Values can be set on a lower level register and is still "seen/part of" a register on top. key/values bubble up, but not down.

Table of Contents

Methods

__construct()  : mixed
current()  : Register
Peek current Register. Does not change stack.
pop()  : Register
Remove top of stack Register and return it.
push()  : void
Add a new Register instance to top of stack

Methods

pop()

Remove top of stack Register and return it.

public pop() : Register

Re-inits with an empty register if empty to avoid exception or nullable handling in consumers if there is for example a "RESTORE_REGISTER" cObj too much. As drawback, consumers never know if there is a leftover pop().

Return values

Register
On this page