Wednesday 09 July 2008 2:11:30 am
Hi, our approach of course cares about the order extensions are activated. Actually this is a pretty simple task: As our loader is able to activate any other extension from an extension which has just been activated think about the following scenario: 1. You have an extension called <b>mybase</b> which is activated in one of the "core"-settings files (which can be /settings/site.ini or /settings/override/site.ini or even /settings/siteaccessXYZ/site.ini). This extension then will be the first one loaded. 2. Inside the extension <b>mybase</b> you have defined to load two other extensions called <b>one</b> and <b>two</b>, which can be done in /extension/mybase/settings/site.ini or in /extension/mybase/settings/siteaccess/XYZ/site.ini. These two extension are loaded now. 3. This can be repeated as long as you have loaded all extensions. After this has been done once the order of all loaded extensions will be cached for future calls to keep the overhead of finding the correct load order as small as possible. This has been a really stripped down example to get the concepts of what we have done. If you think about siteaccesses, it is slightly more complex. We handle loading of extensions in two stages. The first stage is called <b>Pre siteaccess</b> the second is called <b>After siteaccess</b>. Both stages are following the same principles (as described above) of how to load extensions and both are able to activate any additional extension after an loaded extension (as described above). The <b>Pre siteaccess</b> stage is the same for every siteaccess and therefore is cached globally for all siteaccesses after the first call to eZ publish. To load an extension in this stage you can use the following config-files:
a) /settings/site.ini
b) /settings/override/site.ini
c) /extension/volano_basic_settings/settings
d) /extension/MYLOADEDEXTENSION/settings/site.ini
Note that our loader is not a magic one. So it respects for d) only those extensions which have been already loaded. So you need to activate at least one extension in a) or b) or c). The c) is a special extension which always is loaded as the first extension by our loader. This is something we've done, as we didn't wanted to touch the core-settings any longer at all.
<b>So here is an example for loading the first stage:</b> Assume you have defined to load the following extensions in either a), b) or c):
[ExtensionSettings]
ActiveExtensions[]=simpledatatypes
ActiveExtensions[]=operators
ActiveExtensions[]=complexdatatypes
This will result to activate the following additional extensions in exactly this order: <b>volano_basic_settings</b>, <b>simpledatatypes</b>, <b>operators</b>, <b>complexdatatypes</b> Now assume that in /extension/simpledatatypes/settings/site.ini is the following code:
[ExtensionSettings]
ActiveExtensions[]=defaultdesigns
ActiveExtensions[]=moredesigns
And assume that in /extension/complexdatatypes/settings/site.ini is the following code:
[ExtensionSettings]
ActiveExtensions[]=defaultdesigns
ActiveExtensions[]=andevenmoredesigns
ActiveExtensions[]=moredesigns
This will result in the following load order of extensions: <b>volano_basic_settings</b>,, <b>simpledatatypes</b>, <b>operators</b>, <b>complexdatatypes</b>, <b>defaultdesigns</b>, <b>moredesigns</b>, <b>andevenmoredesigns</b> Not that the alternate order in the site.ini of <b>complexdatatypes</b> is ignored and only the additional extension <b>andevenmoredesigns</b> is loaded. The order would be the other way arround, if <b>complexdatatypes</b> would have been loaded before <b>simpledatatypes</b>. You could continue this thing for as long as you want to, as the <b>Pre siteaccess</b> stage is able to activate any extension from a just loaded extension and then load yet an other extension from that loaded extension - but I think anybody should have get that now...
<b>To sum this up:</b> The first stage loads any defined extensions and after those are loaded it takes a look to all of those loaded extension if they define more extensions to load. And after that it does that , till there are no more additional extensions to load.
<b>Now to the siteaccess thing:</b> We now have a set of extension, which have to be loaded for any siteaccess. Any of these loaded extension is able to hold an settings/siteaccess/XYZ directory, in which we can have a site.ini just for the siteaccess we are currently using. So let's assume we're using the siteaccess "XYZ", then the following possible site.ini-files are relevant to look for us in order to find more extensions to load:
1. /extension/volano_basic_settings/settings/siteaccess/XYZ/site.ini
2. /extension/simpledatatypes/settings/siteaccess/XYZ/site.ini
3. /extension/operators/settings/siteaccess/XYZ/site.ini
4. /extension/complexdatatypes/settings/siteaccess/XYZ/site.ini
5. /extension/defaultdesigns/settings/siteaccess/XYZ/site.ini
6. /extension/moredesigns/settings/siteaccess/XYZ/site.ini
7. /extension/andevenmoredesigns/settings/siteaccess/XYZ/site.ini
8. /settings/siteaccess/XYZ/site.ini
Now assume inside /extension/volano_basic_settings/settings/siteaccess/XYZ/site.ini is the following code:
[ExtensionSettings]
ActiveExtensions[]=xyzextension
ActiveExtensions[]=defaultdesigns
And assume inside /extension/operators/settings/siteaccess/XYZ/site.ini is the following code:
[ExtensionSettings]
ActiveExtensions[]=xyzoperators
ActiveExtensions[]=defaultdesigns
This will result in this load order: <b>volano_basic_settings</b>, <b>simpledatatypes</b>, <b>operators</b>, <b>complexdatatypes</b>, <b>defaultdesigns</b>, <b>moredesigns</b>, <b>andevenmoredesigns</b>, <b>xyzextension</b>, <b>xyzoperators</b> Note that <b>defaultdesigns</b> is ignored, as it has been already loaded!
As you might know the <b>After siteaccess</b> stage is able to load an extension from inside a loaded extension, so we can have even more extensions activated: Code in /extension/xyzextension/settings/site.ini:
[ExtensionSettings]
ActiveExtensions[]=xyzextension2
ActiveExtensions[]=defaultdesigns
Code in /extension/xyzextension/settings/siteaccess/XYZ/site.ini:
[ExtensionSettings]
ActiveExtensions[]=xyzextensionjustformysiteaccessxyz
ActiveExtensions[]=defaultdesigns
Once more: <b>defaultdesigns</b> is ignored, as it has already been activated. But we now have two more extensions to load, resulting in this order: <b>volano_basic_settings</b>, <b>simpledatatypes</b>, <b>operators</b>, <b>complexdatatypes</b>, <b>defaultdesigns</b>, <b>moredesigns</b>, <b>andevenmoredesigns</b>, <b>xyzextension</b>, <b>xyzoperators</b>, <b>xyzextensionjustformysiteaccessxyz</b>, <b>xyzextension2</b>
Why <b>xyzextensionjustformysiteaccessxyz</b> is loaded before <b>xyzextension2</b> ??? This is because of the ini-load-order, which chooses siteaccess-settings above normal settings. I just stop here with the extension load order, and hope you get this thing. <b>Please drop a note if something is unclear with that!</b> Now let's have a finaly look to the ini load order (first i write here will be loaded first, higher number overrides lower numbers):
26. /settings/override/siteaccess/XYZ
25. /settings/override
24. /extension/xyzextension2/settings/siteaccess/XYZ
23. /extension/xyzextensionjustformysiteaccessxyz/settings/siteaccess/XYZ
22. /extension/xyzoperators/settings/siteaccess/XYZ
21. /extension/xyzextension/settings/siteaccess/XYZ
20. /extension/andevenmoredesigns/settings/siteaccess/XYZ
19. /extension/moredesigns/settings/siteaccess/XYZ
18. /extension/defaultdesigns/settings/siteaccess/XYZ
17. /extension/complexdatatypes/settings/siteaccess/XYZ
16. /extension/operators/settings/siteaccess/XYZ
15. /extension/simpledatatypes/settings/siteaccess/XYZ
14. /extension/volano_basic_settings/settings/siteaccess/XYZ
13. /settings/siteaccess/XYZ
12. /extension/xyzextension2/settings
11. /extension/xyzextensionjustformysiteaccessxyz
10. /extension/xyzoperators/settings
9. /extension/xyzextension/settings
8. /extension/andevenmoredesigns/settings
7. /extension/moredesigns/settings
6. /extension/defaultdesigns/settings
5. /extension/complexdatatypes/settings
4. /extension/operators/settings
3. /extension/simpledatatypes/settings
2. /extension/volano_basic_settings/settings
1. /settings
Finally I'm really sorry this isn't a real world example - I just tried to catch every possible scenario. Gone catch some coffee, now...
Daniel Beyer
_________________________________
YMC AG
Kreuzlingen, Switzerland
web: www.ymc.ch
____________________________________
|