Skip to content
This repository has been archived by the owner on Dec 19, 2019. It is now read-only.

Fixed #176 - Show only active CMS Blocks #221

Merged
merged 8 commits into from
Nov 23, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion app/code/Magento/CmsGraphQl/Model/Resolver/Blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ private function getBlocksData(array $blockIdentifiers): array
$blocksData = [];
try {
foreach ($blockIdentifiers as $blockIdentifier) {
$blocksData[$blockIdentifier] = $this->blockDataProvider->getData($blockIdentifier);
$blockData = $this->blockDataProvider->getData($blockIdentifier);
if (!empty($blockData)) {
$blocksData[$blockIdentifier] = $blockData;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to log the fact that some of the requested blocks were not found, please add this to the else.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I provided a little refactoring of this PR
Now blocks data is located in data section, and errors are located in errors section

Also, I removed the logging, because there it’s way to log overflow logfile if I send non-existent block id
And at the same time for the client, there is no information what is the actual error (error is only on the server)

}
} catch (NoSuchEntityException $e) {
throw new GraphQlNoSuchEntityException(__($e->getMessage()), $e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function getData(string $blockIdentifier): array
$block = $this->blockRepository->getById($blockIdentifier);

if (false === $block->isActive()) {
throw new NoSuchEntityException();
return [];
}

$renderedContent = $this->widgetFilter->filter($block->getContent());
Expand Down