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
framework
Reflection
AttributeTypeResolver.php
Go to the documentation of this file.
1
<?php
7
namespace
Magento\Framework\Reflection
;
8
9
use
Magento\Framework\Api\AttributeTypeResolverInterface
;
10
use
Magento\Framework\Api\ExtensionAttribute\Config
;
11
12
class
AttributeTypeResolver
implements
AttributeTypeResolverInterface
13
{
17
protected
$config
;
18
22
protected
$typeProcessor
;
23
28
public
function
__construct
(
TypeProcessor
$typeProcessor
,
Config
$config
)
29
{
30
$this->config =
$config
;
31
$this->typeProcessor =
$typeProcessor
;
32
}
33
37
public
function
resolveObjectType
(
$attributeCode
,
$value
, $context)
38
{
39
if
(!is_object(
$value
)) {
40
throw
new \InvalidArgumentException(
'Provided value is not object type'
);
41
}
42
$data
= $this->config->get();
43
$context = trim($context,
'\\'
);
44
$config
= isset(
$data
[$context]) ?
$data
[$context] : [];
45
$output
= get_class(
$value
);
46
if
(isset(
$config
[
$attributeCode
])) {
47
$type
=
$config
[
$attributeCode
][
'type'
];
48
$output
= $this->typeProcessor->getArrayItemType(
$type
);
49
if
(!(
class_exists
(
$output
) || interface_exists(
$output
))) {
50
throw
new \LogicException(
51
sprintf(
52
'The "%s" class doesn\'t exist and the namespace must be specified. Verify and try again.'
,
53
$type
54
)
55
);
56
}
57
}
58
return
$output
;
59
}
60
}
Magento\Framework\Api\ExtensionAttribute\Config
Definition:
Config.php:15
Magento\Framework\Reflection\AttributeTypeResolver\resolveObjectType
resolveObjectType($attributeCode, $value, $context)
Definition:
AttributeTypeResolver.php:37
Magento\Framework\Reflection
Definition:
AttributeTypeResolver.php:7
Magento\Framework\Reflection\AttributeTypeResolver\$config
$config
Definition:
AttributeTypeResolver.php:17
Magento\Framework\Reflection\AttributeTypeResolver
Definition:
AttributeTypeResolver.php:12
Magento\Framework\Reflection\TypeProcessor
Definition:
TypeProcessor.php:24
Magento\Framework\Api\ExtensionAttribute\Config
Definition:
Converter.php:6
Magento\Framework\Api\AttributeTypeResolverInterface
Definition:
AttributeTypeResolverInterface.php:13
$type
$type
Definition:
item.phtml:13
Magento\Framework\Reflection\AttributeTypeResolver\__construct
__construct(TypeProcessor $typeProcessor, Config $config)
Definition:
AttributeTypeResolver.php:28
$data
$data
Definition:
attribute_set_with_image_attribute.php:16
$value
$value
Definition:
gender.phtml:16
Magento\Framework\Reflection\AttributeTypeResolver\$typeProcessor
$typeProcessor
Definition:
AttributeTypeResolver.php:22
$attributeCode
$attributeCode
Definition:
extend.phtml:12
$output
$output
Definition:
classmap_generator.php:100
Magento\Framework\Code\Generator\class_exists
class_exists($className)
Definition:
DefinedClassesTest.php:15