88
99use Magento \Framework \Event \ObserverInterface ;
1010use Magento \Framework \View \EntitySpecificHandlesList ;
11+ use Magento \Framework \Serialize \Serializer \Json ;
12+ use Magento \Framework \Serialize \Serializer \Base64Json ;
1113
1214class ProcessLayoutRenderElement implements ObserverInterface
1315{
@@ -37,19 +39,37 @@ class ProcessLayoutRenderElement implements ObserverInterface
3739 */
3840 private $ entitySpecificHandlesList ;
3941
42+ /**
43+ * @var Base64Json
44+ */
45+ private $ base64jsonSerializer ;
46+
47+ /**
48+ * @var Json
49+ */
50+ private $ jsonSerializer ;
51+
4052 /**
4153 * Class constructor
4254 *
4355 * @param \Magento\PageCache\Model\Config $config
4456 * @param EntitySpecificHandlesList $entitySpecificHandlesList
57+ * @param Json $jsonSerializer
58+ * @param Base64Json $base64jsonSerializer
4559 */
4660 public function __construct (
4761 \Magento \PageCache \Model \Config $ config ,
48- EntitySpecificHandlesList $ entitySpecificHandlesList = null
62+ EntitySpecificHandlesList $ entitySpecificHandlesList = null ,
63+ Json $ jsonSerializer = null ,
64+ Base64Json $ base64jsonSerializer = null
4965 ) {
5066 $ this ->_config = $ config ;
5167 $ this ->entitySpecificHandlesList = $ entitySpecificHandlesList
5268 ?: \Magento \Framework \App \ObjectManager::getInstance ()->get (EntitySpecificHandlesList::class);
69+ $ this ->jsonSerializer = $ jsonSerializer
70+ ?: \Magento \Framework \App \ObjectManager::getInstance ()->get (Json::class);
71+ $ this ->base64jsonSerializer = $ base64jsonSerializer
72+ ?: \Magento \Framework \App \ObjectManager::getInstance ()->get (Base64Json::class);
5373 }
5474
5575 /**
@@ -68,8 +88,10 @@ private function _wrapEsi(
6888 $ url = $ block ->getUrl (
6989 'page_cache/block/esi ' ,
7090 [
71- 'blocks ' => json_encode ([$ block ->getNameInLayout ()]),
72- 'handles ' => json_encode (array_values (array_diff ($ handles , $ pageSpecificHandles )))
91+ 'blocks ' => $ this ->jsonSerializer ->serialize ([$ block ->getNameInLayout ()]),
92+ 'handles ' => $ this ->base64jsonSerializer ->serialize (
93+ array_values (array_diff ($ handles , $ pageSpecificHandles ))
94+ )
7395 ]
7496 );
7597 // Varnish does not support ESI over HTTPS must change to HTTP
0 commit comments