« Return to Thread: Shared Models in Different Modules
Yes that does
look like it would help some but then you are calling more code that what I believe
is needed.
Why can’t the
Zend_Loader take into account modules so then you don’t have to have a helper
and such.
I want it to be
autoloaded and not have to call $this->_helper->ModuleLoader(‘News_Story’)
when ever I need the news story object.
Does that make
sense?
|
Jon Whitcraft |
|
|
Phone: (317) 492-8623 :: Fax: (317) 492-6419 |
|
From: AmirBehzad
Eslami [mailto:behzad.eslami@...]
Sent: Monday, December 03, 2007
12:33 PM
To: Xavier Vidal Piera
Cc:
Subject: Re: [fw-mvc] Shared
Models in Different Modules
In my opinion, there is a
problem with ZF's naming scheme for MVC components, regardless
of our current discussion.
Zend_Loader defines a scheme to load classes. You're encouraged to follow this
scheme
within your ZF-based application: Zend_Loader('X_Y_Z') loads X\Y\Z.php.
Why ZF itself doesn't follow this scheme to "name and store"
controllers and models?
Inconsistent naming schemes leads to confusion; something which happens all the
time
to me when I want to name classes in ZF. "It makes me and you to
Think!".
There is an upcoming component
"Zend_Controller_Action_Helper_ModelLoader" to solve
models loading problem. I think that's a patch to solve the problem.
If ZF-ians follow a standard naming scheme through their framework,
these problems won't arise at all and we won't need these patches.
Regards,
On Dec 3, 2007 8:03 PM, Xavier Vidal Piera < xavividal@...> wrote:
The only reason to make that model classes named that way is to avoid
namespace collisions, but you can name that classes as you like. The problem
will appear if someday a class named Story appears (from another package or
external lib), any attempt to use two classes with the same name will throw an
error.
On Dec 3, 2007 4:51 PM,
Xavier,
I ran into that problem too. I just
refactored the class name to be new_Models_Story which makes no sense but it
works for right now and going back later to refactor once it gets all figured
out wont be too hard as the Zend Neon Beta does a good job of finding all the
occurrences of that class.
Cheers
|
Jon Whitcraft |
|
|
Phone: (317) 492-8623 :: Fax: (317) 492-6419 |
|
From: Xavier Vidal Piera [mailto:xavividal@...]
Sent: Monday, December 03, 2007
10:17 AM
To:
Cc: Marko Korhonen; fw-mvc@...
Subject: Re: [fw-mvc] Shared
Models in Different Modules
Yes
But i remember to do that in lowercase (module names are in lowercase), so i
have all the folder structure in lower case.
At this moment, any way to organize better the model classes will be
apreciated.
On Dec 3,
2007 2:09 PM,
So if I understand you correctly, I
should be able to do this
$story = new News_Models_Story();
Where this is my directory structure:
./modules/
./news/
./models/
Story.php
Correct?
|
Jon Whitcraft |
|
|
Phone: (317) 492-8623 :: Fax: (317) 492-6419 |
|
From: Xavier Vidal Piera [mailto: xavividal@...]
Sent: Monday, December 03, 2007
7:54 AM
To: Marko Korhonen
Cc: fw-mvc@...
Subject: Re: [fw-mvc] Shared
Models in Different Modules
I'm treating model classes as framework classes using
the conventional naming to avoid namespace collisions, so all the model classes
common to all the application are stored in default/models/ and are named
Default_Models_* so they can be easily be localized. Of course, inside the
model class the "real name" is set with protected $_name.
You can have model classes in another modules and be namespaced accordingly.
The autoload function will find this classes the same way it finds the Zend
Libs and other classes.
On Dec 3,
2007 6:35 AM, Marko Korhonen <marko.korhonen@...> wrote:
Hi to all!
I made one folder to all my models, and I appended the include_path with the
path to this folder.
$models_path = APPLICATION_PATH ."My_Application/Model/";
// include $models_path to include_path somewhere
Then where ever in actions I might need some model I just make:
$model = new Page();
or something like that...
So these models are shared by all controllers & actions but not by all my
different applications.
br,
Marko
--
View this message in context: http://www.nabble.com/Shared-Models-in-Different-Modules-tf4932443s16154.html#a14124197
Sent from the Zend MVC mailing list archive at Nabble.com.
--
Xavier Vidal Piera
Enginyer Tècnic Informàtic de Gestió
Tècnic Especialista Informàtic d'equips
xavividal@...
xvidal@...
http://web.xaviervidal.net
610.68.41.78
********************
********************
This E-mail (and attachments) may contain
confidential/privileged information intended only for the named addressee(s).
If you are not an intended recipient, do not read, copy, disseminate or take
any action based on the content of this E-mail. Please notify the sender by
reply E-mail and erase this E-mail from your system. Your assistance is
appreciated. E-mail transmission may not be secure or error-free. The company
is not responsible for any loss/damage arising from any virus transmitted.
********************
********************
--
Xavier Vidal Piera
Enginyer Tècnic Informàtic de Gestió
Tècnic Especialista Informàtic d'equips
xavividal@...
xvidal@...
http://web.xaviervidal.net
610.68.41.78
--
Xavier Vidal Piera
Enginyer Tècnic Informàtic de Gestió
Tècnic Especialista Informàtic d'equips
xavividal@...
xvidal@...
http://web.xaviervidal.net
610.68.41.78
« Return to Thread: Shared Models in Different Modules
| Free embeddable forum powered by Nabble | Forum Help |