5
5
*/
6
6
namespace Magento \Framework \View \Layout ;
7
7
8
+ use Magento \Framework \App \ObjectManager ;
9
+ use Magento \Framework \App \State ;
8
10
use Magento \Framework \View \Layout \Condition \ConditionFactory ;
11
+ use Psr \Log \LoggerInterface ;
9
12
10
13
/**
11
14
* Pool of generators for structural elements
12
15
* @api
16
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
13
17
*/
14
18
class GeneratorPool
15
19
{
@@ -24,31 +28,39 @@ class GeneratorPool
24
28
protected $ generators = [];
25
29
26
30
/**
27
- * @var \Psr\Log\ LoggerInterface
31
+ * @var LoggerInterface
28
32
*/
29
33
protected $ logger ;
30
34
31
35
/**
32
- * @var \Magento\Framework\View\Layout\Condition\ ConditionFactory
36
+ * @var ConditionFactory
33
37
*/
34
38
private $ conditionFactory ;
35
39
40
+ /**
41
+ * @var State
42
+ */
43
+ private $ state ;
44
+
36
45
/**
37
46
* @param ScheduledStructure\Helper $helper
38
47
* @param ConditionFactory $conditionFactory
39
- * @param \Psr\Log\ LoggerInterface $logger
48
+ * @param LoggerInterface $logger
40
49
* @param array|null $generators
50
+ * @param State|null $state
41
51
*/
42
52
public function __construct (
43
53
ScheduledStructure \Helper $ helper ,
44
54
ConditionFactory $ conditionFactory ,
45
- \Psr \Log \LoggerInterface $ logger ,
46
- array $ generators = null
55
+ LoggerInterface $ logger ,
56
+ array $ generators = null ,
57
+ ?State $ state = null
47
58
) {
48
59
$ this ->helper = $ helper ;
49
60
$ this ->conditionFactory = $ conditionFactory ;
50
61
$ this ->logger = $ logger ;
51
62
$ this ->addGenerators ($ generators );
63
+ $ this ->state = $ state ?? ObjectManager::getInstance ()->get (State::class);
52
64
}
53
65
54
66
/**
@@ -226,7 +238,9 @@ protected function moveElementInStructure(
226
238
$ structure ->setAsChild ($ element , $ destination , $ alias );
227
239
$ structure ->reorderChildElement ($ destination , $ element , $ siblingName , $ isAfter );
228
240
} catch (\OutOfBoundsException $ e ) {
229
- $ this ->logger ->warning ('Broken reference: ' . $ e ->getMessage ());
241
+ if ($ this ->state ->getMode () === State::MODE_DEVELOPER ) {
242
+ $ this ->logger ->warning ('Broken reference: ' . $ e ->getMessage ());
243
+ }
230
244
}
231
245
$ scheduledStructure ->unsetElementFromBrokenParentList ($ element );
232
246
return $ this ;
0 commit comments