<h1 dir="auto">Environment</h1>
<div class="highlight highlight-source-json notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&quot;symfony/symfony&quot;: &quot;2.5.*-dev&quot;,
&quot;payum/payum-bundle&quot;: &quot;0.11.*@dev&quot;,
&quot;payum/payum&quot;: &quot;0.11.*@dev&quot;,
&quot;payum/paypal-express-checkout-nvp&quot;: &quot;*&quot;,"><pre class="notranslate"><span class="pl-ent">"symfony/symfony"</span>: <span class="pl-s"><span class="pl-pds">"</span>2.5.*-dev<span class="pl-pds">"</span></span>,
<span class="pl-ent">"payum/payum-bundle"</span>: <span class="pl-s"><span class="pl-pds">"</span>0.11.*@dev<span class="pl-pds">"</span></span>,
<span class="pl-ent">"payum/payum"</span>: <span class="pl-s"><span class="pl-pds">"</span>0.11.*@dev<span class="pl-pds">"</span></span>,
<span class="pl-ent">"payum/paypal-express-checkout-nvp"</span>: <span class="pl-s"><span class="pl-pds">"</span>*<span class="pl-pds">"</span></span>,</pre></div>
<p dir="auto">I have a CustomBundle, there is a <code class="notranslate">services.yml</code> file with default parameters in <code class="notranslate">[Bundle directory]/Resources/config</code> directory:</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="parameters:
    custom_bundle.paypal.api_username:   'default_username'
    custom_bundle.paypal.api_password:   'default_password'
    custom_bundle.paypal.api_signature:  'default_signature'"><pre class="notranslate"><span class="pl-ent">parameters</span>:
    <span class="pl-ent">custom_bundle.paypal.api_username</span>:   <span class="pl-s"><span class="pl-pds">'</span>default_username<span class="pl-pds">'</span></span>
    <span class="pl-ent">custom_bundle.paypal.api_password</span>:   <span class="pl-s"><span class="pl-pds">'</span>default_password<span class="pl-pds">'</span></span>
    <span class="pl-ent">custom_bundle.paypal.api_signature</span>:  <span class="pl-s"><span class="pl-pds">'</span>default_signature<span class="pl-pds">'</span></span></pre></div>
<p dir="auto">There are other values in <code class="notranslate">app/config/parameters.yml</code>:</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="parameters:
    custom_bundle.paypal.api_username:   'other_username'
    custom_bundle.paypal.api_password:   'other_password'
    custom_bundle.paypal.api_signature:  'other_signature'"><pre class="notranslate"><span class="pl-ent">parameters</span>:
    <span class="pl-ent">custom_bundle.paypal.api_username</span>:   <span class="pl-s"><span class="pl-pds">'</span>other_username<span class="pl-pds">'</span></span>
    <span class="pl-ent">custom_bundle.paypal.api_password</span>:   <span class="pl-s"><span class="pl-pds">'</span>other_password<span class="pl-pds">'</span></span>
    <span class="pl-ent">custom_bundle.paypal.api_signature</span>:  <span class="pl-s"><span class="pl-pds">'</span>other_signature<span class="pl-pds">'</span></span></pre></div>
<p dir="auto">In <code class="notranslate">app/config/config.yml</code>:</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="payum:
    contexts:
        paypal_express_checkout:
            paypal_express_checkout_nvp:
                username:  %custom_bundle.paypal.api_username%
                password:  %custom_bundle.paypal.api_password%
                signature: %custom_bundle.paypal.api_signature%
                sandbox:   %custom_bundle.paypal.use_sandbox%"><pre class="notranslate"><span class="pl-ent">payum</span>:
    <span class="pl-ent">contexts</span>:
        <span class="pl-ent">paypal_express_checkout</span>:
            <span class="pl-ent">paypal_express_checkout_nvp</span>:
                <span class="pl-ent">username</span>:  <span class="pl-s">%custom_bundle.paypal.api_username%</span>
                <span class="pl-ent">password</span>:  <span class="pl-s">%custom_bundle.paypal.api_password%</span>
                <span class="pl-ent">signature</span>: <span class="pl-s">%custom_bundle.paypal.api_signature%</span>
                <span class="pl-ent">sandbox</span>:   <span class="pl-s">%custom_bundle.paypal.use_sandbox%</span></pre></div>
<h1 dir="auto">The magic</h1>
<p dir="auto">In Controller (good):</p>
<div class="highlight highlight-text-html-php notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&lt;?php
// ...
$this-&gt;container-&gt;getParameter('custom_bundle.paypal.api_username') // ==&gt;  'other_username'"><pre class="notranslate"><span class="pl-ent">&lt;?php</span>
<span class="pl-c">// ...</span>
<span class="pl-s1"><span class="pl-c1">$</span><span class="pl-smi">this</span></span>-&gt;<span class="pl-c1">container</span>-&gt;<span class="pl-en">getParameter</span>(<span class="pl-s">'custom_bundle.paypal.api_username'</span>) <span class="pl-c">// ==&gt;  'other_username'</span></pre></div>
<p dir="auto">In <code class="notranslate">app/cache/dev/appDevDebugProjectContainer.php</code> file (wrong: default values):</p>
<div class="highlight highlight-text-html-php notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&lt;?php
    /**
     * Gets the 'payum.context.paypal_express_checkout.api' service.
     *
     * This service is shared.
     * This method always returns the same instance of the service.
     *
     * @return Payum\Paypal\ExpressCheckout\Nvp\Api A Payum\Paypal\ExpressCheckout\Nvp\Api instance.
     */
    protected function getPayum_Context_PaypalExpressCheckout_ApiService()
    {
        return $this-&gt;services['payum.context.paypal_express_checkout.api'] = new \Payum\Paypal\ExpressCheckout\Nvp\Api(array(
            'username' =&gt; 'default_username', 
            'password' =&gt; 'default_password',
            'signature' =&gt; 'default_signature',
            'sandbox' =&gt; true), $this-&gt;get('payum.buzz.client'));
    }"><pre class="notranslate"><span class="pl-ent">&lt;?php</span>
    <span class="pl-c">/**</span>
<span class="pl-c">     * Gets the 'payum.context.paypal_express_checkout.api' service.</span>
<span class="pl-c">     *</span>
<span class="pl-c">     * This service is shared.</span>
<span class="pl-c">     * This method always returns the same instance of the service.</span>
<span class="pl-c">     *</span>
<span class="pl-c">     * @return Payum\Paypal\ExpressCheckout\Nvp\Api A Payum\Paypal\ExpressCheckout\Nvp\Api instance.</span>
<span class="pl-c">     */</span>
    <span class="pl-k">protected</span> <span class="pl-k">function</span> <span class="pl-en">getPayum_Context_PaypalExpressCheckout_ApiService</span>()
    {
        <span class="pl-k">return</span> <span class="pl-s1"><span class="pl-c1">$</span><span class="pl-smi">this</span></span>-&gt;<span class="pl-c1">services</span>[<span class="pl-s">'payum.context.paypal_express_checkout.api'</span>] = <span class="pl-k">new</span> \<span class="pl-v">Payum</span>\<span class="pl-v">Paypal</span>\<span class="pl-v">ExpressCheckout</span>\<span class="pl-v">Nvp</span>\<span class="pl-v">Api</span>(<span class="pl-en">array</span>(
            <span class="pl-s">'username'</span> =&gt; <span class="pl-s">'default_username'</span>, 
            <span class="pl-s">'password'</span> =&gt; <span class="pl-s">'default_password'</span>,
            <span class="pl-s">'signature'</span> =&gt; <span class="pl-s">'default_signature'</span>,
            <span class="pl-s">'sandbox'</span> =&gt; <span class="pl-c1">true</span>), <span class="pl-s1"><span class="pl-c1">$</span><span class="pl-smi">this</span></span>-&gt;<span class="pl-en">get</span>(<span class="pl-s">'payum.buzz.client'</span>));
    }</pre></div>
<p dir="auto">Is it Payum or Symfony bug? When I remove defaults from <code class="notranslate">services.yml</code>, it is improved.</p>
<p dir="auto">I trying to use third-party bundle. (<a href="http://knpbundles.com/ornicar/ApcBundle" rel="nofollow">http://knpbundles.com/ornicar/ApcBundle</a>). This bundle requires me to provide <code class="notranslate">ornicar_apc.host</code> config value. I am trying to re-use existing configuration value <code class="notranslate">router.request_context.host</code>, which is overrided in my <code class="notranslate">parameters.yml</code>, but third-party bundle always compiled with default configuration value <code class="notranslate">localhost</code>. After some time of debugging I found:</p>
<p dir="auto">1st step: <a href="https://github.com/symfony/symfony/blob/master/src/Symfony/Component/DependencyInjection/Compiler/MergeExtensionConfigurationPass.php#L50">https://github.com/symfony/symfony/blob/master/src/Symfony/Component/DependencyInjection/Compiler/MergeExtensionConfigurationPass.php#L50</a> loading configuration for the <code class="notranslate">framework</code> extension. Keep in mind: <code class="notranslate">$container</code> already have loaded valid value for <code class="notranslate">router.request_context.host</code>.</p>
<p dir="auto">2nd step: This line: <a href="https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php#L306">https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php#L306</a> loads default config value for <code class="notranslate">router.request_context.host</code> parameter value and rewriting existing "normal" value.</p>
<p dir="auto">3rd step: Thrd-party bundle uses overwriten value of <code class="notranslate">router.request_context.host</code> parameter.</p>
<p dir="auto">Could you help me with resolving this bug?</p>