30/08/2014 - SYMFONY
Aşağıdaki örnek bize parameters.yml içinde, parametrelerin nasıl atandığını gösterecek.
# app/config/parameters.yml
parameters:
string: one
array_1: one two
array_2: [one two]
array_3: [one: two]
array_4: {one two}
array_5: {one: two}
array_6:
name: one
year: two
array_7:
- one
- two
array_8:
dim_1:
- one
- two
dim_2:
- one
- two
Parametrelerin her hangi bir controller içinde print edildiğini varsayalım.
echo '<pre>';
echo $this->container->getParameter('string'); echo PHP_EOL;
print_r($this->container->getParameter('array_1')); echo PHP_EOL;
print_r($this->container->getParameter('array_2')); echo PHP_EOL;
print_r($this->container->getParameter('array_3')); echo PHP_EOL;
print_r($this->container->getParameter('array_4')); echo PHP_EOL;
print_r($this->container->getParameter('array_5')); echo PHP_EOL;
print_r($this->container->getParameter('array_6')); echo PHP_EOL;
print_r($this->container->getParameter('array_7')); echo PHP_EOL;
print_r($this->container->getParameter('array_8')); echo PHP_EOL;
exit;
one
one two
Array
(
[0] => one two
)
Array
(
[0] => Array
(
[one] => two
)
)
Array
(
[one] => two
)
Array
(
[one] => two
)
Array
(
[name] => one
[year] => two
)
Array
(
[0] => one
[1] => two
)
Array
(
[dim_1] => Array
(
[0] => one
[1] => two
)
[dim_2] => Array
(
[0] => one
[1] => two
)
)