Skip to content

Commit 30eebde

Browse files
committed
Magento 2.3.2 - PWA - graphQl fetching Issue for phtml file called in static block #960
1 parent 0ee4cdd commit 30eebde

File tree

2 files changed

+18
-28
lines changed

2 files changed

+18
-28
lines changed

app/code/Magento/CmsGraphQl/Model/Resolver/DataProvider/Block.php

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use Magento\Cms\Api\Data\BlockInterface;
1212
use Magento\Framework\Exception\NoSuchEntityException;
1313
use Magento\Widget\Model\Template\FilterEmulate;
14-
use Magento\Framework\App\State;
1514

1615
/**
1716
* Cms block data provider
@@ -28,24 +27,16 @@ class Block
2827
*/
2928
private $widgetFilter;
3029

31-
/**
32-
* @var State
33-
*/
34-
private $state;
35-
3630
/**
3731
* @param BlockRepositoryInterface $blockRepository
3832
* @param FilterEmulate $widgetFilter
39-
* @param State $state
4033
*/
4134
public function __construct(
4235
BlockRepositoryInterface $blockRepository,
43-
FilterEmulate $widgetFilter,
44-
State $state
36+
FilterEmulate $widgetFilter
4537
) {
4638
$this->blockRepository = $blockRepository;
4739
$this->widgetFilter = $widgetFilter;
48-
$this->state = $state;
4940
}
5041

5142
/**
@@ -65,11 +56,7 @@ public function getData(string $blockIdentifier): array
6556
);
6657
}
6758

68-
$renderedContent = $this->state->emulateAreaCode(
69-
\Magento\Framework\App\Area::AREA_FRONTEND,
70-
[$this, 'getRenderedBlockContent'],
71-
[$block->getContent()]
72-
);
59+
$renderedContent = $this->widgetFilter->filter($block->getContent());
7360

7461
$blockData = [
7562
BlockInterface::BLOCK_ID => $block->getId(),
@@ -79,16 +66,4 @@ public function getData(string $blockIdentifier): array
7966
];
8067
return $blockData;
8168
}
82-
83-
/**
84-
* Get block data as it rendered on frontend
85-
*
86-
* @param string $blockContent
87-
*
88-
* @return string
89-
*/
90-
public function getRenderedBlockContent(string $blockContent) : string
91-
{
92-
return $this->widgetFilter->filter($blockContent);
93-
}
9469
}

app/code/Magento/Widget/Model/Template/FilterEmulate.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php
1+
<?php declare(strict_types=1);
22
/**
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
@@ -17,4 +17,19 @@ public function widgetDirective($construction)
1717
{
1818
return $this->_appState->emulateAreaCode('frontend', [$this, 'generateWidget'], [$construction]);
1919
}
20+
21+
/**
22+
* @param string $value
23+
*
24+
* @return string
25+
* @throws \Exception
26+
*/
27+
public function filter($value) : string
28+
{
29+
return $this->_appState->emulateAreaCode(
30+
\Magento\Framework\App\Area::AREA_FRONTEND,
31+
[$this, 'parent::filter'],
32+
[$value]
33+
);
34+
}
2035
}

0 commit comments

Comments
 (0)