Skip to content
Snippets Groups Projects
Select Git revision
  • c968b425990f6964099f6c2df7b1c84010f5403c
  • develop default protected
  • 1.3 protected
  • 1.1
  • 1.2 protected
  • 1.0
  • 13-export-cli-command
  • 1.7.0
  • 1.6.0
  • 1.5.0
  • 1.4.3
  • 1.4.2
  • 1.4.1
  • 1.4.0
  • 1.3.7
  • 1.3.6
  • 1.3.5
  • 1.3.4
  • 1.3.3
  • 1.3.2
  • 1.3.1
  • 1.3.0
  • 1.1.4
  • 1.2.5
  • 1.2.4
  • 1.2.3
  • 1.0.6
27 results

RenderChangedBlockList.php

Blame
  • 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;
        }
    }