4

I used default library of soap. I created a object using new keyword:

new \SoapVar(
            $this->merchantId,
            XSD_STRING,
            null,
            $nameSpace,
            null,
            $nameSpace
        );

but in magento2 Direct object instantiation is discouraged. So how can I get the object of new \SoapVar without calling it directly.

1 Answer 1

1

Create/use an interface and map it in di.xml so you can use it as dependency injection? You might have to write a factory for it as well.

But Magento discourages instantiation of Magento objects if I'm not mistaking. 3rd party libraries don't apply to these guidelines.

Correct me if I'm wrong

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.