XF 2.2 How to correctly extend XF\Repository\UserUpgrade

FoxSecrets

Active member
I need to use method downgradeExpiredUpgrades() from XF\Repository\UserUpgrade in order to update some data on my add-on after user upgrade expiration, however doing that I got conflicts with other add-ons.

How can I correctly extend the class to use downgradeExpiredUpgrades() without affecting other add-ons?

Class extension:
XF\Repository\UserUpgrade --> My\Addon\XF\Repository\UserUpgrade

Class file - My\Addon\XF\Repository\UserUpgrade
Code:
<?php
namespace My\Addon\XF\Repository;

use XF\Mvc\Entity\Finder;
use XF\Mvc\Entity\Repository;

class UserUpgrade extends Repository
{
  //code

  public function downgradeExpiredUpgrades()
  {
    //code
  }

//code
}
 
Two things:

1. For class extensions you always need to use e.g extends XFCP_UserUpgrade
2. Make sure you call parent::downgradeExpiredUpgrades()
 
Back
Top Bottom