I have this snippet:

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

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


Use code like

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

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.