PHPSocialNetwork/phpfastcache-bundle

View on GitHub
src/DependencyInjection/Configuration.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

/**
 *
 * This file is part of phpFastCache.
 *
 * @license MIT License (MIT)
 *
 * For full copyright and license information, please see the docs/CREDITS.txt file.
 *
 * @author Georges.L (Geolim4)  <contact@geolim4.com>
 * @author PastisD https://github.com/PastisD
 * @author Khoa Bui (khoaofgod)  <khoaofgod@gmail.com> http://www.phpfastcache.com
 *
 */
declare(strict_types=1);

namespace Phpfastcache\Bundle\DependencyInjection;

use Phpfastcache\CacheManager;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;

/**
 * Class Configuration
 * @package Phpfastcache\Bundle\DependencyInjection
 */
class Configuration implements ConfigurationInterface
{
    /**
     * {@inheritDoc}
     *
     * @throws \RuntimeException
     */
    public function getConfigTreeBuilder()
    {
        $treeBuilder = new TreeBuilder();
        $rootNode = $treeBuilder->root('phpfastcache');

        $rootNode
            ->children()
                ->scalarNode('twig_driver')
                    ->isRequired()
                ->end()
                ->booleanNode('twig_block_debug')
                    ->defaultFalse()
                ->end()
                ->arrayNode('drivers')
                    ->useAttributeAsKey('name')
                    ->prototype('array')
                        ->children()
                            ->enumNode('type')->isRequired()->values(CacheManager::getDriverList())->end() // @TODO : Add all available drivers
                            ->arrayNode('parameters')->isRequired()->prototype('variable')->end()
                        ->end()
                    ->end()
                ->end()
            ->end();

        return $treeBuilder;
    }
}