Skip to content
Snippets Groups Projects
ChangedBlockDataProvider.php 1.91 KiB
Newer Older
<?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\ViewModel;

use Firegento\ContentProvisioning\Model\Query\GetDbBlockIds;
use Symfony\Component\Console\Helper\Table;
use Firegento\ContentProvisioning\Model\DTO\ChangedBlockDto;
use Symfony\Component\Console\Output\OutputInterface;
class ChangedBlockDataProvider
{
    /**
     * @var GetDbBlockIds
     */
    private GetDbBlockIds $getDbBlockIds;

    public function __construct(
        GetDbBlockIds $getDbBlockIds
    ) {
        $this->getDbBlockIds = $getDbBlockIds;
    }

    /**
     * Delivery table data
     * @param ChangedBlockDto[] $entries
     * @param OutputInterface $output
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
    public function execute(OutputInterface $output, array $entries): void
    {
        $table = new Table($output);
        $table->setHeaders(['Key', 'Identifier', 'Stores', 'Maintained', 'Active', 'Title', 'in DB (IDs)']);

        foreach ($entries as $entry) {
            $rowData = [
                $entry->getKey(),
                $entry->getIdentifier(),
                $entry->getStores(),
                $entry->getIsMaintained(),
                $entry->getIsActive(),
                $entry->getTitle(),
                $this->getDbBlockIds->execute($entry->getKey())
            ];

            $table->addRow($rowData);