5

I have this snippet:

// In __constructor arguments:
\Magento\Framework\FlagFactory $flagFactory
...
// This is not called in __constructor:
$flag = $this->flagFactory->create(['flag_code' => 'something']);
var_dump($flag->getFlagCode());

It displays null. I var dumped into Magento\Framework\Flag::_construct() this var_dump($this->getData('flag_code')); exit; and still null.

Anyone has an ideea how to set a parameter in $data array of the create() function ? I'm in developer mode. The object manager factory would be Magento\Framework\ObjectManager\Factory\Dynamic::create

1 Answer 1

10

Use code like

$this->flagFactory->create(['data' => ['flag_code' => 'something']]); 
0

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.