Elcodi\Store\CoreBundle\DependencyInjection\Configuration::setupTree PHP Method

setupTree() protected method

Configure the root node
protected setupTree ( ArrayNodeDefinition $rootNode )
$rootNode Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition
    protected function setupTree(ArrayNodeDefinition $rootNode)
    {
        $templateValidation = function ($value) {
            if (is_string($value)) {
                return $value;
            }
            throw new \InvalidArgumentException(sprintf('Status templates must be strings, "%s" found', $value));
        };
        $checkForNumeric = function ($value) {
            if (is_numeric($value)) {
                return $value;
            }
            throw new \InvalidArgumentException(sprintf('Status code for error templates must be numeric, "%s" found', $value));
        };
        $checkForNumericKeys = function (array $value) {
            foreach ($value as $code => $template) {
                if (!is_numeric($code)) {
                    throw new \InvalidArgumentException(sprintf('Status codes for error templates must be numeric, "%s" found', $code));
                }
            }
            return $value;
        };
        $rootNode->children()->arrayNode('error_templates')->info('Error templates setup')->canBeEnabled()->children()->scalarNode('default')->info('Default template for exceptions')->defaultValue('Exception:error.html.twig')->validate()->always($templateValidation)->end()->end()->arrayNode('by_code')->info('Specific template by status code')->example('{ 404: Exception:error.html.twig }')->useAttributeAsKey('name')->prototype('scalar')->validate()->ifTrue(function ($value) {
            return null !== $value;
        })->then($templateValidation)->end()->end()->validate()->always($checkForNumericKeys)->end()->end()->scalarNode('fallback')->info('Default status code for non-http exceptions')->defaultFalse()->treatTrueLike(Response::HTTP_INTERNAL_SERVER_ERROR)->validate()->always($checkForNumeric)->end()->end()->end()->end()->end();
    }
Configuration