I’ve had a bit of an odd issue where JavaScript files from a plugin I’d written weren’t being included for some reason.

Turns out that there’s a bug / feature (?) in the way symfony merges config files.

plugins/myPlugin/config/view.yml

all:
  javascripts:
    - /js/one.js
    - /js/two.js
    - /js/three.js

app/frontend/config/view.yml

all:
  javascripts:
    - /js/four.js
    - /js/five.js

 

Expected result:

all:
  javascripts:
    - /js/one.js
    - /js/two.js
    - /js/three.js
    - /js/four.js
    - /js/five.js

However, due to the way arrayDeepMerge merges the two arrays, all values from the first array are being overridden, resulting in:

all:
  javascripts:
    - /js/four.js
    - /js/five.js
    - /js/three.js

 

This will happen in all config files, most notably view.yml, app.yml, settings.yml, etc. (this has been discussed in http://groups.google.com/group/symfony-devs/browse_thread/thread/3a725483db3dec82 but lies vacant ever since 2007).

 

A workaround would be to specify a unique index for your javascript, e.g.:

plugins/myPlugin/config/view.yml

all:
  javascripts:
    101: /js/one.js
    102: /js/two.js
    103:
      /js/three.js: { position: first }

 

 

Hope this helps if you should run into the same issue.

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="">

   
© 2011 burgiblog Suffusion theme by Sayontan Sinha