TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
FormRuntime Class Reference
Inheritance diagram for FormRuntime:
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 ()
 
 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.<h1>RenderingaForm</h1>That'seasy,justcallrender()ontheFormRuntime:/&mdash;codephp$form=$formDefinition->bind($request, $response);$renderedForm=$form->render();---<h1>AccessingFormValues</h1>Inordertogetthevaluestheuserhasenteredintotheform,youcanaccessthisobjectlikeanarray:Ifaformfieldwiththeidentifier<em>firstName</em>exists,youcando**$form['firstName']**toretrieveitscurrentvalue.Youcanalsosetvaluesinthesameway.<h1>RenderingInternals</h1>TheFormRuntimeaskstheFormDefinitionabouttheconfiguredRendererwhichshouldbeused(@link\TYPO3\CMS\Form\Domain\Model\FormDefinition::getRendererClassName),andthentriggerrender()onthiselement.Thismakesitpossibletodeclarativelydefinehowaformshouldberendered.Scope:frontend<strong>ThisclassisNOTmeanttobesubclassedbydevelopers.</strong>@api

Definition at line 78 of file FormRuntime.php.

Constructor & Destructor Documentation

__construct ( FormDefinition  $formDefinition,
Request  $request,
Response  $response 
)
Parameters
FormDefinition$formDefinition
Request$request
Response$response

Definition at line 157 of file FormRuntime.php.

References FormRuntime\$formDefinition, FormRuntime\$request, FormRuntime\$response, and Request\getArguments().

Member Function Documentation

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
Returns
void

Implements RootRenderableInterface.

Definition at line 771 of file FormRuntime.php.

getControllerContext ( )
protected
Returns
ControllerContext

Definition at line 592 of file FormRuntime.php.

References ControllerContext\setRequest().

Referenced by FormRuntime\invokeFinishers(), and FormRuntime\render().

getCurrentPage ( )

Returns the currently selected page

Returns
Page

Definition at line 554 of file FormRuntime.php.

References FormRuntime\$currentPage.

getElementValue ( string  $identifier)

Returns the value of the specified element

Parameters
string$identifier
Returns
mixed

Definition at line 690 of file FormRuntime.php.

Referenced by FormRuntime\offsetExists(), and FormRuntime\offsetGet().

getFormDefinition ( )

Get the underlying form definition from the runtime

Returns
FormDefinition

Definition at line 757 of file FormRuntime.php.

References FormRuntime\$formDefinition.

getFormState ( )
Returns
FormState

Definition at line 712 of file FormRuntime.php.

References FormRuntime\$formState.

getHoneypotNameFromSession ( Page  $page)
protected
getLabel ( )

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

Returns
string

Implements RootRenderableInterface.

Definition at line 746 of file FormRuntime.php.

getNextPage ( )

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

Returns
null|Page

Definition at line 580 of file FormRuntime.php.

getPages ( )
Returns
array<Page> The Form's pages in the correct order

Definition at line 703 of file FormRuntime.php.

getPreviousPage ( )

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

Returns
null|Page

Definition at line 565 of file FormRuntime.php.

getRendererClassName ( )

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

Returns
string the renderer class name

Implements RootRenderableInterface.

Definition at line 735 of file FormRuntime.php.

getRenderingOptions ( )

Get all rendering options

Returns
array associative array of rendering options

Implements RootRenderableInterface.

Definition at line 723 of file FormRuntime.php.

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 529 of file FormRuntime.php.

References FormRuntime\$request.

Referenced by FormRuntime\initializeObject().

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 543 of file FormRuntime.php.

References FormRuntime\$response.

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 RootRenderableInterface.

Definition at line 612 of file FormRuntime.php.

getTypoScriptFrontendController ( )
protected
Returns
TypoScriptFrontendController

Definition at line 778 of file FormRuntime.php.

References $GLOBALS.

Referenced by FormRuntime\getHoneypotNameFromSession(), and FormRuntime\setHoneypotNameInSession().

initializeCurrentPageFromRequest ( )
protected
Returns
void

Definition at line 204 of file FormRuntime.php.

Referenced by FormRuntime\initializeObject().

initializeFormStateFromRequest ( )
protected
Returns
void

Definition at line 190 of file FormRuntime.php.

References GeneralUtility\makeInstance().

Referenced by FormRuntime\initializeObject().

initializeHoneypotFromRequest ( )
protected
injectHashService ( \TYPO3\CMS\Extbase\Security\Cryptography\HashService  $hashService)
Parameters
\TYPO3\CMS\Extbase\Security\Cryptography\HashService$hashService
Returns
void

Definition at line 137 of file FormRuntime.php.

References FormRuntime\$hashService.

injectObjectManager ( \TYPO3\CMS\Extbase\Object\ObjectManagerInterface  $objectManager)
Parameters
\TYPO3\CMS\Extbase\Object\ObjectManagerInterface$objectManager

Definition at line 146 of file FormRuntime.php.

References FormRuntime\$objectManager.

invokeFinishers ( )
protected

Executes all finishers of this form

Returns
void

Definition at line 497 of file FormRuntime.php.

References FormRuntime\getControllerContext().

Referenced by FormRuntime\render().

isAfterLastPage ( )
protected

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

Returns
bool

Definition at line 348 of file FormRuntime.php.

Referenced by FormRuntime\render(), FormRuntime\renderHoneypot(), and FormRuntime\userWentBackToPreviousStep().

isFirstRequest ( )
protected

Returns TRUE if no previous page is stored in the FormState, otherwise FALSE

Returns
bool

Definition at line 358 of file FormRuntime.php.

Referenced by FormRuntime\initializeHoneypotFromRequest(), FormRuntime\initializeObject(), FormRuntime\renderHoneypot(), and FormRuntime\userWentBackToPreviousStep().

mapAndValidatePage ( Page  $page)
protected
Parameters
Page$page
Returns
Result
Exceptions
PropertyMappingException

Definition at line 390 of file FormRuntime.php.

References AbstractSection\getElementsRecursively(), and ArrayUtility\getValueByPath().

Referenced by FormRuntime\processSubmittedFormValues().

offsetExists (   $identifier)
Parameters
string$identifier
Returns
bool

Definition at line 622 of file FormRuntime.php.

References FormRuntime\getElementValue().

offsetGet (   $identifier)
Parameters
string$identifier
Returns
mixed

Definition at line 650 of file FormRuntime.php.

References FormRuntime\getElementValue().

offsetSet (   $identifier,
  $value 
)
Parameters
string$identifier
mixed$value
Returns
void

Definition at line 668 of file FormRuntime.php.

offsetUnset (   $identifier)
Parameters
string$identifier
Returns
void

Definition at line 678 of file FormRuntime.php.

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
Returns
void

Definition at line 455 of file FormRuntime.php.

processSubmittedFormValues ( )
protected
render ( )

Render this form.

Returns
null|string rendered form
Exceptions
RenderingException

Definition at line 467 of file FormRuntime.php.

References FormRuntime\getControllerContext(), FormRuntime\invokeFinishers(), and FormRuntime\isAfterLastPage().

setHoneypotNameInSession ( Page  $page,
string  $honeypotName 
)
protected
Parameters
Page$page
string$honeypotName
Returns
void

Definition at line 326 of file FormRuntime.php.

References AbstractRenderable\getIdentifier(), FormRuntime\getIdentifier(), and FormRuntime\getTypoScriptFrontendController().

Referenced by FormRuntime\renderHoneypot().

userWentBackToPreviousStep ( )
protected

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

Returns
bool

Definition at line 380 of file FormRuntime.php.

References FormRuntime\isAfterLastPage(), and FormRuntime\isFirstRequest().

Referenced by FormRuntime\processSubmittedFormValues().

Member Data Documentation

$currentPage = null
protected

Definition at line 117 of file FormRuntime.php.

Referenced by FormRuntime\getCurrentPage().

$formDefinition
protected

Definition at line 90 of file FormRuntime.php.

Referenced by FormRuntime\__construct(), and FormRuntime\getFormDefinition().

$formState
protected

Definition at line 105 of file FormRuntime.php.

Referenced by FormRuntime\getFormState().

$hashService
protected

Definition at line 130 of file FormRuntime.php.

Referenced by FormRuntime\injectHashService().

$lastDisplayedPage = null
protected

Definition at line 125 of file FormRuntime.php.

Referenced by FormRuntime\processSubmittedFormValues().

$objectManager
protected

Definition at line 85 of file FormRuntime.php.

Referenced by FormRuntime\injectObjectManager().

$request
protected

Definition at line 95 of file FormRuntime.php.

Referenced by FormRuntime\__construct(), and FormRuntime\getRequest().

$response
protected

Definition at line 100 of file FormRuntime.php.

Referenced by FormRuntime\__construct(), and FormRuntime\getResponse().

const HONEYPOT_NAME_SESSION_IDENTIFIER = 'tx_form_honeypot_name_'

Definition at line 80 of file FormRuntime.php.