Re: [fw-general] RE: Model Loading helper

2007-06-27 Thread Kevin McArthur
Seems like a lot of configuration that should be implicit with the 
common-modular-directory-structure?


- Original Message - 
From: "ArsePit" <[EMAIL PROTECTED]>

To: 
Sent: Wednesday, June 27, 2007 9:46 AM
Subject: [fw-general] RE: Model Loading helper




It sounds good to load modules as you need.
Right now for simplicity, I just created a section in config.ini for 
modules

and then added some code to my bootstrap to take that information and
automatically set the controllers and models for each module.

Currently, I do the following:
--- In config.ini ---
;;; modules ;;;
; paths are relative to the 'application' directory
modules.default.controllers.directory = "controllers"
modules.default.models.directory = "models"
modules.event.controllers.directory = "modules/event/controllers"
modules.event.models.directory = "modules/event/models"

--- In bootstrap ---
$router = $frontController->getRouter(); // returns a rewrite router by
default
$aControllers = array();
// building associative array from config for module controller paths and
adding models to the include path
foreach ($config->modules as $tmpName => $oConf) {
$aControllers[$tmpName] = $app_path . $oConf->controllers->directory;
set_include_path('.' . PATH_SEPARATOR . $app_path .
$oConf->models->directory . PATH_SEPARATOR . get_include_path());
}
$frontController->setControllerDirectory($aControllers);
$registry->set('controllers', $aControllers); // add it to the registry

--
View this message in context: 
http://www.nabble.com/Model-Loading-helper-tf3942096s16154.html#a11326850

Sent from the Zend Framework mailing list archive at Nabble.com.





[fw-general] RE: Model Loading helper

2007-06-27 Thread ArsePit

It sounds good to load modules as you need.
Right now for simplicity, I just created a section in config.ini for modules
and then added some code to my bootstrap to take that information and
automatically set the controllers and models for each module.

Currently, I do the following:
--- In config.ini ---
;;; modules ;;;
; paths are relative to the 'application' directory
modules.default.controllers.directory = "controllers"
modules.default.models.directory = "models"
modules.event.controllers.directory = "modules/event/controllers"
modules.event.models.directory = "modules/event/models"

--- In bootstrap ---
$router = $frontController->getRouter(); // returns a rewrite router by
default
$aControllers = array();
// building associative array from config for module controller paths and
adding models to the include path
foreach ($config->modules as $tmpName => $oConf) {
$aControllers[$tmpName] = $app_path . $oConf->controllers->directory;
set_include_path('.' . PATH_SEPARATOR . $app_path .
$oConf->models->directory . PATH_SEPARATOR . get_include_path());
}
$frontController->setControllerDirectory($aControllers);
$registry->set('controllers', $aControllers); // add it to the registry

-- 
View this message in context: 
http://www.nabble.com/Model-Loading-helper-tf3942096s16154.html#a11326850
Sent from the Zend Framework mailing list archive at Nabble.com.



[fw-general] RE: Model Loading helper

2007-06-18 Thread PotatoBob

Well, when you get into a modular directory structure, we don't have the
simplicity of just setting the models folder for every model into the
include_path. Then again we could do require_once('../models/MyModel.php');


Bill Karwin wrote:
> 
> Here's what I'm doing in the bootstrap (index.php) of a demo app I'm
> working on:
>  
>   require_once 'Zend/Loader.php';
>   Zend_Loader::registerAutoload();
>  
>   $appDir = dirname(dirname(__FILE__)) . '/app'; 
>   set_include_path($appDir . '/models' . PATH_SEPARATOR .
> get_include_path());
>  
> Following this, I have no problem loading models.  Isn't this simpler
> than using another helper class?  Am I missing something?
> However, I realize that in more complex apps, it may not be quite this
> simple.
>  
> Regards,
> Bill Karwin
> 
> 
> 
> 
>   From: PotatoBob [mailto:[EMAIL PROTECTED] 
>   Sent: Monday, June 18, 2007 11:47 AM
>   To: fw-general@lists.zend.com
>   Subject: [fw-general] Model Loading helper
>   
>   
> 
>   Normally models are loaded through require_once() or
> Zend_Loader::loadClass() with painfully long paths similar to
> "module/models/Model.php" or "module/models/controller/Model.php" and
> more likely "../models/controller/Model.php". After a few discussions on
> #zftalk with ralphschindler,
> SpotSec_Controller_Action_Helper_ModelLoader came to existence.
> ModelLoader does exactly what the name says, it makes loading models one
> step simpler by determining the path to the models folder so all you
> have to do is specify the model's class name. 
> 
>   Anyways I just wanted to see some feedback, as I never actually
> tested it and feel it is useless... 
> 
>   If you are using the conventional modular directory structure
> then ModelLoader is already setup and ready to go. If you are not then
> you can setup ModelLoader using __construct(); 
> 
> 
>   Usage:  $this->_helper->ModelLoader('UserModel');
> 
>   link in proposal form: ModelLoading helper
>  oader/library/Zend/Controller/Action/Helper/ModelLoader.php>  
>   
>   SpotSec   
>   
> 
> 
>   View this message in context: Model Loading helper
>  98> 
>   Sent from the Zend Framework mailing list archive
>   at Nabble.com.
>   
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Model-Loading-helper-tf3942096s16154.html#a11181906
Sent from the Zend Framework mailing list archive at Nabble.com.