Question

I am making a custom module in \custom\modules directory and i want to override Companies.class.php (companies model from activecollab\3.3.7\modules\system\models\companies directory). I want to use a function findForObjectsList() but when I use useModel() function of Angie it loads the companies model for all of my site from my custom Module. while I just want to override it in my module not everywhere.

My init.php is like this:

/**
   * company List module initialisation file
   */

  const COMPANYLIST_MODULE = 'company_list';
  const COMPANYLIST_MODULE_PATH = __DIR__;

  AngieApplication::useModel(array(
    'companies',
  ), COMPANYLIST_MODULE);

i have used this too:

AngieApplication::setForAutoload('Comapny List', CALENDAR_MODULE_PATH . '/models/companies/ListCompanies.class.php');

But in vain.

Was it helpful?

Solution

You can't use AngieApplication::useModel() or AngieApplication::setForAutoload() to override built in classes, but to replace them. In order to "override", you would need to fully replace the existing classes and alter the methods that you need.

Approach that you decided to go with is not recommended. I think you should move back a bit and we should start discussing this from the perspective of a problem that you are trying to solve, instead of implementation that you had in mind (I think that you picked the wrong approach, but can't be 100% sure until I hear what exactly are you trying to achieve).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top