TYPO3 CMS  TYPO3_8-7
TYPO3\CMS\Form\Domain\Runtime\FormRuntime Class Reference
Inheritance diagram for TYPO3\CMS\Form\Domain\Runtime\FormRuntime:
TYPO3\CMS\Form\Domain\Model\Renderable\RootRenderableInterface

Public Member Functions

 injectHashService (\TYPO3\CMS\Extbase\Security\Cryptography\HashService $hashService)
 
 injectObjectManager (\TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager)
 
 __construct (FormDefinition $formDefinition, Request $request, Response $response)
 
 initializeObject ()
 
 overrideCurrentPage (int $pageIndex)
 
 render ()
 
 getIdentifier ()
 
 getRequest ()
 
 getResponse ()
 
 getCurrentPage ()
 
 getPreviousPage ()
 
 getNextPage ()
 
 getType ()
 
 offsetExists ($identifier)
 
 offsetGet ($identifier)
 
 offsetSet ($identifier, $value)
 
 offsetUnset ($identifier)
 
 getElementValue (string $identifier)
 
 getPages ()
 
 getFormState ()
 
 getRenderingOptions ()
 
 getRendererClassName ()
 
 getLabel ()
 
 getTemplateName ()
 
 getFormDefinition ()
 
 beforeRendering (FormRuntime $formRuntime)
 

Public Attributes

const HONEYPOT_NAME_SESSION_IDENTIFIER = 'tx_form_honeypot_name_'
 

Protected Member Functions

 initializeFormStateFromRequest ()
 
 initializeCurrentPageFromRequest ()
 
 initializeHoneypotFromRequest ()
 
 renderHoneypot ()
 
 getHoneypotNameFromSession (Page $page)
 
 setHoneypotNameInSession (Page $page, string $honeypotName)
 
 isAfterLastPage ()
 
 isFirstRequest ()
 
 processSubmittedFormValues ()
 
 userWentBackToPreviousStep ()
 
 mapAndValidatePage (Page $page)
 
 invokeFinishers ()
 
 getControllerContext ()
 
 getTypoScriptFrontendController ()
 

Protected Attributes

 $objectManager
 
 $formDefinition
 
 $request
 
 $response
 
 $formState
 
 $currentPage = null
 
 $lastDisplayedPage = null
 
 $hashService
 

Detailed Description

This class implements the runtime logic of a form, i.e. deciding which page is shown currently, what the current values of the form are, trigger validation and property mapping.

You generally receive an instance of this class by calling TYPO3\CMS\Form\Domain\Model\FormDefinition::bind.@sectionautotoc_md45RenderingaFormThat'seasy,justcallrender()ontheFormRuntime:/&mdash;codephp$form=$formDefinition->bind($request, $response);$renderedForm=$form->render();---@sectionautotoc_md46AccessingFormValuesInordertogetthevaluestheuserhasenteredintotheform,youcanaccessthisobjectlikeanarray:Ifaformfieldwiththeidentifier<em>firstName</em>exists,youcando<strong>$form['firstName']</strong>toretrieveitscurrentvalue.Youcanalsosetvaluesinthesameway.@sectionautotoc_md47RenderingInternalsTheFormRuntimeaskstheFormDefinitionabouttheconfiguredRendererwhichshouldbeused(@link\TYPO3\CMS\Form\Domain\Model\FormDefinition::getRendererClassName),andthentriggerrender()onthisRenderer.Thismakesitpossibletodeclarativelydefinehowaformshouldberendered.Scope:frontend<strong>ThisclassisNOTmeanttobesubclassedbydevelopers.</strong>@api

Definition at line 80 of file FormRuntime.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Form\Domain\Runtime\FormRuntime::__construct ( FormDefinition  $formDefinition,
Request  $request,
Response  $response 
)

Member Function Documentation

◆ beforeRendering()

TYPO3\CMS\Form\Domain\Runtime\FormRuntime::beforeRendering ( FormRuntime  $formRuntime)

This is a callback that is invoked by the Renderer before the corresponding element is rendered. Use this to access previously submitted values and/or modify the $formRuntime before an element is outputted to the browser.

Parameters
FormRuntime$formRuntime
Deprecated:
since TYPO3 v8, will be removed in TYPO3 v9

Implements TYPO3\CMS\Form\Domain\Model\Renderable\RootRenderableInterface.

Definition at line 867 of file FormRuntime.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\logDeprecatedFunction().

◆ getControllerContext()

TYPO3\CMS\Form\Domain\Runtime\FormRuntime::getControllerContext ( )
protected

◆ getCurrentPage()

TYPO3\CMS\Form\Domain\Runtime\FormRuntime::getCurrentPage ( )

Returns the currently selected page

Returns
Page

Definition at line 641 of file FormRuntime.php.

References TYPO3\CMS\Form\Domain\Runtime\FormRuntime\$currentPage.

◆ getElementValue()

TYPO3\CMS\Form\Domain\Runtime\FormRuntime::getElementValue ( string  $identifier)

Returns the value of the specified element

Parameters
string$identifier
Returns
mixed

Definition at line 775 of file FormRuntime.php.

Referenced by TYPO3\CMS\Form\Domain\Runtime\FormRuntime\offsetExists(), and TYPO3\CMS\Form\Domain\Runtime\FormRuntime\offsetGet().

◆ getFormDefinition()

TYPO3\CMS\Form\Domain\Runtime\FormRuntime::getFormDefinition ( )

Get the underlying form definition from the runtime

Returns
FormDefinition

Definition at line 853 of file FormRuntime.php.

References TYPO3\CMS\Form\Domain\Runtime\FormRuntime\$formDefinition.

◆ getFormState()

TYPO3\CMS\Form\Domain\Runtime\FormRuntime::getFormState ( )

◆ getHoneypotNameFromSession()

◆ getIdentifier()

◆ getLabel()

TYPO3\CMS\Form\Domain\Runtime\FormRuntime::getLabel ( )

Get the label which shall be displayed next to the form element

Returns
string

Implements TYPO3\CMS\Form\Domain\Model\Renderable\RootRenderableInterface.

Definition at line 831 of file FormRuntime.php.

◆ getNextPage()

TYPO3\CMS\Form\Domain\Runtime\FormRuntime::getNextPage ( )

Returns the next page of the currently selected one or NULL if there is no next page

Returns
Page|null

Definition at line 667 of file FormRuntime.php.

◆ getPages()

TYPO3\CMS\Form\Domain\Runtime\FormRuntime::getPages ( )
Returns
array<Page> The Form's pages in the correct order

Definition at line 788 of file FormRuntime.php.

◆ getPreviousPage()

TYPO3\CMS\Form\Domain\Runtime\FormRuntime::getPreviousPage ( )

Returns the previous page of the currently selected one or NULL if there is no previous page

Returns
Page|null

Definition at line 652 of file FormRuntime.php.

◆ getRendererClassName()

TYPO3\CMS\Form\Domain\Runtime\FormRuntime::getRendererClassName ( )

Get the renderer class name to be used to display this renderable; must implement RendererInterface

Returns
string the renderer class name

Implements TYPO3\CMS\Form\Domain\Model\Renderable\RootRenderableInterface.

Definition at line 820 of file FormRuntime.php.

◆ getRenderingOptions()

TYPO3\CMS\Form\Domain\Runtime\FormRuntime::getRenderingOptions ( )

◆ getRequest()

TYPO3\CMS\Form\Domain\Runtime\FormRuntime::getRequest ( )

Get the request this object is bound to.

This is mostly relevant inside Finishers, where you f.e. want to redirect the user to another page.

Returns
Request the request this object is bound to

Definition at line 616 of file FormRuntime.php.

References TYPO3\CMS\Form\Domain\Runtime\FormRuntime\$request.

Referenced by TYPO3\CMS\Form\Domain\Runtime\FormRuntime\initializeObject().

◆ getResponse()

TYPO3\CMS\Form\Domain\Runtime\FormRuntime::getResponse ( )

Get the response this object is bound to.

This is mostly relevant inside Finishers, where you f.e. want to set response headers or output content.

Returns
Response the response this object is bound to

Definition at line 630 of file FormRuntime.php.

References TYPO3\CMS\Form\Domain\Runtime\FormRuntime\$response.

◆ getTemplateName()

TYPO3\CMS\Form\Domain\Runtime\FormRuntime::getTemplateName ( )

Get the template name of the renderable

Returns
string

Definition at line 842 of file FormRuntime.php.

◆ getType()

TYPO3\CMS\Form\Domain\Runtime\FormRuntime::getType ( )

Abstract "type" of this Renderable. Is used during the rendering process to determine the template file or the View PHP class being used to render the particular element.

Returns
string

Implements TYPO3\CMS\Form\Domain\Model\Renderable\RootRenderableInterface.

Definition at line 699 of file FormRuntime.php.

◆ getTypoScriptFrontendController()

TYPO3\CMS\Form\Domain\Runtime\FormRuntime::getTypoScriptFrontendController ( )
protected

◆ initializeCurrentPageFromRequest()

TYPO3\CMS\Form\Domain\Runtime\FormRuntime::initializeCurrentPageFromRequest ( )
protected

Initializes the current page data based on the current request, also modifiable by a hook

Definition at line 204 of file FormRuntime.php.

References $GLOBALS, and TYPO3\CMS\Core\Utility\GeneralUtility\makeInstance().

Referenced by TYPO3\CMS\Form\Domain\Runtime\FormRuntime\initializeObject().

◆ initializeFormStateFromRequest()

TYPO3\CMS\Form\Domain\Runtime\FormRuntime::initializeFormStateFromRequest ( )
protected

Initializes the current state of the form, based on the request

Definition at line 190 of file FormRuntime.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\makeInstance().

Referenced by TYPO3\CMS\Form\Domain\Runtime\FormRuntime\initializeObject().

◆ initializeHoneypotFromRequest()

TYPO3\CMS\Form\Domain\Runtime\FormRuntime::initializeHoneypotFromRequest ( )
protected

◆ initializeObject()

◆ injectHashService()

TYPO3\CMS\Form\Domain\Runtime\FormRuntime::injectHashService ( \TYPO3\CMS\Extbase\Security\Cryptography\HashService  $hashService)
Parameters
\TYPO3\CMS\Extbase\Security\Cryptography\HashService$hashService

Definition at line 138 of file FormRuntime.php.

References TYPO3\CMS\Form\Domain\Runtime\FormRuntime\$hashService.

◆ injectObjectManager()

TYPO3\CMS\Form\Domain\Runtime\FormRuntime::injectObjectManager ( \TYPO3\CMS\Extbase\Object\ObjectManagerInterface  $objectManager)
Parameters
\TYPO3\CMS\Extbase\Object\ObjectManagerInterface$objectManager

Definition at line 147 of file FormRuntime.php.

References TYPO3\CMS\Form\Domain\Runtime\FormRuntime\$objectManager.

◆ invokeFinishers()

TYPO3\CMS\Form\Domain\Runtime\FormRuntime::invokeFinishers ( )
protected

Executes all finishers of this form

Returns
string

Definition at line 569 of file FormRuntime.php.

References TYPO3\CMS\Form\Domain\Runtime\FormRuntime\getControllerContext().

Referenced by TYPO3\CMS\Form\Domain\Runtime\FormRuntime\render().

◆ isAfterLastPage()

TYPO3\CMS\Form\Domain\Runtime\FormRuntime::isAfterLastPage ( )
protected

Returns TRUE if the last page of the form has been submitted, otherwise FALSE

Returns
bool

Definition at line 380 of file FormRuntime.php.

Referenced by TYPO3\CMS\Form\Domain\Runtime\FormRuntime\render(), TYPO3\CMS\Form\Domain\Runtime\FormRuntime\renderHoneypot(), and TYPO3\CMS\Form\Domain\Runtime\FormRuntime\userWentBackToPreviousStep().

◆ isFirstRequest()

TYPO3\CMS\Form\Domain\Runtime\FormRuntime::isFirstRequest ( )
protected

◆ mapAndValidatePage()

◆ offsetExists()

TYPO3\CMS\Form\Domain\Runtime\FormRuntime::offsetExists (   $identifier)
Parameters
string$identifier
Returns
bool

Definition at line 709 of file FormRuntime.php.

References TYPO3\CMS\Form\Domain\Runtime\FormRuntime\getElementValue().

◆ offsetGet()

TYPO3\CMS\Form\Domain\Runtime\FormRuntime::offsetGet (   $identifier)
Parameters
string$identifier
Returns
mixed

Definition at line 737 of file FormRuntime.php.

References TYPO3\CMS\Form\Domain\Runtime\FormRuntime\getElementValue().

◆ offsetSet()

TYPO3\CMS\Form\Domain\Runtime\FormRuntime::offsetSet (   $identifier,
  $value 
)
Parameters
string$identifier
mixed$value

Definition at line 754 of file FormRuntime.php.

◆ offsetUnset()

TYPO3\CMS\Form\Domain\Runtime\FormRuntime::offsetUnset (   $identifier)
Parameters
string$identifier

Definition at line 763 of file FormRuntime.php.

◆ overrideCurrentPage()

TYPO3\CMS\Form\Domain\Runtime\FormRuntime::overrideCurrentPage ( int  $pageIndex)

Override the current page taken from the request, rendering the page with index $pageIndex instead.

This is typically not needed in production code, but it is very helpful when displaying some kind of "preview" of the form.

Parameters
int$pageIndex

Definition at line 528 of file FormRuntime.php.

◆ processSubmittedFormValues()

TYPO3\CMS\Form\Domain\Runtime\FormRuntime::processSubmittedFormValues ( )
protected

◆ render()

TYPO3\CMS\Form\Domain\Runtime\FormRuntime::render ( )

◆ renderHoneypot()

◆ setHoneypotNameInSession()

TYPO3\CMS\Form\Domain\Runtime\FormRuntime::setHoneypotNameInSession ( Page  $page,
string  $honeypotName 
)
protected

◆ userWentBackToPreviousStep()

TYPO3\CMS\Form\Domain\Runtime\FormRuntime::userWentBackToPreviousStep ( )
protected

returns TRUE if the user went back to any previous step in the form.

Returns
bool

Definition at line 412 of file FormRuntime.php.

References TYPO3\CMS\Form\Domain\Runtime\FormRuntime\isAfterLastPage(), and TYPO3\CMS\Form\Domain\Runtime\FormRuntime\isFirstRequest().

Referenced by TYPO3\CMS\Form\Domain\Runtime\FormRuntime\processSubmittedFormValues().

Member Data Documentation

◆ $currentPage

TYPO3\CMS\Form\Domain\Runtime\FormRuntime::$currentPage = null
protected

◆ $formDefinition

TYPO3\CMS\Form\Domain\Runtime\FormRuntime::$formDefinition
protected

◆ $formState

TYPO3\CMS\Form\Domain\Runtime\FormRuntime::$formState
protected

◆ $hashService

TYPO3\CMS\Form\Domain\Runtime\FormRuntime::$hashService
protected

◆ $lastDisplayedPage

TYPO3\CMS\Form\Domain\Runtime\FormRuntime::$lastDisplayedPage = null
protected

◆ $objectManager

TYPO3\CMS\Form\Domain\Runtime\FormRuntime::$objectManager
protected

◆ $request

TYPO3\CMS\Form\Domain\Runtime\FormRuntime::$request
protected

◆ $response

TYPO3\CMS\Form\Domain\Runtime\FormRuntime::$response
protected

◆ HONEYPOT_NAME_SESSION_IDENTIFIER

const TYPO3\CMS\Form\Domain\Runtime\FormRuntime::HONEYPOT_NAME_SESSION_IDENTIFIER = 'tx_form_honeypot_name_'

Definition at line 82 of file FormRuntime.php.