Instanciate Class on Magento 2 and pass Array

by lucasvm1980   Last Updated October 09, 2019 18:09 PM

Im building a custom module, this one is using an external lib, everything looks like its working, anyway now i need to instanciate the class with something like this php:

$myClass = new Class(array('NUMBER' => 20111111112));

And then:

$myClass ->getClient->CreateClient($data);

So, doing this i will get the info of the recent client created to the external lib, so, i have done this:

I have created and added the library into the module and now instanciate using this way:

     * @var myClass 
    protected $myClass ;

    public function __construct(\Magento\Backend\App\Action\Context $context, 
    \MyClass\CreateClient\lib\CreateClient $myClass 
       $this->myClass = $myClass ;
       parent::__construct($context, $myClass );

Is this the correct way to create and instanciate classes in Magento 2?, Im getting some issues using this method

Fatal error: Uncaught Error: Call to a member function isLoggedIn() on null in

Tags : magento2

Related Questions