@@ -32,26 +32,6 @@ class CachedMetadata implements MetadataInterface
32
32
*/
33
33
protected $ metadata ;
34
34
35
- /**
36
- * @var array
37
- */
38
- protected $ attributeMetadataCache = [];
39
-
40
- /**
41
- * @var array
42
- */
43
- protected $ attributesCache = [];
44
-
45
- /**
46
- * @var \Magento\Customer\Api\Data\AttributeMetadataInterface[]
47
- */
48
- protected $ allAttributeMetadataCache = null ;
49
-
50
- /**
51
- * @var \Magento\Customer\Api\Data\AttributeMetadataInterface[]
52
- */
53
- protected $ customAttributesMetadataCache = null ;
54
-
55
35
/**
56
36
* Initialize dependencies.
57
37
*
@@ -67,69 +47,55 @@ public function __construct(MetadataInterface $metadata)
67
47
*/
68
48
public function getAttributes ($ formCode )
69
49
{
70
- $ key = $ formCode ;
71
- if (isset ( $ this -> attributesCache [ $ key ]) ) {
72
- return $ this -> attributesCache [ $ key ] ;
50
+ $ attributes = $ this -> getCache ()-> getAttributes ( $ this -> entityType , $ formCode) ;
51
+ if ($ attributes !== false ) {
52
+ return $ attributes ;
73
53
}
74
-
75
- $ value = $ this ->metadata ->getAttributes ($ formCode );
76
- $ this ->attributesCache [$ key ] = $ value ;
77
-
78
- return $ value ;
54
+ $ attributes = $ this ->metadata ->getAttributes ($ formCode );
55
+ $ this ->getCache ()->saveAttributes ($ this ->entityType , $ attributes , $ formCode );
56
+ return $ attributes ;
79
57
}
80
58
81
59
/**
82
60
* {@inheritdoc}
83
61
*/
84
62
public function getAttributeMetadata ($ attributeCode )
85
63
{
86
- $ key = $ attributeCode ;
87
- if (isset ( $ this -> attributeMetadataCache [ $ key ]) ) {
88
- return $ this -> attributeMetadataCache [ $ key ] ;
64
+ $ metadata = $ this -> getCache ()-> getAttributes ( $ this -> entityType , $ attributeCode) ;
65
+ if ($ metadata ) {
66
+ return $ metadata ;
89
67
}
90
-
91
- $ value = $ this ->metadata ->getAttributeMetadata ($ attributeCode );
92
- $ this ->attributeMetadataCache [$ key ] = $ value ;
93
-
94
- return $ value ;
68
+ $ metadata = $ this ->metadata ->getAttributeMetadata ($ attributeCode );
69
+ $ this ->getCache ()->saveAttributes ($ this ->entityType , $ metadata , $ attributeCode );
70
+ return $ metadata ;
95
71
}
96
72
97
73
/**
98
74
* {@inheritdoc}
99
75
*/
100
76
public function getAllAttributesMetadata ()
101
77
{
102
- if ($ this ->allAttributeMetadataCache !== null ) {
103
- return $ this ->allAttributeMetadataCache ;
104
- }
105
78
$ attributes = $ this ->getCache ()->getAttributes ($ this ->entityType , 'all ' );
106
- if ($ attributes ) {
107
- $ this ->allAttributeMetadataCache = $ attributes ;
108
- return $ this ->allAttributeMetadataCache ;
79
+ if ($ attributes !== false ) {
80
+ return $ attributes ;
109
81
}
110
-
111
-
112
- $ this ->allAttributeMetadataCache = $ this ->metadata ->getAllAttributesMetadata ();
113
- $ this ->getCache ()->saveAttributes ($ this ->entityType , $ this ->allAttributeMetadataCache , 'all ' );
114
- return $ this ->allAttributeMetadataCache ;
82
+ $ attributes = $ this ->metadata ->getCustomAttributesMetadata ();
83
+ $ this ->getCache ()->saveAttributes ($ this ->entityType , $ attributes , 'all ' );
84
+ return $ attributes ;
115
85
}
116
86
117
87
/**
118
88
* {@inheritdoc}
119
89
*/
120
90
public function getCustomAttributesMetadata ($ dataObjectClassName = null )
121
91
{
122
- if ($ this ->customAttributesMetadataCache !== null ) {
123
- return $ this ->customAttributesMetadataCache ;
124
- }
125
92
$ attributes = $ this ->getCache ()->getAttributes ($ this ->entityType , 'custom ' );
126
- if ($ attributes ) {
127
- $ this ->customAttributesMetadataCache = $ attributes ;
128
- return $ this ->customAttributesMetadataCache ;
93
+ if ($ attributes !== false ) {
94
+ return $ attributes ;
129
95
}
130
- $ this -> customAttributesMetadataCache = $ this ->metadata ->getCustomAttributesMetadata ();
96
+ $ attributes = $ this ->metadata ->getCustomAttributesMetadata ();
131
97
$ this ->getCache ()->saveAttributes ($ this ->entityType , $ attributes , 'custom ' );
132
- return $ this -> customAttributesMetadataCache ;
98
+ return $ attributes ;
133
99
}
134
100
135
101
/**
0 commit comments