Skip to content

Commit 835bb5e

Browse files
committed
Update deprecated registry code
1 parent 155cf84 commit 835bb5e

File tree

5 files changed

+41
-41
lines changed

5 files changed

+41
-41
lines changed

Block/Adminhtml/Job/View.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,28 @@
33
namespace Algolia\AlgoliaSearch\Block\Adminhtml\Job;
44

55
use Magento\Backend\Block\Widget\Button;
6-
use Magento\Framework\Registry;
6+
use Magento\Framework\Session\SessionManager;
77
use Magento\Framework\View\Element\Template;
88
use Magento\Framework\View\Element\Template\Context;
99

1010
class View extends Template
1111
{
12-
/** @var \Magento\Framework\Registry */
13-
protected $coreRegistry;
12+
/** @var SessionManager */
13+
protected $backendSession;
1414

1515
/**
16-
* @param Context $context
17-
* @param Registry $coreRegistry
18-
* @param array $data
16+
* @param Context $context
17+
* @param SessionManager $backendSession
18+
* @param array $data
1919
*/
2020
public function __construct(
21-
Context $context,
22-
Registry $coreRegistry,
21+
Context $context,
22+
SessionManager $backendSession,
2323
array $data = []
2424
) {
2525
parent::__construct($context, $data);
2626

27-
$this->coreRegistry = $coreRegistry;
27+
$this->backendSession = $backendSession;
2828
}
2929

3030
/** @inheritdoc */
@@ -48,7 +48,7 @@ protected function _prepareLayout()
4848
/** @return \Algolia\AlgoliaSearch\Model\Job */
4949
public function getCurrentJob()
5050
{
51-
return $this->coreRegistry->registry('current_job');
51+
return $this->backendSession->getData('current_job');
5252
}
5353

5454
/** @return string */

Block/Adminhtml/QueueArchive/View.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,28 @@
33
namespace Algolia\AlgoliaSearch\Block\Adminhtml\QueueArchive;
44

55
use Magento\Backend\Block\Widget\Button;
6-
use Magento\Framework\Registry;
6+
use Magento\Framework\Session\SessionManager;
77
use Magento\Framework\View\Element\Template;
88
use Magento\Framework\View\Element\Template\Context;
99

1010
class View extends Template
1111
{
12-
/** @var Registry */
13-
protected $coreRegistry;
12+
/** @var SessionManager */
13+
protected $backendSession;
1414

1515
/**
16-
* @param Context $context
17-
* @param Registry $coreRegistry
18-
* @param array $data
16+
* @param Context $context
17+
* @param SessionManager $backendSession
18+
* @param array $data
1919
*/
2020
public function __construct(
21-
Context $context,
22-
Registry $coreRegistry,
21+
Context $context,
22+
SessionManager $backendSession,
2323
array $data = []
2424
) {
2525
parent::__construct($context, $data);
2626

27-
$this->coreRegistry = $coreRegistry;
27+
$this->backendSession = $backendSession;
2828
}
2929

3030
/** @inheritdoc */
@@ -48,7 +48,7 @@ protected function _prepareLayout()
4848
/** @return \Algolia\AlgoliaSearch\Model\QueueArchive */
4949
public function getCurrentJob()
5050
{
51-
return $this->coreRegistry->registry('current_job');
51+
return $this->backendSession->getData('current_job');
5252
}
5353

5454
/** @return string */

Block/Algolia.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
use Magento\Framework\Data\Form\FormKey;
2121
use Magento\Framework\Locale\Currency;
2222
use Magento\Framework\Locale\Format;
23-
use Magento\Framework\Registry;
23+
use Algolia\AlgoliaSearch\Registry\CurrentProduct;
2424
use Magento\Framework\Stdlib\DateTime\DateTime;
2525
use Magento\Framework\Url\Helper\Data;
2626
use Magento\Framework\View\Element\Template;
@@ -38,9 +38,9 @@ class Algolia extends Template implements CollectionDataSourceInterface
3838
*/
3939
protected $catalogSearchHelper;
4040
/**
41-
* @var Registry
41+
* @var CurrentProduct
4242
*/
43-
protected $registry;
43+
protected $currentProduct;
4444
/**
4545
* @var ProductHelper
4646
*/
@@ -110,7 +110,7 @@ class Algolia extends Template implements CollectionDataSourceInterface
110110
* @param ProductHelper $productHelper
111111
* @param Currency $currency
112112
* @param Format $format
113-
* @param Registry $registry
113+
* @param CurrentProduct $currentProduct
114114
* @param AlgoliaHelper $algoliaHelper
115115
* @param Data $urlHelper
116116
* @param FormKey $formKey
@@ -131,7 +131,7 @@ public function __construct(
131131
ProductHelper $productHelper,
132132
Currency $currency,
133133
Format $format,
134-
Registry $registry,
134+
CurrentProduct $currentProduct,
135135
AlgoliaHelper $algoliaHelper,
136136
Data $urlHelper,
137137
FormKey $formKey,
@@ -151,7 +151,7 @@ public function __construct(
151151
$this->productHelper = $productHelper;
152152
$this->currency = $currency;
153153
$this->format = $format;
154-
$this->registry = $registry;
154+
$this->currentProduct = $currentProduct;
155155
$this->algoliaHelper = $algoliaHelper;
156156
$this->urlHelper = $urlHelper;
157157
$this->formKey = $formKey;
@@ -267,7 +267,7 @@ public function getCurrentCategory()
267267
/** @return Product */
268268
public function getCurrentProduct()
269269
{
270-
return $this->registry->registry('product');
270+
return $this->currentProduct->get();
271271
}
272272

273273
/** @return Order */

Controller/Adminhtml/Queue/AbstractAction.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
use Algolia\AlgoliaSearch\Model\JobFactory;
66
use Algolia\AlgoliaSearch\Model\ResourceModel\Job as JobResourceModel;
77
use Magento\Backend\App\Action\Context;
8-
use Magento\Framework\Registry;
8+
use Magento\Framework\Session\SessionManager;
99
use Magento\Indexer\Model\IndexerFactory;
1010

1111
abstract class AbstractAction extends \Magento\Backend\App\Action
1212
{
13-
/** @var Registry */
14-
protected $coreRegistry;
13+
/** @var SessionManager */
14+
protected $backendSession;
1515

1616
/** @var \Algolia\AlgoliaSearch\Model\JobFactory */
1717
protected $jobFactory;
@@ -24,21 +24,21 @@ abstract class AbstractAction extends \Magento\Backend\App\Action
2424

2525
/**
2626
* @param Context $context
27-
* @param Registry $coreRegistry
27+
* @param SessionManager $backendSession
2828
* @param JobFactory $jobFactory
2929
* @param JobResourceModel $jobResourceModel
3030
* @param IndexerFactory $indexerFactory
3131
*/
3232
public function __construct(
3333
Context $context,
34-
Registry $coreRegistry,
34+
SessionManager $backendSession,
3535
JobFactory $jobFactory,
3636
JobResourceModel $jobResourceModel,
3737
IndexerFactory $indexerFactory
3838
) {
3939
parent::__construct($context);
4040

41-
$this->coreRegistry = $coreRegistry;
41+
$this->backendSession = $backendSession;
4242
$this->jobFactory = $jobFactory;
4343
$this->jobResourceModel = $jobResourceModel;
4444
$this->indexerFactory = $indexerFactory;
@@ -68,7 +68,7 @@ protected function initJob()
6868
}
6969

7070
// Register model to use later in blocks
71-
$this->coreRegistry->register('current_job', $model);
71+
$this->backendSession->setData('current_job', $model);
7272

7373
return $model;
7474
}

Controller/Adminhtml/QueueArchive/AbstractAction.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
use Algolia\AlgoliaSearch\Model\QueueArchiveFactory;
66
use Algolia\AlgoliaSearch\Model\ResourceModel\QueueArchive as QueueArchiveResourceModel;
77
use Magento\Backend\App\Action\Context;
8-
use Magento\Framework\Registry;
8+
use Magento\Framework\Session\SessionManager;
99
use Magento\Indexer\Model\IndexerFactory;
1010

1111
abstract class AbstractAction extends \Magento\Backend\App\Action
1212
{
13-
/** @var Registry */
14-
protected $coreRegistry;
13+
/** @var SessionManager */
14+
protected $backendSession;
1515

1616
/** @var \Algolia\AlgoliaSearch\Model\QueueArchiveFactory */
1717
protected $queueArchiveFactory;
@@ -24,21 +24,21 @@ abstract class AbstractAction extends \Magento\Backend\App\Action
2424

2525
/**
2626
* @param Context $context
27-
* @param Registry $coreRegistry
27+
* @param SessionManager $backendSession
2828
* @param QueueArchiveFactory $queueArchiveFactory
2929
* @param QueueArchiveResourceModel $queueArchiveResourceModel
3030
* @param IndexerFactory $indexerFactory
3131
*/
3232
public function __construct(
3333
Context $context,
34-
Registry $coreRegistry,
34+
SessionManager $backendSession,
3535
QueueArchiveFactory $queueArchiveFactory,
3636
QueueArchiveResourceModel $queueArchiveResourceModel,
3737
IndexerFactory $indexerFactory
3838
) {
3939
parent::__construct($context);
4040

41-
$this->coreRegistry = $coreRegistry;
41+
$this->backendSession = $backendSession;
4242
$this->queueArchiveFactory = $queueArchiveFactory;
4343
$this->queueArchiveResourceModel = $queueArchiveResourceModel;
4444
$this->indexerFactory = $indexerFactory;
@@ -68,7 +68,7 @@ protected function initJob()
6868
}
6969

7070
// Register model to use later in blocks
71-
$this->coreRegistry->register('current_job', $model);
71+
$this->backendSession->setData('current_job', $model);
7272

7373
return $model;
7474
}

0 commit comments

Comments
 (0)