Hi,
First of all, the Xyster library looks very promising and I already use it with success, thnx.
My question,
How should I handle the loading of models with respect to a module layout. By example: I have a structure like this:
application/news/models/Item.php
application/news/models/ItemSet.php
application/news/models/ItemMapper.php
I add in the controller the include path 'application/news/models'. Loading of Item.php is done by require_once 'Item.php'. I run in problems cause the Xyster/Orm/Loader.php can't handle the loading of the Mapper class.
Is there a workaround or am I missing some alreading existing functionality?
In the example you gave, all
Submitted by Double Compile on Mon, 02/18/2008 - 19:29
In the example you gave, all that should be necessary for you to use the ORM classes is to pass the full path for application/news/models to
Xyster_Orm_Loader::addPath().After you add the path, when you use the methods on the
Xyster_Ormclass,Xyster_Orm_Loaderwill look in all of the paths you have provided for classes to instantiate.Let's say you have "application/news/models", "application/foobar/modules", and "application/example/modules". Then let's say you pass all three of these paths to
Xyster_Orm_Loader::addPath(). Next, you callXyster_Orm::getInstance()->get('Item', 1). The ORM layer will go through news/modules, foobar/modules, and example/modules looking for 'Item.php'.Did this answer your question?
I told you not the whole
Submitted by hanleenders on Tue, 02/19/2008 - 03:29
I told you not the whole truth ;-)
My layout is
/application/models/ /application/modules/news/controllers/ /application/modules/news/models/ /application/modules/foo/models/ etc.
My models are named as file like Item.php but to avoid collision the class name is News_Item. With setting my include path dynamically at module level I can use require_once 'Item.php'. But with this layout I can't use the default Zend_Loader/Xyster_Orm_Loader functionality.
Okay, I see now. Well, under
Submitted by Double Compile on Wed, 02/20/2008 - 14:49
Okay, I see now.
Well, under a custom naming scheme like that, and if you're using
require_onceto include all the classes, you shouldn't need to use Xyster_Orm_Loader anyway.If I were to make your domain model from scratch, I'd try to avoid generic names like "Item" so that your entities can all sit together in one directory.
Is there any reason you can't name the file "News_Item.php", "News_ItemSet.php", etc.? Then you could use the Loader.