From 6ed764c2dbe72889e8d027075754a2026d70a1b7 Mon Sep 17 00:00:00 2001 From: Yohan Date: Fri, 13 Dec 2019 17:12:59 +0100 Subject: [PATCH] Add enable field --- Transport/UdpTransportWrapper.php | 25 ++++++++++++++++++++++++- etc/adminhtml/system.xml | 7 ++++++- etc/di.xml | 1 + 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/Transport/UdpTransportWrapper.php b/Transport/UdpTransportWrapper.php index 3cb7f06..7cad71c 100644 --- a/Transport/UdpTransportWrapper.php +++ b/Transport/UdpTransportWrapper.php @@ -23,18 +23,27 @@ class UdpTransportWrapper implements TransportInterface * @var ScopeConfigInterface */ private $scopeConfig; + /** * @var string */ private $hostPath; + /** * @var string */ private $portPath; + + /** + * @var string + */ + private $isEnable; + /** * @var string */ private $chunkSize; + /** * @var UdpTransport */ @@ -45,16 +54,28 @@ class UdpTransportWrapper implements TransportInterface */ private $transportFactory; + /** + * UdpTransportWrapper constructor. + * + * @param UdpTransportFactory $transportFactory + * @param ScopeConfigInterface $scopeConfig + * @param string $hostPath + * @param string $portPath + * @param string $isEnable + * @param string $chunkSize + */ public function __construct( UdpTransportFactory $transportFactory, ScopeConfigInterface $scopeConfig, string $hostPath, string $portPath, + string $isEnable, string $chunkSize = UdpTransport::CHUNK_SIZE_LAN ) { $this->scopeConfig = $scopeConfig; $this->hostPath = $hostPath; $this->portPath = $portPath; + $this->isEnable = $isEnable; $this->chunkSize = $chunkSize; $this->transportFactory = $transportFactory; } @@ -68,7 +89,9 @@ public function __construct( */ public function send(Message $message) { - return $this->getTransporter()->send($message); + if ($this->scopeConfig->getValue($this->isEnable) === '1') { + return $this->getTransporter()->send($message); + } } /** diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index db00936..a7ff1b3 100644 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -16,11 +16,16 @@ Opengento_Logger::config_opengento_looger + + + + Magento\Config\Model\Config\Source\Yesno + - + diff --git a/etc/di.xml b/etc/di.xml index d99dbd5..7768da4 100644 --- a/etc/di.xml +++ b/etc/di.xml @@ -11,6 +11,7 @@ loggin/loggin/transport_host loggin/loggin/transport_port + loggin/loggin/is_enable