Quote from: Aalandriel at Oct 21, 2010, 12:52 PM
on a different note
The Create Classes snippet will generate classes for all tables with the defined prefix, but is there any built-in functionality to add relations between these tables, or would the schema have to be corrected afterwards? And I guess as a result there of the classes as well?
Been fiddling with it all day but can’t seem to get it working.
TBH, I haven’t had time to try it. I kind of suspect that you’d have to put in the aggregate aliases and composite aliases yourself, but at least you’d have a head start with the schema.
Look at the core/model/schema/modx.mysql.schema.xml file for examples.
Here are two examples from the modResource class:
<aggregate alias="Parent" class="modResource" local="parent" foreign="id" cardinality="one" owner="foreign" />
<aggregate alias="Children" class="modResource" local="id" foreign="parent" cardinality="many" owner="local" />
alias: How will users refer to this related object
class: What’s the class of the related object
local: local key (lkey in this object relating it to the related object)
foreign: foreign key (key in the related object relating it to this object)
cardinality: can there be more than one of these related objects that are related to this object
owner: who owns the key used in the relationship.