How To Extend GalleryEntity

alexisb
alexisb's picture

Joined: 2005-11-24
Posts: 56
Posted: Mon, 2006-01-23 02:33

Hi, I have some doubts about creating a new GalleryEntity, I've reviewed the code of comment module for example and I see:

class GalleryComment_core extends GalleryChildEntity

Ok, that's easy, we are creating a new entity so we have to extend GalleryChildEntity (which itself extends GalleryEntity).

But I don't understand why you are using GalleryComment_core instead of just using GalleryComment?, something similar occurs with other modules and even the "original" GalleryEntity and GalleryChildEntity.

Later in the code, continuing with the comment module example, actually at the end of GalleryComment.class, I see:

include(dirname(__FILE__) . '/interfaces/GalleryComment.inc');

This file, GalleryComment.inc, is the one containing the "real" class declaration:

class GalleryComment extends GalleryComment_core

Ok, I'm getting a little lost but I guess you have a very good reason for doing this, creating first a class "Something_core" and then extend it to create the class
"Something".

In GalleryComment.inc I also read:

 * Interface class for the GalleryComment class.
 * (Class schema version: 1.0)
 *
 * This file is automatically generated from XML embedded in the
 * class, combined with the ClassCode.xsl file.  You should not modify
 * it by hand, as your changes will be lost next time this file is
 * rebuilt.  If you want to add more getters/setters, you should add
 * them in the core class.  If you want to change the format of this
 * file, then you should edit the XSL template.

Here I have to admit I'm totally confused :) , what XML embedded in the class are you referring to?, where is the ClassCode.xsl file and is that the XSL template?

I understant the suggestion of modifying the core class, I guess it's class GalleryComment_core right?, but what if I want to create my own entity class?, do I have to follow the same process?, MyEntity_core first and then extend to MyEntity? How should I use the XML you mention to do it right?

I hope you can give me some urls with more info about this or some ideas to get it clearer.

Thanks a lot.

Alexis Bellido - Ventanazul web solutions

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2006-01-23 02:52

1. Gallery has changed since G 2.0 (2.0.2). in G2.1, there's no modules/*/classes/interfaces/ folder anymore. there's no GalleryEntity_core / GalleryComment_core, ... class anymore. there's now only a GalleryEntity, GalleryComment, ... class.

2. when developing stuff right now, you should develop against G2.1 (current nightly snapshots / cvs) and not against G2.0.
therefore i won't explain the _core stuff. basically, the _core classes were all auto-generated code, the non _core classes were written and maintained by us.

 
alexisb
alexisb's picture

Joined: 2005-11-24
Posts: 56
Posted: Mon, 2006-01-23 03:11

Hi, it's good to know I don't have to mess around with the GalleryEntity_core issue :)

I'm already playing with 2.1 CVS, SF is down so I got a nightly snapshots from Jesse Mullan's page.

Now I'm trying to get my code updated to work with 2.1.

Thanks!

Alexis Bellido - Ventanazul web solutions