firegento / firegento-adminmonitoring

Monitor all activities in the backend and provide a history about the changes.
GNU General Public License v3.0
91 stars 23 forks source link

Fixed models with constructor parameters #39

Closed midlan closed 4 years ago

midlan commented 4 years ago

If I have some model that needs parameters:

<?php

class Vendor_Module_Model_Example extends Mage_Core_Model_Abstract
{

    protected $_myDep;

    public function __construct(array $dependencies)
    {
        parent::__construct();

        if (isset($dependencies['mydep']) && ($attributes['mydep'] instanceof MyDep)) {
            $this->_myDep = $attributes['mydep'];
        } else {
            throw new ArgumentCountError('Too few arguments to function ' . __FUNCTION__);
        }
    }

   ....
}

//using model:
Mage::getModel('vendor_module/example', array('mydep' => new MyDep));

Then calling $model = new $className; in adminmonitoring on line

src/app/code/community/FireGento/AdminMonitoring/Model/History/Data.php:65

throws exception. My fix clones the object, so dependencies are kept and there is no need to call constructor. Clears data by setting empty array before load.