Success::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 6
rs 10
1
<?php
2
/**
3
 * Copyright © 2021 O2TI. All rights reserved.
4
 *
5
 * @author  Bruno Elisei <[email protected]>
6
 * See LICENSE.txt for license details.
7
 */
8
9
namespace O2TI\ThemeFullCheckout\Plugin;
10
11
/**
12
 * Class Success - Checkout Page Success.
13
 */
14
class Success
15
{
16
    /**
17
     * @var \Magento\Framework\Registry
18
     */
19
    protected $_coreRegistry;
20
    /**
21
     * @var \Magento\Checkout\Model\Session
22
     */
23
    protected $_checkoutSession;
24
25
    /**
26
     * Success constructor.
27
     *
28
     * @param \Magento\Framework\Registry     $coreRegistry
29
     * @param \Magento\Checkout\Model\Session $checkoutSession
30
     */
31
    public function __construct(
32
        \Magento\Framework\Registry $coreRegistry,
33
        \Magento\Checkout\Model\Session $checkoutSession
34
    ) {
35
        $this->_coreRegistry = $coreRegistry;
36
        $this->_checkoutSession = $checkoutSession;
37
    }
38
39
    /**
40
     * Set Current Order.
41
     *
42
     * @param \Magento\Checkout\Controller\Onepage\Success $subject
43
     *
44
     * @return void
45
     */
46
    public function beforeExecute()
47
    {
48
        $currentOrder = $this->_checkoutSession->getLastRealOrder();
49
        $this->_coreRegistry->register('current_order', $currentOrder);
0 ignored issues
show
Deprecated Code introduced by
The function Magento\Framework\Registry::register() has been deprecated: 102.0.0 ( Ignorable by Annotation )

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

49
        /** @scrutinizer ignore-deprecated */ $this->_coreRegistry->register('current_order', $currentOrder);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
50
    }
51
}
52