0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.