Select Git revision
RenderChangedBlockList.php
RenderChangedBlockList.php 2.55 KiB
<?php
declare(strict_types=1);
/**
* Copyright (c) 2025 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) 2025 TechDivision GmbH (https://www.techdivision.com)
* @author TechDivision Team Zero <zero@techdivision.com>
* @link https://www.techdivision.com/
*/
namespace Firegento\ContentProvisioning\Model;
use Firegento\ContentProvisioning\Model\Query\GetExistsInDbValueByKey;
use Symfony\Component\Console\Helper\Table;
class RenderChangedBlockList
{
/**
* @var GetExistsInDbValueByKey
*/
private GetExistsInDbValueByKey $getExistsInDbValue;
public function __construct(
GetExistsInDbValueByKey $getExistsInDbValue
) {
$this->getExistsInDbValue = $getExistsInDbValue;
}
/**
* Render table with CMS block information
* @param InputInterface $input
* @param OutputInterface $output
* @param array $entries
* @return void
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function renderTable(InputInterface $input, OutputInterface $output, array $entries)
{
$table = new Table($output);
$table->setHeaders(['Key', 'Identifier', 'Stores', 'Maintained', 'Active', 'Title', 'in DB (IDs)']);
foreach ($entries as $entry) {
$table->addRow(
[
$entry['key'],
$entry['identifier'],
(!empty($entry['stores'])) ? (is_array($entry['stores']) ?
implode(', ', $entry['stores']) : $entry['stores']) : "null",
$entry['is_maintained'],
$entry['is_active'],
$entry['title'],
$this->getExistsInDbValue->execute($entry['key']),
]
);
}
$table->render($output);
}
/**
* Transform array values into a string to be displayed in the email
* @param array $entries
* @return string
*/
public function renderValuesForEmail(array $entries): string
{
$entriesList = [];
foreach ($entries as $entry) {
$entriesList[] = "key: " . $entry['key'];
$entriesList[] = "identifier: " . $entry['identifier'];
}
$separatedEntries = implode(", ", $entriesList);
return $separatedEntries;
}
}