CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • How to manage new entities related to contacts from an extension?
Pages: [1]

Author Topic: How to manage new entities related to contacts from an extension?  (Read 1971 times)

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
How to manage new entities related to contacts from an extension?
April 25, 2013, 11:37:41 am
Hi,

On the sepa extension, we have two new entities (table/dao/api).

One of them is the mandate, that is linked to the contact, but also to a recurring contrib or a membership.

How to be sure this entity is properly updated too when a contact is deleted or merged?

Same question about ContributionRecur or Membership

As the mandate can be linked to a contribution, a recurring contribution or a membership already, I wanted to store this relationship a couple entity_id +entity_type so the sql level FK won't work.

But might be convinced to have several fields contributionrecur & contribution & membership

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: How to manage new entities related to contacts from an extension?
April 25, 2013, 12:03:46 pm
I started a wiki page on this topic but haven't implemented anything. Any ideas/reactions/alternatives/additions?

http://wiki.civicrm.org/confluence/display/CRM/CiviCRM+Database+Layer+for+Extensions

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: How to manage new entities related to contacts from an extension?
April 25, 2013, 12:25:55 pm
Hi,

I've followed your suggested path 1, but cruder:

xml in the extension, symlink to civicrm, genGode within civicrm and symlink back the dao. The sql is copied by hand.

It isn't pretty but wasn't that much of a pain either. We'll see when we need to modify more often the schema. As an aside, found convenient to have the DAO in git, makes it easier to see I haven't copied back the sql.

https://github.com/Project60/sepa_dd

I don't have any opinion on doctrine, but I'm ready to bet I'll like it better than pear db_object.

IMO the tricky part will be to modify the BAO to "oo properly" inherit from the DAO and override the CRUD methods instead of creating static separate ones.

I'll keep your wiki in mind and come back to you once I've dug more into my extension.

To answer my own question, I'm guessing with hooks on merge, post and delete, I should be able to keep the new entity type in sync with the core ones.

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • How to manage new entities related to contacts from an extension?

This forum was archived on 2017-11-26.