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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Config\Model\Config\Structure;
use Magento\Framework\Exception\ConfigurationMismatchException;
/**
* Contains list of classes which implement ElementVisibilityInterface for
* checking of visibility of form elements on Stores > Settings > Configuration page in Admin Panel.
* @api
* @since 101.0.0
*/
class ElementVisibilityComposite implements ElementVisibilityInterface
{
/**
* List of objects which implements ElementVisibilityInterface for
* checking of visibility of form elements on Configuration page.
*
* @var ElementVisibilityInterface[]
*/
private $visibility = [];
/**
* @param ElementVisibilityInterface[] $visibility List of objects which define visibility status of form elements
* under its own conditions.
* @throws ConfigurationMismatchException It is thrown if some object from list $visibility
* implements the wrong interface.
*/
public function __construct(array $visibility = [])
{
foreach ($visibility as $name => $item) {
if (!$item instanceof ElementVisibilityInterface) {
throw new ConfigurationMismatchException(
__(
'%1: Instance of %2 is expected, got %3 instead',
$name,
ElementVisibilityInterface::class,
get_class($item)
)
);
}
}
$this->visibility = $visibility;
}
/**
* @inheritdoc
* @since 101.0.0
*/
public function isHidden($path)
{
foreach ($this->visibility as $element) {
if ($element->isHidden($path)) {
return true;
}
}
return false;
}
/**
* @inheritdoc
* @since 101.0.0
*/
public function isDisabled($path)
{
foreach ($this->visibility as $element) {
if ($element->isDisabled($path)) {
return true;
}
}
return false;
}
}