|
1 | 1 | <?php
|
2 | 2 | /**
|
3 |
| - * Copyright © Magento, Inc. All rights reserved. |
4 |
| - * See COPYING.txt for license details. |
| 3 | + * Copyright 2011 Adobe |
| 4 | + * All Rights Reserved |
5 | 5 | */
|
6 | 6 | namespace Magento\CatalogInventory\Model\Indexer;
|
7 | 7 |
|
8 | 8 | use Magento\Framework\Indexer\CacheContext;
|
| 9 | +use Magento\Framework\App\ObjectManager; |
9 | 10 |
|
10 | 11 | class Stock implements \Magento\Framework\Indexer\ActionInterface, \Magento\Framework\Mview\ActionInterface
|
11 | 12 | {
|
12 | 13 | /**
|
13 |
| - * @var \Magento\CatalogInventory\Model\Indexer\Stock\Action\Row |
| 14 | + * @var Row |
14 | 15 | */
|
15 | 16 | protected $_productStockIndexerRow;
|
16 | 17 |
|
17 | 18 | /**
|
18 |
| - * @var \Magento\CatalogInventory\Model\Indexer\Stock\Action\Rows |
| 19 | + * @var Rows |
19 | 20 | */
|
20 | 21 | protected $_productStockIndexerRows;
|
21 | 22 |
|
22 | 23 | /**
|
23 |
| - * @var \Magento\CatalogInventory\Model\Indexer\Stock\Action\Full |
| 24 | + * @var Full |
24 | 25 | */
|
25 | 26 | protected $_productStockIndexerFull;
|
26 | 27 |
|
27 | 28 | /**
|
28 |
| - * @var \Magento\Framework\Indexer\CacheContext |
| 29 | + * @var CacheContext |
29 | 30 | */
|
30 | 31 | private $cacheContext;
|
31 | 32 |
|
32 | 33 | /**
|
33 | 34 | * @param Stock\Action\Row $productStockIndexerRow
|
34 | 35 | * @param Stock\Action\Rows $productStockIndexerRows
|
35 | 36 | * @param Stock\Action\Full $productStockIndexerFull
|
| 37 | + * @param CacheContext|null $cacheContext |
36 | 38 | */
|
37 | 39 | public function __construct(
|
38 | 40 | \Magento\CatalogInventory\Model\Indexer\Stock\Action\Row $productStockIndexerRow,
|
39 | 41 | \Magento\CatalogInventory\Model\Indexer\Stock\Action\Rows $productStockIndexerRows,
|
40 |
| - \Magento\CatalogInventory\Model\Indexer\Stock\Action\Full $productStockIndexerFull |
| 42 | + \Magento\CatalogInventory\Model\Indexer\Stock\Action\Full $productStockIndexerFull, |
| 43 | + ?CacheContext $cacheContext = null |
41 | 44 | ) {
|
42 | 45 | $this->_productStockIndexerRow = $productStockIndexerRow;
|
43 | 46 | $this->_productStockIndexerRows = $productStockIndexerRows;
|
44 | 47 | $this->_productStockIndexerFull = $productStockIndexerFull;
|
| 48 | + $this->cacheContext = $cacheContext ?: ObjectManager::getInstance()->get(CacheContext::class); |
45 | 49 | }
|
46 | 50 |
|
47 | 51 | /**
|
@@ -99,14 +103,14 @@ public function executeRow($id)
|
99 | 103 | /**
|
100 | 104 | * Get cache context
|
101 | 105 | *
|
102 |
| - * @return \Magento\Framework\Indexer\CacheContext |
| 106 | + * @return CacheContext |
103 | 107 | * @deprecated 100.0.7
|
104 | 108 | * @see we don't add dependecies this way anymore
|
105 | 109 | */
|
106 | 110 | protected function getCacheContext()
|
107 | 111 | {
|
108 | 112 | if (!($this->cacheContext instanceof CacheContext)) {
|
109 |
| - return \Magento\Framework\App\ObjectManager::getInstance()->get(CacheContext::class); |
| 113 | + return ObjectManager::getInstance()->get(CacheContext::class); |
110 | 114 | } else {
|
111 | 115 | return $this->cacheContext;
|
112 | 116 | }
|
|
0 commit comments