src/Infotech/DocumentGenerator/DataStructure/Definition/CommonStructureDefinition.php
public function addPlaceholders(array $fields)
    {
        foreach ($fields as $placeholder => $fieldDef) {
            if (!is_array($fieldDef)) {
                throw new InvalidDefinitionException(
                    sprintf('Invalid definition of field "%s". Definition should be an array', $placeholder)
                );
            }

            try {
                $description = $this->getArrayValue($fieldDef, 'description');
                $sampleValue = $this->getArrayValue($fieldDef, 'sample');
                $emptyValue = $this->getArrayValue($fieldDef, 'empty', '');
                $placeholder = is_string($placeholder) ? $placeholder : $this->getArrayValue($fieldDef, 'placeholder');
            } catch (InvalidDefinitionException $e) {
                throw new InvalidDefinitionException(
                    sprintf('Invalid definition of field "%s". %s', $placeholder, $e->getMessage())
                );
            }

            $this->addPlaceholder($placeholder, $description, $sampleValue, $emptyValue);
        }
    }
public function addPlaceholders(array $fields)
    {
        foreach ($fields as $placeholder => $fieldDef) {
            if (!is_array($fieldDef)) {
                throw new InvalidDefinitionException(
                    sprintf('Invalid definition of field "%s". Definition should be an array', $placeholder)
                );
            }

            try {
                $description = $this->getArrayValue($fieldDef, 'description');
                $sampleValue = $this->getArrayValue($fieldDef, 'sample');
                $emptyValue = $this->getArrayValue($fieldDef, 'empty', '');
                $placeholder = is_string($placeholder) ? $placeholder : $this->getArrayValue($fieldDef, 'placeholder');
            } catch (InvalidDefinitionException $e) {
                throw new InvalidDefinitionException(
                    sprintf('Invalid definition of field "%s". %s', $placeholder, $e->getMessage())
                );
            }

            $this->addPlaceholder($placeholder, $description, $sampleValue, $emptyValue);
        }
    }
public function addPlaceholders ( array $ fields ) { foreach ( $ fields as $ placeholder => $ fieldDef ) { if ( ! is_array ( $ fieldDef ) ) { throw new InvalidDefinitionException ( sprintf ( 'Invalid definition of field "%s". Definition should be an array' , $ placeholder ) ) ; } try { $ description = $ this -> getArrayValue ( $ fieldDef , 'description' ) ; $ sampleValue = $ this -> getArrayValue ( $ fieldDef , 'sample' ) ; $ emptyValue = $ this -> getArrayValue ( $ fieldDef , 'empty' , '' ) ; $ placeholder = is_string ( $ placeholder ) ? $ placeholder : $ this -> getArrayValue ( $ fieldDef , 'placeholder' ) ; } catch ( InvalidDefinitionException $ e ) { throw new InvalidDefinitionException ( sprintf ( 'Invalid definition of field "%s". %s' , $ placeholder , $ e -> getMessage ( ) ) ) ; } $ this -> addPlaceholder ( $ placeholder , $ description , $ sampleValue , $ emptyValue ) ; } }
@param array $fields Fields definitions.
<code>
[
[
'placeholder' => string,
'description' => string,
'sample' => string,
'empty' => string opt
],
...
]
</code>

@throws DefinitionDuplicateException if definition with same placeholder's name already exists
@throws InvalidDefinitionException if definition malformed
@param array $fields Fields definitions . <code > [ [ placeholder = > string description = > string sample = > string empty = > string opt ] ... ] < / code >