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
|
|
|
declare(strict_types=1); |
10
|
|
|
|
11
|
|
|
namespace O2TI\ThemeFullCheckout\Observer; |
12
|
|
|
|
13
|
|
|
use Magento\Framework\App\Config\ScopeConfigInterface; |
14
|
|
|
use Magento\Framework\Event; |
15
|
|
|
use Magento\Framework\Event\Observer as EventObserver; |
16
|
|
|
use Magento\Framework\Event\ObserverInterface; |
17
|
|
|
use Magento\Framework\View\Layout as Layout; |
18
|
|
|
use Magento\Framework\View\Layout\ProcessorInterface as LayoutProcessor; |
19
|
|
|
use Magento\Store\Model\ScopeInterface; |
20
|
|
|
use Magento\Store\Model\StoreManagerInterface; |
21
|
|
|
use O2TI\ThemeFullCheckout\Helper\Config; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* AddFullCheckoutLayoutUpdateHandleObserver - Add Theme Full Checkout. |
25
|
|
|
*/ |
26
|
|
|
class AddFullCheckoutLayoutUpdateHandleObserver implements ObserverInterface |
27
|
|
|
{ |
28
|
|
|
/** |
29
|
|
|
* Category Custom Layout. |
30
|
|
|
*/ |
31
|
|
|
public const LAYOUT_HANDLE_FULL_CHECKOUT = 'theme_full_checkout'; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @var Config |
35
|
|
|
*/ |
36
|
|
|
private $config; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @var ScopeInterface |
40
|
|
|
*/ |
41
|
|
|
private $scopeConfig; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @var StoreManagerInterface |
45
|
|
|
*/ |
46
|
|
|
private $storeManagerInterface; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @param ScopeConfigInterface $scopeConfig |
50
|
|
|
* @param StoreManagerInterface $storeManagerInterface |
51
|
|
|
* @param Config $config |
52
|
|
|
*/ |
53
|
|
|
public function __construct( |
54
|
|
|
ScopeConfigInterface $scopeConfig, |
55
|
|
|
StoreManagerInterface $storeManagerInterface, |
56
|
|
|
Config $config |
57
|
|
|
) { |
58
|
|
|
$this->scopeConfig = $scopeConfig; |
|
|
|
|
59
|
|
|
$this->storeManagerInterface = $storeManagerInterface; |
60
|
|
|
$this->config = $config; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Add Handle to Checkout. |
65
|
|
|
* |
66
|
|
|
* @param EventObserver $observer |
67
|
|
|
* |
68
|
|
|
* @return void |
69
|
|
|
*/ |
70
|
|
|
public function execute(EventObserver $observer) |
71
|
|
|
{ |
72
|
|
|
if ($this->config->isEnabled()) { |
73
|
|
|
/** @var Event $event */ |
74
|
|
|
$event = $observer->getEvent(); |
75
|
|
|
$actionName = $event->getData('full_action_name'); |
76
|
|
|
|
77
|
|
|
if ($actionName === 'checkout_index_index') { |
78
|
|
|
/** @var Layout $layout */ |
79
|
|
|
$layout = $event->getData('layout'); |
80
|
|
|
|
81
|
|
|
/** @var LayoutProcessor $layoutUpdate */ |
82
|
|
|
$layoutUpdate = $layout->getUpdate(); |
83
|
|
|
$layoutUpdate->addHandle(static::LAYOUT_HANDLE_FULL_CHECKOUT); |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
|
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..