Okay.. A little fun reading on propel's site :)

I can override a plugin class with baseClass and inheritance. But it's
still a separate class, and all my references to it would have to change
as well as the internal plugin references.. (not likely).

  <table name="member" baseClass="M2Member" basePeer="M2MemberPeer">
    <column name="id" type="INTEGER" primaryKey="true" required="true"
autoIncrement="true">
      <inheritance key="id" class="m2_member" extends="M2Member" />
    </column>
  </table>


Also, by not having package="xxxxxxxxx" on my plugin schema.xmls, my
plugins built WITH the FKs that I was trying to achive, but I'm still
not able to add a custom method to the plugin model. I would imagine
that not having the package definition on the table is a 'bad practice'
though.

As far as I understand, the foreginKey restraint is per-package. So
that's why you "shouldn't" be able to setup a FK from your project model
to a plugin model.

Ideas? Is this a propel limitation or a plugin system limitation?

~synace


-----Original Message-----
From: [email protected]
[mailto:[EMAIL PROTECTED] On Behalf Of synace
Sent: Thursday, November 09, 2006 1:17 AM
To: [email protected]
Subject: [symfony-devs] (enhancement) adding custom methods to plugin
model classes during build time



How does one add a custom method to a plugin model class now? As far as
I know, there's no way to.


I propose allowing a project to define a set of code that can be
included into the model during build time.

---
example: (albeit a bad one, because technically this mod can be
performed w/ a static method outside the model file that doesn't require
'private' access to $this)..

sfGuardUser has a field: last_login.

And I want to add a method, sfGuardUser->getTimeSinceLastLogin()
---

I propose that you can define code, such as:

public function getTimeSinceLastLogin()
{
        return time() - $this->getLastLogin();
}

Now, during build, this method would be written into the base model
file.
---

I came across this need when I realised that if I link my tables to a
plugin table via a FK relationship, the plugin's base model files are
updated to include associations with my project. Thus allowing me to do
things like joins against my project-specific tables.

I have a dilema in that I'm reusing a plugin for many sites, but it'd be
very easy to customize if I could add methods (with private scope) that
I could do different things with, such as performing customized logic on
some newly linked tables (from my project).


Thoughts... Alternatives... Best Practices? Or am I completely wrong
here?



Ooh, side note, I notice that I don't have package="" on my table
definitions in my plugin directories, only my database definition. Dunno
if this is a side effect or whatever. I'm going to give that a shot and
see what else I can do.

~synace







--~--~---------~--~----~------------~-------~--~----~
 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to