Zend_Application-AvailableResources-Modules.xml 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect2 id="zend.application.available-resources.modules">
  4. <title>Zend_Application_Resource_Modules</title>
  5. <para>
  6. <classname>Zend_Application_Resource_Modules</classname> is used to initialize
  7. your application modules. If your module has a
  8. <filename>Bootstrap.php</filename> file in its root, and it contains a class
  9. named <classname>Module_Bootstrap</classname> (where "Module" is the module name),
  10. then it will use that class to bootstrap the module.
  11. </para>
  12. <para>
  13. By default, an instance of
  14. <classname>Zend_Application_Module_Autoloader</classname> will be created for the
  15. module, using the module name and directory to initialize it.
  16. </para>
  17. <note>
  18. <title>Front Controller resource dependency</title>
  19. <para>
  20. The Modules resource has a dependency on the <link
  21. linkend="zend.application.available-resources.frontcontroller">Front
  22. Controller resource</link>. You can, of course, provide your own
  23. replacement for that resource via a custom Front Controller resource
  24. class or a class initializer method -- so long as the resource
  25. plugin class ends in "Frontcontroller" or the initializer method is
  26. named "_initFrontController" (case insensitive).
  27. </para>
  28. </note>
  29. <example id="zend.application.available-resources.modules.configExample">
  30. <title>Configuring Modules</title>
  31. <para>
  32. You can specify module-specific configuration using the module name
  33. as a prefix or sub-section in your configuration file.
  34. </para>
  35. <para>
  36. For example, let's assume that your application has a "news" module.
  37. The following are <acronym>INI</acronym> and <acronym>XML</acronym> examples showing
  38. configuration of resources in that module.
  39. </para>
  40. <programlisting language="ini"><![CDATA[
  41. [production]
  42. news.resources.db.adapter = "pdo_mysql"
  43. news.resources.db.params.host = "localhost"
  44. news.resources.db.params.username = "webuser"
  45. news.resources.db.params.password = "XXXXXXX"
  46. news.resources.db.params.dbname = "news"
  47. news.resources.layout.layout = "news"
  48. ]]></programlisting>
  49. <programlisting language="xml"><![CDATA[
  50. <?xml version="1.0"?>
  51. <config>
  52. <production>
  53. <news>
  54. <resources>
  55. <db>
  56. <adapter>pdo_mysql</adapter>
  57. <params>
  58. <host>localhost</host>
  59. <username>webuser</username>
  60. <password>XXXXXXX</password>
  61. <dbname>news</dbname>
  62. </params>
  63. <isDefaultAdapter>true</isDefaultAdapter>
  64. </db>
  65. </resources>
  66. </news>
  67. </production>
  68. </config>
  69. ]]></programlisting>
  70. </example>
  71. <example id="zend.application.available-resources.modules.retrieveBootstrapExample">
  72. <title>Retrieving a specific module bootstrap</title>
  73. <para>
  74. On occasion, you may need to retrieve the bootstrap object for a
  75. specific module -- perhaps to run discrete bootstrap methods, or to
  76. fetch the autoloader in order to configure it. This can be done
  77. using the Modules resource's <methodname>getExecutedBootstraps()</methodname>
  78. method.
  79. </para>
  80. <programlisting language="php"><![CDATA[
  81. $resource = $bootstrap->getPluginResource('modules');
  82. $moduleBootstraps = $resource->getExecutedBootstraps();
  83. $newsBootstrap = $moduleBootstraps['news'];
  84. ]]></programlisting>
  85. </example>
  86. </sect2>