<![CDATA[Codecaine.co.za - Bite-size ZF: Module-specific models]]> http://www.codecaine.co.za/posts/bite-size-zf-module-specific-models If you're like me, you like to use different classes to represent the same model in different modules. The rationale is quite simple: by using different classes you're encapsulating module-specific business logic within that module. For instance, a user model in an admin module may require functions related to access control, whereas the model's counterpart in a website module might need functionality to send messages to other users.

]]>
en-us Mar 10, 2010 6:52:37 PM Mar 10, 2010 6:52:37 PM <![CDATA[Taco]]> http://www.codecaine.co.za/posts/bite-size-zf-module-specific-models/#comment-240 <?php /** * Action Helper for loading forms * * @uses Zend_Controller_Action_Helper_Abstract */ class Xendl_Controller_Action_Helper_ConfigLoader extends Zend_Controller_Action_Helper_Abstract { /** * @var Zend_Loader_PluginLoader */ public $pluginLoader; /** * Initialize plugin loader * * @return void */ public function __construct() { $this->pluginLoader = new Zend_Loader_PluginLoader(); } /** * Load a configuration file. * * @param string $name * @return Zend_Config_Xml */ public function loadConfig($name) { $module = $this->getRequest()->getModuleName(); $controller = $this->getRequest()->getControllerName(); $front = $this->getFrontController(); $default = $front->getDispatcher() ->getDefaultModule(); if (empty($module)) { $module = $default; } $moduleDirectory = $front->getControllerDirectory($module); $configDirectory = dirname($moduleDirectory) . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . $controller . DIRECTORY_SEPARATOR; return new Zend_Config_Xml($configDirectory . $name . '.xml'); } /** * Call helper as broker method * * @param string $name * @return Zend_Config_Xml */ public function direct($name) { return $this->loadConfig($name); } } ]]> Aug 6, 2008 6:21:23 PM <![CDATA[Neil Garb]]> http://www.codecaine.co.za/posts/bite-size-zf-module-specific-models/#comment-230 Jul 23, 2008 7:06:07 AM <![CDATA[AmirBehzad Eslami]]> http://www.codecaine.co.za/posts/bite-size-zf-module-specific-models/#comment-229 Jul 23, 2008 1:29:54 AM <![CDATA[AmirBehzad Eslami]]> http://www.codecaine.co.za/posts/bite-size-zf-module-specific-models/#comment-228 Jul 23, 2008 1:27:15 AM <![CDATA[Neil Garb]]> http://www.codecaine.co.za/posts/bite-size-zf-module-specific-models/#comment-227 Jul 20, 2008 11:19:49 AM <![CDATA[alan]]> http://www.codecaine.co.za/posts/bite-size-zf-module-specific-models/#comment-226 Jul 20, 2008 11:17:04 AM <![CDATA[alan]]> http://www.codecaine.co.za/posts/bite-size-zf-module-specific-models/#comment-225 Jul 20, 2008 11:10:26 AM <![CDATA[Neil Garb]]> http://www.codecaine.co.za/posts/bite-size-zf-module-specific-models/#comment-224 Jul 20, 2008 10:49:24 AM <![CDATA[LBO]]> http://www.codecaine.co.za/posts/bite-size-zf-module-specific-models/#comment-223 loadModel($name, $module = null); read this: http://blog.mikeseth.com/index.php?/archives/4-ActiveRecord-sucks,-but-Kore-Nordmann-is-wrong.html ]]> Jul 20, 2008 10:41:26 AM <![CDATA[Neil Garb]]> http://www.codecaine.co.za/posts/bite-size-zf-module-specific-models/#comment-222 Jul 20, 2008 10:28:48 AM