ZendFramework Headscript Helper - Make scripts unique
- by tokam
How can I ensure that the headScript and headStyle helper include css files only once when added?
The reason I am asking is that I would like to display some contents in a lightbox and all Flashmassages.E.g. notifications like profile successfully edited.
To display flashmessages in the lightbox i would like to check at the top of my layout script if they are set, in case they are i would like to attach the required javascript library using the headScript helper.
The problem is that I have no control about the scripts which were already added at this point. Maybe at a page where the library is needed for an other use case, it has already been added with addScript.
How can I ensure all scripts are added only once to my helper?
I already checked that these helpers extend Zend_View_Helper_Placeholder_Container_Standalone which uses an ArrayObject internally to hold the data and provides getters & setter to the array object.
Maybe a solution here would be to check each time when adding a script file if it already exists using the ArrayObject?