objectManager = $objectManager; } /** * Create new object for each requested model. * If model is requested first time, store it at array. * It's made by performance reasons to avoid initialization of same models each time when rules are being processed. * * @param string $type * * @return \Magento\Rule\Model\Condition\ConditionInterface * * @throws \LogicException * @throws \BadMethodCallException * @throws \InvalidArgumentException */ public function create($type) { if (!array_key_exists($type, $this->conditionModels)) { if (!class_exists($type)) { throw new \InvalidArgumentException('Class does not exist'); } if (!in_array(ConditionInterface::class, class_implements($type))) { throw new \InvalidArgumentException('Class does not implement condition interface'); } $this->conditionModels[$type] = $this->objectManager->create($type); } return clone $this->conditionModels[$type]; } }