PHP Class WellCommerce\Bundle\ThemeBundle\Generator\ThemeFieldsGenerator

Author: Adam Piotrowski ([email protected])
Inheritance: extends WellCommerce\Bundle\AppBundle\DependencyInjection\AbstractContainer, implements Symfony\Component\DependencyInjection\ContainerAwareInterface
Show file Open project: wellcommerce/wellcommerce

Protected Properties

Property Type Description
$builder WellCommerce\Component\Form\FormBuilderInterface
$configuration DOMDocument
$configurationFile
$defaultValues
$form WellCommerce\Component\Form\Elements\Form
$layoutBoxSelector
$nextFieldId
$theme WellCommerce\Bundle\ThemeBundle\Entity\Theme
$themeDir

Public Methods

Method Description
addFormFields ( WellCommerce\Component\Form\FormBuilderInterface $builder ) Adds required theme configuration fields to form
getDefaultValues ( $field ) : array Returns default values for field
loadThemeFieldsConfiguration ( Theme $theme, string $layoutBoxSelector = '.layout-box' ) Initializes generator configuration

Protected Methods

Method Description
addField ( DOMElement $field ) Resolves field type and adds it to fieldset
addFieldBackground ( DOMElement $field ) : mixed Adds background selector
addFieldFont ( DOMElement $field ) : mixed Adds font selector
addFieldHeight ( DOMElement $field ) : mixed Adds height input
addFieldWidth ( DOMElement $field ) : mixed Adds width input
addFieldset ( DOMElement $node ) Adds new configuration fieldset to form
addSizeInput ( string $type, array $attributes ) : WellCommerce\Component\Form\Elements\ElementInterface Returns text field
getFieldAttributes ( DOMElement $item ) : array Returns an array containing all required field attributes
getFieldName ( DOMElement $item ) : string Returns form name or sets it automatically
getFieldSelector ( DOMElement $item ) : mixed Returns field specific selector
getFieldTypeSuffix ( $type ) : mixed Returns field element suffix

Private Methods

Method Description
getDirectory ( ) : string Returns theme working directory
loadConfiguration ( ) : DOMDocument | null Loads fields configuration from fields.xml file
loadFile ( $file ) : DOMDocument Parses XML file

Method Details

addField() protected method

Resolves field type and adds it to fieldset
protected addField ( DOMElement $field )
$field DOMElement

addFieldBackground() protected method

Adds background selector
protected addFieldBackground ( DOMElement $field ) : mixed
$field DOMElement
return mixed

addFieldFont() protected method

Adds font selector
protected addFieldFont ( DOMElement $field ) : mixed
$field DOMElement
return mixed

addFieldHeight() protected method

Adds height input
protected addFieldHeight ( DOMElement $field ) : mixed
$field DOMElement
return mixed

addFieldWidth() protected method

Adds width input
protected addFieldWidth ( DOMElement $field ) : mixed
$field DOMElement
return mixed

addFieldset() protected method

Adds new configuration fieldset to form
protected addFieldset ( DOMElement $node )
$node DOMElement

addFormFields() public method

Adds required theme configuration fields to form
public addFormFields ( WellCommerce\Component\Form\FormBuilderInterface $builder )
$builder WellCommerce\Component\Form\FormBuilderInterface

addSizeInput() protected method

Returns text field
protected addSizeInput ( string $type, array $attributes ) : WellCommerce\Component\Form\Elements\ElementInterface
$type string
$attributes array
return WellCommerce\Component\Form\Elements\ElementInterface

getDefaultValues() public method

Returns default values for field
public getDefaultValues ( $field ) : array
$field
return array

getFieldAttributes() protected method

Returns an array containing all required field attributes
protected getFieldAttributes ( DOMElement $item ) : array
$item DOMElement
return array

getFieldName() protected method

Returns form name or sets it automatically
protected getFieldName ( DOMElement $item ) : string
$item DOMElement
return string

getFieldSelector() protected method

Returns field specific selector
protected getFieldSelector ( DOMElement $item ) : mixed
$item DOMElement
return mixed

getFieldTypeSuffix() protected method

Returns field element suffix
protected getFieldTypeSuffix ( $type ) : mixed
$type
return mixed

loadThemeFieldsConfiguration() public method

Initializes generator configuration
public loadThemeFieldsConfiguration ( Theme $theme, string $layoutBoxSelector = '.layout-box' )
$theme WellCommerce\Bundle\ThemeBundle\Entity\Theme
$layoutBoxSelector string

Property Details

$builder protected property

protected FormBuilderInterface,WellCommerce\Component\Form $builder
return WellCommerce\Component\Form\FormBuilderInterface

$configuration protected property

protected DOMDocument $configuration
return DOMDocument

$configurationFile protected property

protected $configurationFile

$defaultValues protected property

protected $defaultValues

$form protected property

protected Form,WellCommerce\Component\Form\Elements $form
return WellCommerce\Component\Form\Elements\Form

$layoutBoxSelector protected property

protected $layoutBoxSelector

$nextFieldId protected property

protected $nextFieldId

$theme protected property

protected Theme,WellCommerce\Bundle\ThemeBundle\Entity $theme
return WellCommerce\Bundle\ThemeBundle\Entity\Theme

$themeDir protected property

protected $themeDir