Skip to content

Commit b94085e

Browse files
committed
Magento 2.3.2 - PWA - graphQl fetching Issue for phtml file called in static block #960
1 parent ea71192 commit b94085e

File tree

1 file changed

+25
-2
lines changed
  • app/code/Magento/CmsGraphQl/Model/Resolver/DataProvider

1 file changed

+25
-2
lines changed

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

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
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;
1415

1516
/**
1617
* Cms block data provider
@@ -27,16 +28,24 @@ class Block
2728
*/
2829
private $widgetFilter;
2930

31+
/**
32+
* @var State
33+
*/
34+
private $state;
35+
3036
/**
3137
* @param BlockRepositoryInterface $blockRepository
3238
* @param FilterEmulate $widgetFilter
39+
* @param State $state
3340
*/
3441
public function __construct(
3542
BlockRepositoryInterface $blockRepository,
36-
FilterEmulate $widgetFilter
43+
FilterEmulate $widgetFilter,
44+
State $state
3745
) {
3846
$this->blockRepository = $blockRepository;
3947
$this->widgetFilter = $widgetFilter;
48+
$this->state = $state;
4049
}
4150

4251
/**
@@ -56,7 +65,11 @@ public function getData(string $blockIdentifier): array
5665
);
5766
}
5867

59-
$renderedContent = $this->widgetFilter->filter($block->getContent());
68+
$renderedContent = $this->state->emulateAreaCode(
69+
'frontend',
70+
[$this, 'getRenderedBlockContent'],
71+
[$block->getContent()]
72+
);
6073

6174
$blockData = [
6275
BlockInterface::BLOCK_ID => $block->getId(),
@@ -66,4 +79,14 @@ public function getData(string $blockIdentifier): array
6679
];
6780
return $blockData;
6881
}
82+
83+
/**
84+
* @param string $blockContent
85+
*
86+
* @return string
87+
*/
88+
public function getRenderedBlockContent(string $blockContent) : string
89+
{
90+
return $this->widgetFilter->filter($blockContent);
91+
}
6992
}

0 commit comments

Comments
 (0)