@@ -43,7 +43,7 @@ abstract class AbstractEntity extends AbstractResource implements EntityInterfac
43
43
protected $ attributeLoader ;
44
44
45
45
/**
46
- * Connection name
46
+ * The connection name.
47
47
*
48
48
* @var string
49
49
*/
@@ -226,11 +226,13 @@ abstract class AbstractEntity extends AbstractResource implements EntityInterfac
226
226
* @param Context $context
227
227
* @param array $data
228
228
* @param UniqueValidationInterface|null $uniqueValidator
229
+ * @param AttributeLoaderInterface|null $attributeLoader
229
230
*/
230
231
public function __construct (
231
232
Context $ context ,
232
233
$ data = [],
233
- UniqueValidationInterface $ uniqueValidator = null
234
+ UniqueValidationInterface $ uniqueValidator = null ,
235
+ AttributeLoaderInterface $ attributeLoader = null
234
236
) {
235
237
$ this ->_eavConfig = $ context ->getEavConfig ();
236
238
$ this ->_resource = $ context ->getResource ();
@@ -240,8 +242,10 @@ public function __construct(
240
242
$ this ->_universalFactory = $ context ->getUniversalFactory ();
241
243
$ this ->transactionManager = $ context ->getTransactionManager ();
242
244
$ this ->objectRelationProcessor = $ context ->getObjectRelationProcessor ();
243
- $ this ->uniqueValidator = $ uniqueValidator ?:
244
- ObjectManager::getInstance ()->get (UniqueValidationInterface::class);
245
+ $ this ->uniqueValidator = $ uniqueValidator
246
+ ?: ObjectManager::getInstance ()->get (UniqueValidationInterface::class);
247
+ $ this ->attributeLoader = $ attributeLoader
248
+ ?: ObjectManager::getInstance ()->get (AttributeLoaderInterface::class);
245
249
parent ::__construct ();
246
250
$ properties = get_object_vars ($ this );
247
251
foreach ($ data as $ key => $ value ) {
@@ -547,7 +551,7 @@ public function isPartialSave($flag = null)
547
551
*/
548
552
public function loadAllAttributes ($ object = null )
549
553
{
550
- return $ this ->getAttributeLoader () ->loadAllAttributes ($ this , $ object );
554
+ return $ this ->attributeLoader ->loadAllAttributes ($ this , $ object );
551
555
}
552
556
553
557
/**
@@ -677,7 +681,7 @@ public function walkAttributes($partMethod, array $args = [], $collectExceptionM
677
681
678
682
try {
679
683
// phpcs:disable Magento2.Functions.DiscouragedFunction
680
- $ results [$ attrCode ] = call_user_func_array ([$ instance , $ method ], $ args );
684
+ $ results [$ attrCode ] = call_user_func_array ([$ instance , $ method ], array_values ( $ args) );
681
685
} catch (\Magento \Eav \Model \Entity \Attribute \Exception $ e ) {
682
686
if ($ collectExceptionMessages ) {
683
687
$ results [$ attrCode ] = $ e ->getMessage ();
@@ -1928,9 +1932,6 @@ protected function _isAttributeValueEmpty(AbstractAttribute $attribute, $value)
1928
1932
*/
1929
1933
protected function getAttributeLoader ()
1930
1934
{
1931
- if ($ this ->attributeLoader === null ) {
1932
- $ this ->attributeLoader = ObjectManager::getInstance ()->get (AttributeLoaderInterface::class);
1933
- }
1934
1935
return $ this ->attributeLoader ;
1935
1936
}
1936
1937
0 commit comments