php - Merge Dependency Injection Parameters by key -


i new symfony. need create 2 or 3 separate bundles. each bundle extends dependencyinjection providing array typed parameter key:navigations different values.

nav.xml on bundle page:

<parameters>     <parameter key="navigations" type="collection">         <parameter key="page" type="collection">             <parameter key="label">page</parameter>             <parameter key="url">%admin%/page</parameter>         </parameter>     </parameter> </parameters> 

nav.xml on bundle blog:

<parameters>     <parameter key="navigations" type="collection">         <parameter key="blog" type="collection">             <parameter key="label">blog</parameter>             <parameter key="url">page</parameter>         </parameter>     </parameter> </parameters> 

when do:

$nav = $this->container->getparameter('navigations'); dump($nav); 

i last defined parameters. how should merge them ?

each parameter name should start bundle alias, though best-practice suggestion. rest of parameter name use period (.) separate different parts (e.g. acme_hello.email.from).

in configuration file

<!-- app/config/config.xml --> <parameters>     <parameter key="acme_hello.email.from">fabien@example.com</parameter> </parameters> 

retrieve configuration parameters in code container:

$container->getparameter('acme_hello.email.from'); 

read more in best practices


Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -