55 */
66namespace Magento \Framework \View \Layout ;
77
8+ use Magento \Framework \App \ObjectManager ;
9+ use Magento \Framework \App \State ;
810use Magento \Framework \View \Layout \Condition \ConditionFactory ;
11+ use Psr \Log \LoggerInterface ;
912
1013/**
1114 * Pool of generators for structural elements
1215 * @api
16+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1317 */
1418class GeneratorPool
1519{
@@ -24,31 +28,39 @@ class GeneratorPool
2428 protected $ generators = [];
2529
2630 /**
27- * @var \Psr\Log\ LoggerInterface
31+ * @var LoggerInterface
2832 */
2933 protected $ logger ;
3034
3135 /**
32- * @var \Magento\Framework\View\Layout\Condition\ ConditionFactory
36+ * @var ConditionFactory
3337 */
3438 private $ conditionFactory ;
3539
40+ /**
41+ * @var State
42+ */
43+ private $ state ;
44+
3645 /**
3746 * @param ScheduledStructure\Helper $helper
3847 * @param ConditionFactory $conditionFactory
39- * @param \Psr\Log\ LoggerInterface $logger
48+ * @param LoggerInterface $logger
4049 * @param array|null $generators
50+ * @param State|null $state
4151 */
4252 public function __construct (
4353 ScheduledStructure \Helper $ helper ,
4454 ConditionFactory $ conditionFactory ,
45- \Psr \Log \LoggerInterface $ logger ,
46- array $ generators = null
55+ LoggerInterface $ logger ,
56+ array $ generators = null ,
57+ ?State $ state = null
4758 ) {
4859 $ this ->helper = $ helper ;
4960 $ this ->conditionFactory = $ conditionFactory ;
5061 $ this ->logger = $ logger ;
5162 $ this ->addGenerators ($ generators );
63+ $ this ->state = $ state ?? ObjectManager::getInstance ()->get (State::class);
5264 }
5365
5466 /**
@@ -226,7 +238,9 @@ protected function moveElementInStructure(
226238 $ structure ->setAsChild ($ element , $ destination , $ alias );
227239 $ structure ->reorderChildElement ($ destination , $ element , $ siblingName , $ isAfter );
228240 } 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+ }
230244 }
231245 $ scheduledStructure ->unsetElementFromBrokenParentList ($ element );
232246 return $ this ;
0 commit comments