Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
module-rule
Model
ConditionFactory.php
Go to the documentation of this file.
1
<?php
6
namespace
Magento\Rule\Model
;
7
8
use
Magento\Framework\ObjectManagerInterface
;
9
use
Magento\Rule\Model\Condition\ConditionInterface
;
10
11
class
ConditionFactory
12
{
16
private
$objectManager;
17
23
private
$conditionModels = [];
24
28
public
function
__construct
(
ObjectManagerInterface
$objectManager)
29
{
30
$this->objectManager =
$objectManager
;
31
}
32
46
public
function
create
(
$type
)
47
{
48
if
(!array_key_exists(
$type
, $this->conditionModels)) {
49
if
(!
class_exists
(
$type
)) {
50
throw
new \InvalidArgumentException(
'Class does not exist'
);
51
}
52
if
(!in_array(ConditionInterface::class, class_implements(
$type
))) {
53
throw
new \InvalidArgumentException(
'Class does not implement condition interface'
);
54
}
55
$this->conditionModels[
$type
] = $this->objectManager->create(
$type
);
56
}
57
58
return
clone $this->conditionModels[
$type
];
59
}
60
}
$objectManager
$objectManager
Definition:
bootstrap.php:17
Magento\Rule\Model
Magento\Rule\Model\ConditionFactory\create
create($type)
Definition:
ConditionFactory.php:46
Magento\Framework\ObjectManagerInterface
Definition:
ObjectManagerInterface.php:12
Magento\Rule\Model\ConditionFactory
Definition:
ConditionFactory.php:11
$type
$type
Definition:
item.phtml:13
Magento\Rule\Model\ConditionFactory\__construct
__construct(ObjectManagerInterface $objectManager)
Definition:
ConditionFactory.php:28
Magento\Framework\Code\Generator\class_exists
class_exists($className)
Definition:
DefinedClassesTest.php:15
Magento\Rule\Model\Condition\ConditionInterface
Definition:
ConditionInterface.php:12