Skip to content
Snippets Groups Projects

ZERO-162-changes

Open Eduarda Lentz Rodrigues da Silva requested to merge ZERO-162-changes into develop
Compare and Show latest version
16 files
+ 466
86
Compare changes
  • Side-by-side
  • Inline
Files
16
@@ -19,14 +19,15 @@ declare(strict_types=1);
namespace Firegento\ContentProvisioning\Cron;
use Firegento\ContentProvisioning\Model\Console\BlockListCommand;
use Firegento\ContentProvisioning\Model\Query\GetChangedBlockIdentifiers;
use Firegento\ContentProvisioning\Model\Query\GetFilesContentInformation;
use Firegento\ContentProvisioning\Model\RenderChangedBlockList;
use Magento\Framework\Mail\Message;
use Psr\Log\LoggerInterface;
use Magento\Framework\Mail\TransportInterfaceFactory;
use Magento\Framework\App\Config\ScopeConfigInterface;
class InconsistenciesInBlockEmail
class InconsistenciesInCmsBlock
{
public const EMAIL_SUBJECT = "Inconsistencies in CMS block";
@@ -39,11 +40,6 @@ class InconsistenciesInBlockEmail
*/
private LoggerInterface $logger;
/**
* @var BlockListCommand
*/
private BlockListCommand $blockList;
/**
* @var TransportInterfaceFactory
*/
@@ -64,28 +60,41 @@ class InconsistenciesInBlockEmail
*/
private RenderChangedBlockList $renderChangedBlockList;
/**
* @var GetChangedBlockIdentifiers
*/
private GetChangedBlockIdentifiers $getChangedBlockIdentifier;
/**
* @var GetFilesContentInformation
*/
private GetFilesContentInformation $getFilesContentInformation;
/**
* @param LoggerInterface $logger
* @param BlockListCommand $blockList
* @param TransportInterfaceFactory $mailTransportFactory
* @param Message $message
* @param ScopeConfigInterface $scopeConfig
* @param RenderChangedBlockList $renderChangedBlockList
* @param GetFilesContentInformation $getFilesContentInformation
* @param GetChangedBlockIdentifiers $getChangedBlockIdentifier
*/
public function __construct(
LoggerInterface $logger,
BlockListCommand $blockList,
TransportInterfaceFactory $mailTransportFactory,
Message $message,
ScopeConfigInterface $scopeConfig,
RenderChangedBlockList $renderChangedBlockList
RenderChangedBlockList $renderChangedBlockList,
GetFilesContentInformation $getFilesContentInformation,
GetChangedBlockIdentifiers $getChangedBlockIdentifier
) {
$this->logger = $logger;
$this->blockList = $blockList;
$this->mailTransportFactory = $mailTransportFactory;
$this->message = $message;
$this->scopeConfig = $scopeConfig;
$this->renderChangedBlockList = $renderChangedBlockList;
$this->getFilesContentInformation = $getFilesContentInformation;
$this->getChangedBlockIdentifier = $getChangedBlockIdentifier;
}
/**
@@ -96,15 +105,30 @@ class InconsistenciesInBlockEmail
*/
public function execute(): void
{
$changedBlocks = $this->blockList->getChangedEntries();
$files = $this->getFilesContentInformation->execute();
$changedBlocks = $this->getChangedBlockIdentifier->execute($files);
if ($changedBlocks) {
$emailMessage = $this->renderChangedBlockList->getValuesForEmail($changedBlocks);
$emailMessage = $this->getValuesForEmail($changedBlocks);
$this->sendEmail($emailMessage);
} else {
$this->logger->info("No changed blocks found.");
}
}
/**
* Transform array values into a string to be displayed in the email
* @param array $entries
* @return string
*/
public function getValuesForEmail(array $entries): string
{
$entriesList = [];
foreach ($entries as $entry) {
$entriesList[] = "key: " . $entry['key'] . ", identifier: " . $entry['identifier'];
}
return implode(PHP_EOL, $entriesList);
}
/**
* @param string $message
* @return void
Loading