Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed models with constructor parameters #39

Merged
merged 1 commit into from
Jun 15, 2020
Merged

Fixed models with constructor parameters #39

merged 1 commit into from
Jun 15, 2020

Conversation

midlan
Copy link
Contributor

@midlan midlan commented Jun 3, 2020

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.

@Schrank Schrank merged commit 7d41def into firegento:develop Jun 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants