0
$newMembership = JTable::getInstance('MembershipSold', 'Table');
$newMembership->load($this->membership_sold_id);
$this->membership_sold = $newMembership;
$dispatcher->trigger('onAfterMembershipChanged', array($newMembership));
return parent::store();/* whats the use of above code */
Craig
  • 9,335
  • 2
  • 34
  • 38
vivek321
  • 169
  • 3
  • 18

1 Answers1

2
  1. $newMembership = JTable::getInstance('MembershipSold', 'Table');
    This line is getting is a static method to get an instance of a JTable class, specifically one called "MembershipSold". You can read about JTable (Joomla's abstract table class) here, the document is a little out of date but you can read the relevant JTable class in your Joomla installation at /libraries/joomla/database/table.php

  2. $newMembership->load($this->membership_sold_id);
    This line uses the membership_sold_id to load a record from the table in the database.

  3. $this->membership_sold = $newMembership;
    This line inserts the JTable object (now holding the record loaded from the table) into the $this.

  4. $dispatcher->trigger('onAfterMembershipChanged', array($newMembership));
    This line appears to be triggering an event and passing in the $newMembership object (Joomla supports a basic event system for plugins etc to act on), you can read more about it in this document "Supporting plugins in your component"

  5. return parent::store();
    This line is calling the current objects parent's store() method. See PHP:parent

Craig
  • 9,335
  • 2
  • 34
  • 38