request = $request; $this->actionFactory = $actionFactory; $this->metadataFactory = $metadataFactory; $this->context = $context; } public function execute(\Magento\Framework\Event\Observer $observer) { $metadata = $this->metadataFactory->create([ 'request' => $this->request, 'eventName' => MetadataInterface::EVENT_LAYOUT_RENDER_BEFORE, 'loggingObject' => $this->context ]); $actionHandler = $this->actionFactory->create($metadata); $actionHandler->execute(); } }