Oops.. BEFORE: was supposed to read:
<database name="propel" defaultIdMethod="native"
package="plugins.sfGuardPlugin.lib.model">
<table phpName="sfGuardUser" name="sf_guard_user"
package="plugins.sfGuardPlugin.lib.model">
~synace
-----Original Message-----
From: [email protected]
[mailto:[EMAIL PROTECTED] On Behalf Of synace
Sent: Thursday, November 09, 2006 2:49 PM
To: [email protected]
Subject: [symfony-devs] Re: (enhancement) adding custom methods to
plugin model classes during build time
PROPOSAL:
A. Remove 'package=' from tables in ALL plugin schema files.
B. Setup a 'consistent best practice' for using sfMixer to customize
plugins & plugin model classes.
When you remove 'package=' from the table definitions (BUT LEAVE IT IN
THE DATABASE TAG) schema file, the plugin schema is rebuilt (via
propel-build-model) with any linkage you've setup in your project schema
file. (YES!! YOU CAN HAVE Foreign Keys to the plugin classes!!!) Then,
all related peer methods will be built into the plugin model class file
(IN THE PLUGIN DIRECTORY), and you'll be able to call
$somePluginClass->getYourRelatedByFkClass().
+/- anyone?
To test/try this out: open any plugin, remove 'package=' from the table
tags only!! Then, add a foreign key relationship TO the plugin class
FROM your project schema and re-run: ./symfony propel-build-model.
The plugin's model files will be rebuilt in
/plugins/xxxxx/lib/model/om/* and will contain member variables for your
project classes that were linked via FK.
~synace
Example:
BEFORE:
<database name="propel" defaultIdMethod="native"
package="plugins.sfGuardPlugin.lib.model">
<table phpName="sfGuardUser" name="sf_guard_user">
AFTER:
<?xml version="1.0" encoding="utf-8"?>
<database name="propel" defaultIdMethod="native"
package="plugins.sfGuardPlugin.lib.model">
<table phpName="sfGuardUser" name="sf_guard_user">
<column name="id" type="INTEGER" size="11" required="true"
primaryKey="true" autoIncrement="true" />
<column name="username" type="VARCHAR" size="128"
required="true" />
<column name="algorithm" type="VARCHAR" size="128"
required="true" default="\asha1\a" />
<column name="salt" type="VARCHAR" size="128"
required="true" />
<column name="password" type="VARCHAR" size="128"
required="true" />
<column name="created_at" type="TIMESTAMP" required="true"
/>
<column name="last_login" type="TIMESTAMP" required="true"
/>
<column name="is_active" type="BOOLEAN" required="true"
default="1" />
<column name="is_super_admin" type="BOOLEAN"
required="true" />
<index name="username_unique">
<index-column name="username" />
</index>
</table>
AND YOUR SCHEMA FILE:
<?xml version="1.0" encoding="utf-8"?>
<database name="propel" defaultIdMethod="native">
<table name="user_profile">
<column name="id" type="INTEGER" size="11" required="true"
primaryKey="true" />
<column name="username" type="VARCHAR" size="128"
required="true" />
<column name="algorithm" type="VARCHAR" size="128"
required="true" default="\asha1\a" />
<column name="salt" type="VARCHAR" size="128"
required="true" />
<foreign-key foreignTable="sf_guard_user" name="Rel_15"
onDelete="cascade">
<reference local="id" foreign="id" />
</foreign-key>
Will produce, IN /plugins/sfGuard/lib/model/om/BasesfGuardUser.php a
getUserProfile method.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"symfony developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/symfony-devs?hl=en
-~----------~----~----~----~------~----~------~--~---