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
4 files
+ 70
71
Compare changes
  • Side-by-side
  • Inline
Files
4
@@ -2,18 +2,32 @@
declare(strict_types=1);
/**
* Copyright (c) 2024 TechDivision GmbH
* All rights reserved
*
* This product includes proprietary software developed at TechDivision GmbH, Germany
* For more information see https://www.techdivision.com/
*
* To obtain a valid license for using this software please contact us at
* license@techdivision.com
*
* @copyright Copyright (c) 2024 TechDivision GmbH (https://www.techdivision.com)
* @author TechDivision Team Zero <zero@techdivision.com>
* @link https://www.techdivision.com/
*/
namespace Firegento\ContentProvisioning\Model\Console;
use Firegento\ContentProvisioning\Model\Query\GetBlockEntryList as GetBlockEntryList;
use Firegento\ContentProvisioning\Model\Query\GetChangedBlocksIdentifier;
use Firegento\ContentProvisioning\Model\Query\GetFilesContentInformation;
use Firegento\ContentProvisioning\Model\RenderChangedBlockList;
use Magento\Framework\Exception\LocalizedException;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Firegento\ContentProvisioning\Model\Query\GetContentProvisioningFiles;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -27,11 +41,6 @@ class BlockListCommand extends Command
*/
private GetBlockEntryList $getAllBlockEntries;
/**
* @var GetContentProvisioningFiles
*/
private GetContentProvisioningFiles $getContentProvisioningFiles;
/**
* @var GetChangedBlocksIdentifier
*/
@@ -42,22 +51,27 @@ class BlockListCommand extends Command
*/
private RenderChangedBlockList $renderChangedBlockList;
/**
* @var GetFilesContentInformation
*/
private GetFilesContentInformation $GetFilesContentInformation;
/**
* @param GetBlockEntryList $getAllBlockEntries
* @param GetContentProvisioningFiles $getContentProvisioningFiles
* @param GetFilesContentInformation $getFilesContentInformation
* @param GetChangedBlocksIdentifier $getChangedBlocksIdentifier
* @param RenderChangedBlockList $renderChangedBlockList
* @param string|null $name
*/
public function __construct(
GetBlockEntryList $getAllBlockEntries,
GetContentProvisioningFiles $getContentProvisioningFiles,
GetFilesContentInformation $getFilesContentInformation,
GetChangedBlocksIdentifier $getChangedBlocksIdentifier,
RenderChangedBlockList $renderChangedBlockList,
string $name = null
) {
$this->getAllBlockEntries = $getAllBlockEntries;
$this->getContentProvisioningFiles = $getContentProvisioningFiles;
$this->GetFilesContentInformation = $getFilesContentInformation;
$this->getChangedBlocksIdentifier = $getChangedBlocksIdentifier;
$this->renderChangedBlockList = $renderChangedBlockList;
parent::__construct($name);
@@ -104,41 +118,7 @@ class BlockListCommand extends Command
*/
public function getChangedEntries(): ?array
{
$files = $this->getContentProvisioningFiles->execute();
return $this->getChangedBlocksIdentifier->execute($this->getBlockInformation($files));
}
/**
* Return array with block information from content_provisioning file
* @param array $files
* @return array
* @throws \Exception
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
*/
public function getBlockInformation(array $files): array
{
$results = [];
foreach ($files as $fileName => $fileContent) {
try {
$xml = new \SimpleXMLElement($fileContent);
foreach ($xml->block as $block) {
$stores = (string)(isset($block->stores->store) && $block->stores->store->attributes() ?
$block->stores->store->attributes()->code : null);
$results[] = [
'identifier' => (string)$block['identifier'],
'key' => (string)$block['key'],
'content' => (string)$block->content,
'stores' => $stores,
'is_active' => (string)$block['active'] ? 'yes' : 'no',
'is_maintained' => (string)$block['maintained'] ? 'yes' : 'no',
'title' => $block->title
];
}
} catch (LocalizedException $e) {
error_log($e->getMessage());
}
}
return $results;
$files = $this->GetFilesContentInformation->execute();
return $this->getChangedBlocksIdentifier->execute($files);
}
}
Loading