Completed
Push — master ( 1b679c...e05b34 )
by
unknown
19s queued 10s
created

Controller/Notify/Index.php (5 issues)

1
<?php
2
3
namespace Pagantis\Pagantis\Controller\Notify;
4
5
use Magento\Quote\Model\QuoteManagement;
6
use Magento\Quote\Api\Data\PaymentInterface;
7
use Magento\Sales\Api\Data\OrderInterface;
8
use Magento\Sales\Api\OrderRepositoryInterface;
9
use Magento\Quote\Model\Quote;
10
use Magento\Quote\Model\QuoteRepository;
11
use Magento\Framework\App\Action\Context;
12
use Magento\Framework\App\Action\Action;
13
use Pagantis\ModuleUtils\Exception\MerchantOrderNotFoundException;
14
use Pagantis\OrdersApiClient\Client;
15
use Pagantis\Pagantis\Helper\Config;
16
use Pagantis\Pagantis\Helper\ExtraConfig;
17
use Magento\Framework\App\ResourceConnection;
18
use Magento\Checkout\Model\Session;
19
use Magento\Framework\DB\Ddl\Table;
20
use Pagantis\ModuleUtils\Exception\AmountMismatchException;
21
use Pagantis\ModuleUtils\Exception\ConcurrencyException;
22
use Pagantis\ModuleUtils\Exception\NoIdentificationException;
23
use Pagantis\ModuleUtils\Exception\OrderNotFoundException;
24
use Pagantis\ModuleUtils\Exception\QuoteNotFoundException;
25
use Pagantis\ModuleUtils\Exception\UnknownException;
26
use Pagantis\ModuleUtils\Exception\WrongStatusException;
27
use Pagantis\ModuleUtils\Model\Response\JsonSuccessResponse;
28
use Pagantis\ModuleUtils\Model\Response\JsonExceptionResponse;
29
use Pagantis\ModuleUtils\Exception\AlreadyProcessedException;
30
use Pagantis\ModuleUtils\Model\Log\LogEntry;
31
32
/**
33
 * Class Index
34
 * @package Pagantis\Pagantis\Controller\Notify
35
 */
36
class Index extends Action
37
{
38
    /** Orders tablename */
39
    const ORDERS_TABLE = 'cart_process';
40
41
    /** Concurrency tablename */
42
    const CONCURRENCY_TABLE = 'Pagantis_orders';
43
44
    /** Concurrency tablename */
45
    const LOGS_TABLE = 'Pagantis_logs';
46
47
    /** Payment code */
48
    const PAYMENT_METHOD = 'pagantis';
49
50
    /**
51
     * EXCEPTION RESPONSES
52
     */
53
    const CPO_ERR_MSG = 'Order not confirmed';
54
    const CPO_OK_MSG = 'Order confirmed';
55
56
    /** @var QuoteManagement */
57
    protected $quoteManagement;
58
59
    /** @var PaymentInterface $paymentInterface */
60
    protected $paymentInterface;
61
62
    /** @var OrderRepositoryInterface $orderRepositoryInterface */
63
    protected $orderRepositoryInterface;
64
65
    /** @var Quote $quote */
66
    protected $quote;
67
68
    /** @var QuoteRepository $quoteRepository */
69
    protected $quoteRepository;
70
71
    /** @var mixed $config */
72
    protected $config;
73
74
    /** @var mixed $quoteId */
75
    protected $quoteId;
76
77
    /** @var array $notifyResult */
78
    protected $notifyResult;
79
80
    /** @var mixed $magentoOrderId */
81
    protected $magentoOrderId;
82
83
    /** @var mixed $pagantisOrder */
84
    protected $pagantisOrder;
85
86
    /** @var ResourceConnection $dbObject */
87
    protected $dbObject;
88
89
    /** @var Session $checkoutSession */
90
    protected $checkoutSession;
91
92
    /** @var Client $orderClient */
93
    protected $orderClient;
94
95
    /** @var mixed $pagantisOrderId */
96
    protected $pagantisOrderId;
97
98
    /** @var  OrderInterface $magentoOrder */
99
    protected $magentoOrder;
100
101
    /** @var ExtraConfig $extraConfig */
102
    protected $extraConfig;
103
104
    /** @var mixed $origin */
105
    protected $origin;
106
107
    /**
108
     * Index constructor.
109
     *
110
     * @param Context                  $context
111
     * @param Quote                    $quote
112
     * @param QuoteManagement          $quoteManagement
113
     * @param PaymentInterface         $paymentInterface
114
     * @param Config                   $config
115
     * @param QuoteRepository          $quoteRepository
116
     * @param OrderRepositoryInterface $orderRepositoryInterface
117
     * @param ResourceConnection       $dbObject
118
     * @param Session                  $checkoutSession
119
     * @param ExtraConfig              $extraConfig
120
     */
121
    public function __construct(
122
        Context $context,
123
        Quote $quote,
124
        QuoteManagement $quoteManagement,
125
        PaymentInterface $paymentInterface,
126
        Config $config,
127
        QuoteRepository $quoteRepository,
128
        OrderRepositoryInterface $orderRepositoryInterface,
129
        ResourceConnection $dbObject,
130
        Session $checkoutSession,
131
        ExtraConfig $extraConfig
132
    ) {
133
        parent::__construct($context);
134
        $this->quote = $quote;
135
        $this->quoteManagement = $quoteManagement;
136
        $this->paymentInterface = $paymentInterface;
137
        $this->extraConfig = $extraConfig->getExtraConfig();
0 ignored issues
show
Documentation Bug introduced by
It seems like $extraConfig->getExtraConfig() of type array or array is incompatible with the declared type Pagantis\Pagantis\Helper\ExtraConfig of property $extraConfig.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
138
        $this->config = $config->getConfig();
139
        $this->quoteRepository = $quoteRepository;
140
        $this->orderRepositoryInterface = $orderRepositoryInterface;
141
        $this->dbObject = $dbObject;
142
        $this->checkoutSession = $checkoutSession;
143
        $this->origin = ($_SERVER['REQUEST_METHOD'] == 'POST') ? 'Notification' : 'Order';
144
    }
145
146
    /**
147
     * @return \Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\ResultInterface|void
148
     * @throws UnknownException
149
     */
150
    public function execute()
151
    {
152
        try {
153
            $this->checkConcurrency();
154
            $this->getMerchantOrder();
155
            $this->getPagantisOrderId();
156
            $this->getPagantisOrder();
157
            $this->checkOrderStatus();
158
            $this->checkMerchantOrderStatus();
159
            $this->validateAmount();
160
            $this->processMerchantOrder();
161
        } catch (\Exception $exception) {
162
            $jsonResponse = new JsonExceptionResponse();
163
            $jsonResponse->setMerchantOrderId($this->magentoOrderId);
164
            $jsonResponse->setpagantisOrderId($this->pagantisOrderId);
165
            $jsonResponse->setException($exception);
166
            $response = $jsonResponse->toJson();
167
            $this->insertLog($exception);
168
        }
169
170
        try {
171
            if (!isset($response)) {
172
                $this->confirmpagantisOrder();
173
                $jsonResponse = new JsonSuccessResponse();
174
                $jsonResponse->setMerchantOrderId($this->magentoOrderId);
175
                $jsonResponse->setpagantisOrderId($this->pagantisOrderId);
176
            }
177
        } catch (\Exception $exception) {
178
            $this->rollbackMerchantOrder();
179
            $jsonResponse = new JsonExceptionResponse();
180
            $jsonResponse->setMerchantOrderId($this->magentoOrderId);
181
            $jsonResponse->setpagantisOrderId($this->pagantisOrderId);
182
            $jsonResponse->setException($exception);
183
            $jsonResponse->toJson();
184
            $this->insertLog($exception);
185
        }
186
187
        $this->unblockConcurrency(true);
188
189
        if ($_SERVER['REQUEST_METHOD'] == 'POST') {
190
            $jsonResponse->printResponse();
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $jsonResponse does not seem to be defined for all execution paths leading up to this point.
Loading history...
191
        } else {
192
            $returnUrl = $this->getRedirectUrl();
193
            $this->_redirect($returnUrl);
194
        }
195
    }
196
197
    /**
198
     * COMMON FUNCTIONS
199
     */
200
201
    /**
202
     * @throws QuoteNotFoundException
203
     * @throws UnknownException
204
     */
205
    private function checkConcurrency()
206
    {
207
        $this->getQuoteId();
208
        $this->checkDbTable();
209
        $this->unblockConcurrency();
210
        $this->blockConcurrency();
211
    }
212
213
    /**
214
     * @throws MerchantOrderNotFoundException
215
     */
216
    private function getMerchantOrder()
217
    {
218
        try {
219
            /** @var Quote quote */
220
            $this->quote = $this->quoteRepository->get($this->quoteId);
221
        } catch (\Exception $e) {
222
            throw new MerchantOrderNotFoundException();
223
        }
224
    }
225
226
    /**
227
     * @throws UnknownException
228
     */
229
    private function getPagantisOrderId()
230
    {
231
        try {
232
            /** @var \Magento\Framework\DB\Adapter\AdapterInterface $dbConnection */
233
            $dbConnection     = $this->dbObject->getConnection();
234
            $tableName        = $this->dbObject->getTableName(self::ORDERS_TABLE);
235
            $query            = "select order_id from $tableName where id='$this->quoteId'";
236
            $queryResult      = $dbConnection->fetchRow($query);
237
            $this->pagantisOrderId = $queryResult['order_id'];
238
            if ($this->pagantisOrderId == '') {
239
                throw new NoIdentificationException();
240
            }
241
        } catch (\Exception $e) {
242
            throw new UnknownException($e->getMessage());
243
        }
244
    }
245
246
    /**
247
     * @throws OrderNotFoundException
248
     */
249
    private function getPagantisOrder()
250
    {
251
        try {
252
            $this->orderClient = new Client($this->config['pagantis_public_key'], $this->config['pagantis_private_key']);
253
            $this->pagantisOrder = $this->orderClient->getOrder($this->pagantisOrderId);
254
        } catch (\Exception $e) {
255
            throw new OrderNotFoundException();
256
        }
257
    }
258
259
    /**
260
     * @throws AlreadyProcessedException
261
     * @throws WrongStatusException
262
     */
263
    private function checkOrderStatus()
264
    {
265
        try {
266
            $this->checkPagantisStatus(array('AUTHORIZED'));
267
        } catch (\Exception $e) {
268
            $this->getMagentoOrderId();
269
            if ($this->magentoOrderId!='') {
270
                throw new AlreadyProcessedException();
271
            } else {
272
                throw new WrongStatusException($this->pagantisOrder->getStatus());
273
            }
274
        }
275
    }
276
277
    /**
278
     * @throws AlreadyProcessedException
279
     */
280
    private function checkMerchantOrderStatus()
281
    {
282
        if ($this->quote->getIsActive()=='0') {
283
            $this->getMagentoOrderId();
284
            throw new AlreadyProcessedException();
285
        }
286
    }
287
288
    /**
289
     * @throws AmountMismatchException
290
     */
291
    private function validateAmount()
292
    {
293
        $pagantisAmount = $this->pagantisOrder->getShoppingCart()->getTotalAmount();
294
        $merchantAmount = intval(strval(100 * $this->quote->getGrandTotal()));
295
        if ($pagantisAmount != $merchantAmount) {
296
            throw new AmountMismatchException($pagantisAmount, $merchantAmount);
297
        }
298
    }
299
300
    /**
301
     * @throws UnknownException
302
     */
303
    private function processMerchantOrder()
304
    {
305
        try {
306
            $this->saveOrder();
307
            $this->updateBdInfo();
308
        } catch (\Exception $e) {
309
            throw new UnknownException($e->getMessage());
310
        }
311
    }
312
313
    /**
314
     * @return false|string
315
     * @throws UnknownException
316
     */
317
    private function confirmpagantisOrder()
318
    {
319
        try {
320
            $this->pagantisOrder = $this->orderClient->confirmOrder($this->pagantisOrderId);
321
        } catch (\Exception $e) {
322
            throw new UnknownException($e->getMessage());
323
        }
324
325
        $jsonResponse = new JsonSuccessResponse();
326
        $jsonResponse->setStatusCode(200);
327
        $jsonResponse->setMerchantOrderId($this->magentoOrderId);
328
        $jsonResponse->setpagantisOrderId($this->pagantisOrderId);
329
        $jsonResponse->setResult(self::CPO_OK_MSG);
330
        return $jsonResponse->toJson();
331
    }
332
333
    /**
334
     * UTILS FUNCTIONS
335
     */
336
337
    /** STEP 1 CC - Check concurrency
338
     * @throws QuoteNotFoundException
339
     */
340
    private function getQuoteId()
341
    {
342
        $this->quoteId = $this->getRequest()->getParam('quoteId');
343
        if ($this->quoteId == '') {
344
            throw new QuoteNotFoundException();
345
        }
346
    }
347
348
    /**
349
     * @return \Zend_Db_Statement_Interface
350
     * @throws UnknownException
351
     */
352
    private function checkDbTable()
353
    {
354
        try {
355
            /** @var \Magento\Framework\DB\Adapter\AdapterInterface $dbConnection */
356
            $dbConnection = $this->dbObject->getConnection();
357
            $tableName    = $this->dbObject->getTableName(self::CONCURRENCY_TABLE);
358
            $query        = "CREATE TABLE IF NOT EXISTS $tableName(`id` int not null,`timestamp` int not null,PRIMARY KEY (`id`))";
359
360
            return $dbConnection->query($query);
361
        } catch (\Exception $e) {
362
            throw new UnknownException($e->getMessage());
363
        }
364
    }
365
366
    /**
367
     * @return void|\Zend_Db_Statement_Interface
368
     * @throws UnknownException
369
     */
370
    private function checkDbLogTable()
371
    {
372
        try {
373
            /** @var \Magento\Framework\DB\Adapter\AdapterInterface $dbConnection */
374
            $dbConnection = $this->dbObject->getConnection();
375
            $tableName = $this->dbObject->getTableName(self::LOGS_TABLE);
376
            if (!$dbConnection->isTableExists($tableName)) {
377
                $table = $dbConnection
378
                    ->newTable($tableName)
379
                    ->addColumn('id', Table::TYPE_SMALLINT, null, array('nullable'=>false, 'auto_increment'=>true, 'primary'=>true))
380
                    ->addColumn('log', Table::TYPE_TEXT, null, array('nullable'=>false))
381
                    ->addColumn('createdAt', Table::TYPE_TIMESTAMP, null, array('nullable'=>false, 'default'=>Table::TIMESTAMP_INIT));
382
                return $dbConnection->createTable($table);
383
            }
384
385
            return;
386
        } catch (\Exception $e) {
387
            throw new UnknownException($e->getMessage());
388
        }
389
    }
390
391
    /**
392
     * @param bool $mode
393
     *
394
     * @throws \Exception
395
     */
396
    private function unblockConcurrency($mode = false)
397
    {
398
        try {
399
            /** @var \Magento\Framework\DB\Adapter\AdapterInterface $dbConnection */
400
            $dbConnection = $this->dbObject->getConnection();
401
            $tableName    = $this->dbObject->getTableName(self::CONCURRENCY_TABLE);
402
            if ($mode == false) {
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison === instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
403
                $dbConnection->delete($tableName, "timestamp<".(time() - 5));
404
            } elseif ($this->quoteId!='') {
405
                $dbConnection->delete($tableName, "id=".$this->quoteId);
406
            }
407
        } catch (Exception $exception) {
0 ignored issues
show
The type Pagantis\Pagantis\Controller\Notify\Exception was not found. Did you mean Exception? If so, make sure to prefix the type with \.
Loading history...
408
            throw new ConcurrencyException();
409
        }
410
    }
411
412
    /**
413
     * @throws \Exception
414
     */
415
    private function blockConcurrency()
416
    {
417
        try {
418
            /** @var \Magento\Framework\DB\Adapter\AdapterInterface $dbConnection */
419
            $dbConnection = $this->dbObject->getConnection();
420
            $tableName    = $this->dbObject->getTableName(self::CONCURRENCY_TABLE);
421
            $dbConnection->insert($tableName, array('id'=>$this->quoteId, 'timestamp'=>time()));
422
        } catch (Exception $exception) {
423
            throw new ConcurrencyException();
424
        }
425
    }
426
427
    /** STEP 2 GMO - Get Merchant Order */
428
    /** STEP 3 GPOI - Get Pagantis OrderId */
429
    /** STEP 4 GPO - Get Pagantis Order */
430
    /** STEP 5 COS - Check Order Status */
431
    /**
432
     * @param $statusArray
433
     *
434
     * @throws \Exception
435
     */
436
    private function checkPagantisStatus($statusArray)
437
    {
438
        $pagantisStatus = array();
439
        foreach ($statusArray as $status) {
440
            $pagantisStatus[] = constant("\Pagantis\OrdersApiClient\Model\Order::STATUS_$status");
441
        }
442
443
        $payed = in_array($this->pagantisOrder->getStatus(), $pagantisStatus);
444
        if (!$payed) {
445
            throw new WrongStatusException($this->pagantisOrder->getStatus());
446
        }
447
    }
448
449
    /** STEP 6 CMOS - Check Merchant Order Status */
450
    /**
451
     * @throws \Exception
452
     */
453
    private function getMagentoOrderId()
454
    {
455
        try {
456
            /** @var \Magento\Framework\DB\Adapter\AdapterInterface $dbConnection */
457
            $dbConnection = $this->dbObject->getConnection();
458
            $tableName    = $this->dbObject->getTableName(self::ORDERS_TABLE);
459
            $pagantisOrderId   = $this->pagantisOrderId;
460
461
            $query        = "select mg_order_id from $tableName where id='$this->quoteId' and order_id='$pagantisOrderId'";
462
            $queryResult  = $dbConnection->fetchRow($query);
463
            $this->magentoOrderId = $queryResult['mg_order_id'];
464
        } catch (\Exception $e) {
465
            throw new UnknownException($e->getMessage());
466
        }
467
    }
468
469
    /** STEP 7 VA - Validate Amount */
470
    /** STEP 8 PMO - Process Merchant Order */
471
    /**
472
     * @throws UnknownException
473
     */
474
    private function saveOrder()
475
    {
476
        try {
477
            $this->paymentInterface->setMethod(self::PAYMENT_METHOD);
478
            $this->magentoOrderId = $this->quoteManagement->placeOrder($this->quoteId, $this->paymentInterface);
479
480
            /** @var OrderRepositoryInterface magentoOrder */
481
            $this->magentoOrder = $this->orderRepositoryInterface->get($this->magentoOrderId);
482
            $metadataOrder = $this->pagantisOrder->getMetadata();
483
            $metadataInfo = null;
484
            foreach ($metadataOrder as $metadataKey => $metadataValue) {
485
                if ($metadataKey == 'promotedProduct') {
486
                    $metadataInfo.= " Producto promocionado = $metadataValue //";
487
                }
488
            }
489
            $this->magentoOrder->addStatusHistoryComment($metadataInfo)->setIsCustomerNotified(false)->setEntityName('order')->save();
490
491
            $comment = 'pagantisOrderId: '.$this->pagantisOrder->getId(). ' ' .
492
                       'pagantisOrderStatus: '.$this->pagantisOrder->getStatus(). ' ' .
493
                       'via: '.$this->origin;
494
            $this->magentoOrder->addStatusHistoryComment($comment)->setIsCustomerNotified(false)->setEntityName('order')->save();
495
496
            if ($this->magentoOrderId == '') {
497
                throw new UnknownException('Order can not be saved');
498
            }
499
        } catch (\Exception $e) {
500
            throw new UnknownException($e->getMessage());
501
        }
502
    }
503
504
    /**
505
     * @throws UnknownException
506
     */
507
    private function updateBdInfo()
508
    {
509
        try {
510
            /** @var \Magento\Framework\DB\Adapter\AdapterInterface $dbConnection */
511
            $dbConnection = $this->dbObject->getConnection();
512
            $tableName    = $this->dbObject->getTableName(self::ORDERS_TABLE);
513
            $pagantisOrderId   = $this->pagantisOrder->getId();
514
            $dbConnection->update(
515
                $tableName,
516
                array('mg_order_id' => $this->magentoOrderId),
517
                "order_id='$pagantisOrderId' and id='$this->quoteId'"
518
            );
519
        } catch (\Exception $e) {
520
            throw new UnknownException($e->getMessage());
521
        }
522
    }
523
524
    /** STEP 9 CPO - Confirmation Pagantis Order */
525
    /**
526
     * @throws UnknownException
527
     */
528
    private function rollbackMerchantOrder()
529
    {
530
        try {
531
            $this->magentoOrder->setState(\Magento\Sales\Model\Order::STATE_PENDING_PAYMENT, true);
0 ignored issues
show
The call to Magento\Sales\Api\Data\OrderInterface::setState() has too many arguments starting with true. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

531
            $this->magentoOrder->/** @scrutinizer ignore-call */ 
532
                                 setState(\Magento\Sales\Model\Order::STATE_PENDING_PAYMENT, true);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
532
            $this->magentoOrder->setStatus(\Magento\Sales\Model\Order::STATE_PENDING_PAYMENT);
533
            $this->magentoOrder->save();
534
        } catch (\Exception $e) {
535
            throw new UnknownException($e->getMessage());
536
        }
537
    }
538
539
    /**
540
     * @return string
541
     */
542
    private function getRedirectUrl()
543
    {
544
        //$returnUrl = 'checkout/#payment';
545
        $returnUrl = $this->_url->getUrl('checkout', ['_fragment' => 'payment']);
546
        if ($this->magentoOrderId!='') {
547
            /** @var Order $this->magentoOrder */
548
            $this->magentoOrder = $this->orderRepositoryInterface->get($this->magentoOrderId);
549
            if (!$this->_objectManager->get(\Magento\Checkout\Model\Session\SuccessValidator::class)->isValid()) {
550
                $this->checkoutSession
551
                    ->setLastOrderId($this->magentoOrderId)
552
                    ->setLastRealOrderId($this->magentoOrder->getIncrementId())
553
                    ->setLastQuoteId($this->quoteId)
554
                    ->setLastSuccessQuoteId($this->quoteId)
555
                    ->setLastOrderStatus($this->magentoOrder->getStatus());
556
            }
557
558
            //Magento status flow => https://docs.magento.com/m2/ce/user_guide/sales/order-status-workflow.html
559
            //Order Workflow => https://docs.magento.com/m2/ce/user_guide/sales/order-workflow.html
560
            $orderStatus    = strtolower($this->magentoOrder->getStatus());
561
            $acceptedStatus = array('processing', 'completed');
562
            if (in_array($orderStatus, $acceptedStatus)) {
563
                if (isset($this->extraConfig['PAGANTIS_OK_URL']) &&  $this->extraConfig['PAGANTIS_OK_URL']!= '') {
564
                    $returnUrl = $this->extraConfig['PAGANTIS_OK_URL'];
565
                } else {
566
                    $returnUrl = 'checkout/onepage/success';
567
                }
568
            } else {
569
                if (isset($this->extraConfig['PAGANTIS_KO_URL']) && $this->extraConfig['PAGANTIS_KO_URL'] != '') {
570
                    $returnUrl = $this->extraConfig['PAGANTIS_KO_URL'];
571
                } else {
572
                    //$returnUrl = 'checkout/#payment';
573
                    $returnUrl = $this->_url->getUrl('checkout', ['_fragment' => 'payment']);
574
                }
575
            }
576
        }
577
        return $returnUrl;
578
    }
579
580
    /**
581
     * @param $exceptionMessage
582
     *
583
     * @throws UnknownException
584
     */
585
    private function insertLog($exceptionMessage)
586
    {
587
        try {
588
            if ($exceptionMessage instanceof \Exception) {
589
                $this->checkDbLogTable();
590
                $logEntry = new LogEntry();
591
                $logEntryJson = $logEntry->error($exceptionMessage)->toJson();
592
593
                /** @var \Magento\Framework\DB\Adapter\AdapterInterface $dbConnection */
594
                $dbConnection = $this->dbObject->getConnection();
595
                $tableName    = $this->dbObject->getTableName(self::LOGS_TABLE);
596
                $dbConnection->insert($tableName, array('log' => $logEntryJson));
597
            }
598
        } catch (\Exception $e) {
599
            throw new UnknownException($e->getMessage());
600
        }
601
    }
602
}
603