TYPO3 CMS  TYPO3_7-6
TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript Class Reference

Public Member Functions

 convert ($json)
 

Protected Member Functions

 convertToTyposcriptArray (array $elements, array &$parent, $childrenWithParentName=false)
 
 getContainer (array $element, array &$parent, $elementCounter, $childrenWithParentName=false)
 
 getForm (array $element, array &$parent, $elementCounter)
 
 getDefaultElementSetup (array $element, array &$parent, $elementCounter, $childrenWithParentName=false)
 
 getContentObjectType (array $element)
 
 setConfiguration (array $element, array &$parent, $elementCounter, $childrenWithParentName=false)
 
 setAttributes (array $attributes, array &$parent, $elementCounter, $childrenWithParentName=false)
 
 setConfirmation ($confirmation, array &$parent, $elementCounter)
 
 setFilters (array $filters, array &$parent, $elementCounter)
 
 setLabel (array $label, array &$parent, $elementCounter)
 
 setLayout (array $element, $value, array &$parent, $elementCounter)
 
 setLegend (array $legend, array &$parent, $elementCounter)
 
 setOptions (array $element, array $options, array &$parent, $elementCounter)
 
 setPostProcessor (array $postProcessors, array &$parent, $elementCounter)
 
 setPrefix ($prefix, array &$parent, $elementCounter)
 
 setValidationRules (array $element, array $validationRules)
 
 setVarious (array $element, array $various, array &$parent, $elementCounter)
 
 typoscriptArrayToString (array $typoscriptArray, $addKey='', $tabCount=-1)
 

Protected Attributes

 $elementId = 0
 
 $validationRules = []
 
 $validationRulesCounter = 1
 

Detailed Description

Json to Typoscript converter

Takes the incoming Json and converts it to Typoscipt

Definition at line 22 of file JsonToTypoScript.php.

Member Function Documentation

◆ convert()

TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript::convert (   $json)

Convert JSON to TypoScript

First a TypoScript array is constructed, which will be converted to a formatted string

Parameters
string$jsonJson containing all configuration for the form
Returns
string The typoscript for the form

Definition at line 55 of file JsonToTypoScript.php.

References TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\convertToTyposcriptArray(), and TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\typoscriptArrayToString().

◆ convertToTyposcriptArray()

TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript::convertToTyposcriptArray ( array  $elements,
array &  $parent,
  $childrenWithParentName = false 
)
protected

Converts the JSON array for each element to a TypoScript array and adds this Typoscript array to the parent

Parameters
array$elementsThe JSON array
array$parentThe parent element
bool$childrenWithParentNameIndicates if the children use the parent name
Returns
void

Definition at line 76 of file JsonToTypoScript.php.

References TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\getContainer(), TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\getDefaultElementSetup(), and TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\getForm().

Referenced by TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\convert(), and TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\getContainer().

◆ getContainer()

TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript::getContainer ( array  $element,
array &  $parent,
  $elementCounter,
  $childrenWithParentName = false 
)
protected

Called for elements are a container for other elements like FORM and FIELDSET

Parameters
array$elementThe JSON array for this element
array$parentThe parent element
bool$childrenWithParentNameIndicates if the children use the parent name
int$elementCounterThe element counter
Returns
void

Definition at line 148 of file JsonToTypoScript.php.

References TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\convertToTyposcriptArray().

Referenced by TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\convertToTyposcriptArray().

◆ getContentObjectType()

TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript::getContentObjectType ( array  $element)
protected

Returns the content object type which is related to the ExtJS xtype

Parameters
array$elementThe JSON array for this element
Returns
string The Content Object Type

Definition at line 205 of file JsonToTypoScript.php.

Referenced by TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\getDefaultElementSetup().

◆ getDefaultElementSetup()

TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript::getDefaultElementSetup ( array  $element,
array &  $parent,
  $elementCounter,
  $childrenWithParentName = false 
)
protected

Called for each element

Adds the content object type to the parent array and starts adding the configuration for the element

Parameters
array$elementThe JSON array for this element
array$parentThe parent element
int$elementCounterThe element counter
bool$childrenWithParentNameIndicates if the children use the parent name
Returns
void

Definition at line 187 of file JsonToTypoScript.php.

References TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\getContentObjectType(), and TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\setConfiguration().

Referenced by TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\convertToTyposcriptArray().

◆ getForm()

TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript::getForm ( array  $element,
array &  $parent,
  $elementCounter 
)
protected

Only called for the type FORM

Adds the validation rules to the form. In the wizard they are added to each element. In this script the validation rules are stored in a separate array to add them to the form at a later point.

Parameters
array$elementThe JSON array for this element
array$parentThe parent element
int$elementCounterThe element counter
Returns
void

Definition at line 167 of file JsonToTypoScript.php.

References TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\$validationRules.

Referenced by TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\convertToTyposcriptArray().

◆ setAttributes()

TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript::setAttributes ( array  $attributes,
array &  $parent,
  $elementCounter,
  $childrenWithParentName = false 
)
protected

Set the attributes for the element

Parameters
array$attributesThe JSON array for the attributes of this element
array$parentThe parent element
int$elementCounterThe element counter
bool$childrenWithParentNameIndicates if the children use the parent name
Returns
void

Definition at line 303 of file JsonToTypoScript.php.

References TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\$elementId.

Referenced by TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\setConfiguration().

◆ setConfiguration()

TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript::setConfiguration ( array  $element,
array &  $parent,
  $elementCounter,
  $childrenWithParentName = false 
)
protected

◆ setConfirmation()

TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript::setConfirmation (   $confirmation,
array &  $parent,
  $elementCounter 
)
protected

Set the confirmation for the element FORM

The confirmation indicates a confirmation screen has to be displayed

Parameters
bool$confirmationTRUE when confirmation screen
array$parentThe parent element
int$elementCounterThe element counter
Returns
void

Definition at line 325 of file JsonToTypoScript.php.

Referenced by TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\setConfiguration().

◆ setFilters()

TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript::setFilters ( array  $filters,
array &  $parent,
  $elementCounter 
)
protected

Set the filters for the element

Parameters
array$filtersThe JSON array for the filters of this element
array$parentThe parent element
int$elementCounterThe element counter
Returns
void

Definition at line 338 of file JsonToTypoScript.php.

Referenced by TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\setConfiguration().

◆ setLabel()

TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript::setLabel ( array  $label,
array &  $parent,
  $elementCounter 
)
protected

Set the label for the element

Parameters
array$labelThe JSON array for the label of this element
array$parentThe parent element
int$elementCounterThe element counter
Returns
void

Definition at line 359 of file JsonToTypoScript.php.

Referenced by TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\setConfiguration().

◆ setLayout()

TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript::setLayout ( array  $element,
  $value,
array &  $parent,
  $elementCounter 
)
protected

Changes the layout of some elements when this has been set in the wizard

The wizard only uses 'back' or 'front' to set the layout. The TypoScript of the form uses a XML notation for the position of the label to the field.

Parameters
array$elementThe JSON array for this element
string$valueThe layout setting, back or front
array$parentThe parent element
int$elementCounterThe element counter
Returns
void

Definition at line 379 of file JsonToTypoScript.php.

Referenced by TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\setConfiguration().

◆ setLegend()

TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript::setLegend ( array  $legend,
array &  $parent,
  $elementCounter 
)
protected

Set the legend for the element

Parameters
array$legendThe JSON array for the legend of this element
array$parentThe parent element
int$elementCounterThe element counter
Returns
void

Definition at line 427 of file JsonToTypoScript.php.

Referenced by TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\setConfiguration().

◆ setOptions()

TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript::setOptions ( array  $element,
array  $options,
array &  $parent,
  $elementCounter 
)
protected

Set the options for a SELECT

Although other elements like CHECKBOXGROUP and RADIOGROUP are using the option setting as well, they act like containers and are handled differently

Parameters
array$elementThe JSON array for this element
array$optionsThe JSON array for the options of this element
array$parentThe parent element
int$elementCounterThe element counter
Returns
void

Definition at line 447 of file JsonToTypoScript.php.

Referenced by TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\setConfiguration().

◆ setPostProcessor()

TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript::setPostProcessor ( array  $postProcessors,
array &  $parent,
  $elementCounter 
)
protected

Set the post processors for the element

Parameters
array$postProcessorsThe JSON array for the post processors of this element
array$parentThe parent element
int$elementCounterThe element counter
Returns
void

Definition at line 470 of file JsonToTypoScript.php.

Referenced by TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\setConfiguration().

◆ setPrefix()

TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript::setPrefix (   $prefix,
array &  $parent,
  $elementCounter 
)
protected

Set the prefix for the element FORM

The prefix will be used in the names of all elements in the form

Parameters
string$prefixThe prefix for all element names
array$parentThe parent element
int$elementCounterThe element counter
Returns
void

Definition at line 493 of file JsonToTypoScript.php.

Referenced by TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\setConfiguration().

◆ setValidationRules()

TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript::setValidationRules ( array  $element,
array  $validationRules 
)
protected

Stores the validation rules, set to the elements, in a temporary array

In the wizard the validation rules are added to the element, in TypoScript they are added to the form.

Parameters
array$elementThe JSON array for this element
array$validationRulesThe temporary storage array for the rules
Returns
void

Definition at line 508 of file JsonToTypoScript.php.

References TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\$elementId, and TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\$validationRulesCounter.

Referenced by TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\setConfiguration().

◆ setVarious()

TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript::setVarious ( array  $element,
array  $various,
array &  $parent,
  $elementCounter 
)
protected

Set the various configuration of an element

Parameters
array$elementThe JSON array for this element
array$variousThe JSON array for the various options of this element
array$parentThe parent element
int$elementCounterThe element counter
Returns
void

Definition at line 533 of file JsonToTypoScript.php.

Referenced by TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\setConfiguration().

◆ typoscriptArrayToString()

TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript::typoscriptArrayToString ( array  $typoscriptArray,
  $addKey = '',
  $tabCount = -1 
)
protected

Converts a TypoScript array to a formatted string

Takes care of indentation, curly brackets and parentheses

Parameters
array$typoscriptArrayThe TypoScript array
string$addKeyKey which has underlying configuration
int$tabCountThe amount of tabs for indentation
Returns
string The formatted TypoScript string

Definition at line 560 of file JsonToTypoScript.php.

Referenced by TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\convert().

Member Data Documentation

◆ $elementId

TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript::$elementId = 0
protected

◆ $validationRules

TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript::$validationRules = []
protected

◆ $validationRulesCounter

TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript::$validationRulesCounter = 1
protected