2009年8月23日星期日

Re: [fw-mvc] Calling Models in Default Module

Brenton Alker-3 wrote:
>
> Scott Sowers wrote:
>> Hi,
>>
>> How would I call models from the default module and how do I name the
>> model classes for the default module (I'm using ZF 1.8)? I understand
>> how to do this for non-default modules, but I can't figure it out for
>> default modules. I have the following directory structure:
>>
>> application/
>> modules/
>> default/
>> models/
>> controllers/
>> views/
>> admin/
>> models/
>> controllers/
>> views/
>
> Firstly, the default module doesn't sit under the modules directory with
> the other modules. It is directly in the application directory (as
> created by Zend_Tool and specified in the docs)
>
> The models of the default module won't be prefixed by default, so they
> will be in application/models/ and be called Model_*. However, I usually
> namespace them with App_ (or the actual name of the app if there is one)
> by adding:
>
> protected function _initResourceAutoloader()
> {
> new Zend_Application_Module_Autoloader(array(
> 'basePath' => APPLICATION_PATH,
> 'namespace' => 'App',
> ));
> }
>
> to the default Bootstrap (application/Bootstrap.php)
>
> - --
>
> Brenton Alker
> PHP Developer - Brisbane, Australia
>
> http://blog.tekerson.com/
> http://twitter.com/tekerson
>

The 'default' module is stored under the modules directory, it shows it
here: http://framework.zend.com/manual/en/zend.controller.modular.html.

If you have your application directory added to the include path and
autoloading enabled, you should be able to call the models
Default_Model_SomeModel.

--
View this message in context: http://www.nabble.com/Calling-Models-in-Default-Module-tp25098644p25100853.html
Sent from the Zend MVC mailing list archive at Nabble.com.

没有评论: