I have a numeric parameter in the symfony's parameters.yml file and I have a configuration class in my bundle where I validate that the parameter is an integer, but I get the following error in the validation proccess:
[Symfony\Component\Config\Definition\Exception\InvalidTypeException]
Invalid type for path "page_size". Expected int, but got string.
Is there a way to specify the parameter type in the parameters.yml file?
EDIT
parameters.yml:
parameters:
...
list_page_size: 15
...
config.yml:
...
example:
page_size: %list_page_size%
...
Configuration.php:
class Configuration implements ConfigurationInterface
{
/**
* {@inheritDoc}
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('example');
$rootNode->children()
// Some code here
->integerNode('page_size')
->defaultValue(15)
->end()
// More code here
->end();
return $treeBuilder;
}
}
EDIT 2
I have discovered that the exception is thrown in the prepend() method in the bundle extension file (DependencyInjection/ExampleExtension.php), but the error is not thrown in the load method of the same file. It seems like if the parameters.yml file was not loaded at prepend method execution time.
page_size: 15directly in the config.yml file, it runs.