2

I have a class

$class = new Abc\Cde\Efg('variable');

how can i implement this using object manager

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$class = $objectManager->create(Abc\Cde\Efg);

The variable value is required. Right now i have only one option to use new. but i dont want to use new keyword in magento2

1 Answer 1

0

Try following way:


$class = $objectManager->create('Abc\Cde\Efg', ['Variable']);
1
  • not working, it is still throwing error. Exception #0 (BadMethodCallException): Missing required argument Sep 22, 2018 at 16:39

Your Answer

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

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