-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathMiscScriptArraySerialized.php
58 lines (49 loc) · 1.36 KB
/
MiscScriptArraySerialized.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
/**
* Copyright © MagePal LLC. All rights reserved.
* See COPYING.txt for license details.
* https://www.magepal.com | [email protected]
*/
namespace MagePal\CheckoutSuccessMiscScript\Model\Config\Backend\Serialized;
use Magento\Config\Model\Config\Backend\Serialized\ArraySerialized;
class MiscScriptArraySerialized extends ArraySerialized
{
/**
* @inheritDoc
*/
public function afterLoad()
{
parent::afterLoad();
$values = $this->getValue();
if (is_array($values)) {
foreach ($values as &$value) {
if (!array_key_exists('is_enabled', $value)) {
$value['is_enabled'] = '';
}
}
}
$this->setValue($values);
return $this;
}
/**
* @return $this
*/
public function beforeSave()
{
$values = $this->getValue();
if (is_array($values)) {
foreach ($values as &$value) {
if (is_array($value)) {
if (!array_key_exists('is_enabled', $value)) {
$value['is_enabled'] = '';
} else {
$value['is_enabled'] = 'checked';
}
}
}
$this->setValue($values);
}
parent::beforeSave();
return $this;
}
}