Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
module-page-cache
Controller
Block.php
Go to the documentation of this file.
1
<?php
8
namespace
Magento\PageCache\Controller
;
9
10
use
Magento\Framework\Serialize\Serializer\Base64Json
;
11
use
Magento\Framework\Serialize\Serializer\Json
;
12
use
Magento\Framework\View\Layout\LayoutCacheKeyInterface
;
13
14
abstract
class
Block
extends
\Magento\Framework\App\Action\Action
15
{
19
protected
$translateInline
;
20
24
private
$jsonSerializer;
25
29
private
$base64jsonSerializer;
30
36
private
$layoutCacheKey;
37
41
private
$layoutCacheKeyName =
'mage_pagecache'
;
42
50
public
function
__construct
(
51
\
Magento
\Framework\
App
\Action\
Context
$context,
52
\
Magento
\Framework\Translate\InlineInterface
$translateInline
,
53
Json
$jsonSerializer =
null
,
54
Base64Json
$base64jsonSerializer =
null
,
55
LayoutCacheKeyInterface
$layoutCacheKey =
null
56
) {
57
parent::__construct($context);
58
$this->translateInline =
$translateInline
;
59
$this->jsonSerializer = $jsonSerializer
60
?:
\Magento\Framework\App\ObjectManager::getInstance
()->get(Json::class);
61
$this->base64jsonSerializer = $base64jsonSerializer
62
?:
\Magento\Framework\App\ObjectManager::getInstance
()->get(Base64Json::class);
63
$this->layoutCacheKey = $layoutCacheKey
64
?:
\Magento\Framework\App\ObjectManager::getInstance
()->get(LayoutCacheKeyInterface::class);
65
}
66
72
protected
function
_getBlocks
()
73
{
74
$blocks = $this->
getRequest
()->getParam(
'blocks'
,
''
);
75
$handles = $this->
getRequest
()->getParam(
'handles'
,
''
);
76
77
if
(!$handles || !$blocks) {
78
return
[];
79
}
80
$blocks = $this->jsonSerializer->unserialize($blocks);
81
$handles = $this->base64jsonSerializer->unserialize($handles);
82
83
$layout = $this->_view->getLayout();
84
$this->layoutCacheKey->addCacheKeys($this->layoutCacheKeyName);
85
86
$this->_view->loadLayout($handles,
true
,
true
,
false
);
87
$data
= [];
88
89
foreach
($blocks as $blockName) {
90
$blockInstance = $layout->getBlock($blockName);
91
if
(is_object($blockInstance)) {
92
$data
[$blockName] = $blockInstance;
93
}
94
}
95
96
return
$data
;
97
}
98
}
Magento\Framework\App
Magento\Framework\Serialize\Serializer\Json
Definition:
Json.php:16
Magento\Framework\App\ObjectManager\getInstance
static getInstance()
Definition:
ObjectManager.php:33
Magento\PageCache\Controller
Magento\PageCache\Controller\Block
Definition:
Block.php:14
Magento\Framework\App\Action\AbstractAction\getRequest
getRequest()
Definition:
AbstractAction.php:60
$data
$data
Definition:
attribute_set_with_image_attribute.php:16
Magento\Framework\View\Layout\LayoutCacheKeyInterface
Definition:
LayoutCacheKeyInterface.php:11
Magento\PageCache\Controller\Block\_getBlocks
_getBlocks()
Definition:
Block.php:72
Magento\PageCache\Controller\Block\__construct
__construct(\Magento\Framework\App\Action\Context $context, \Magento\Framework\Translate\InlineInterface $translateInline, Json $jsonSerializer=null, Base64Json $base64jsonSerializer=null, LayoutCacheKeyInterface $layoutCacheKey=null)
Definition:
Block.php:50
Magento
Magento\PageCache\Controller\Block\$translateInline
$translateInline
Definition:
Block.php:19
Magento\Framework\Serialize\Serializer\Base64Json
Definition:
Base64Json.php:14
Context
Definition:
ClassesForConstructorIntegrity.php:33
Magento\Framework\App\Action\Action
Definition:
Action.php:25