An error occurred while loading the file. Please try again.
-
Guillaume Perréal authoredcbca3756
<?php declare(strict_types=1);
/*
* Copyright (C) 2015-2017 IRSTEA
* All rights reserved.
*/
namespace Irstea\FileUploadBundle\DependencyInjection;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
/**
* This is the class that validates and merges configuration from your app/config files.
*
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class}
*/
class Configuration implements ConfigurationInterface
{
/**
* {@inheritdoc}
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('irstea_file_upload');
$rootNode
->children()
->integerNode('max_chunk_size')
->beforeNormalization()
->ifString()
->then(
function ($v) {
$int = intval($v);
if (strpos($v, 'K')) {
return 1000 * $int;
}
if (strpos($v, 'M')) {
return 1000000 * $int;
}
return $int;
}
)
->end()
->defaultValue(0)
->treatNullLike(0)
->treatFalseLike(0)
->min(0)
->end()
->end();
return $treeBuilder;
}
}