Skip to content
Snippets Groups Projects
Select Git revision
  • 11b2efcce9556b7999fd328fb93d2ed10d0cfb5b
  • 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

BlockInstaller.php

Blame
  • BlockInstaller.php 2.41 KiB
    <?php
    declare(strict_types=1);
    
    namespace Firegento\ContentProvisioning\Model;
    
    use Exception;
    use Firegento\ContentProvisioning\Model\Command\ApplyBlockEntry;
    use Firegento\ContentProvisioning\Model\Command\ApplyMediaFiles;
    use Firegento\ContentProvisioning\Model\Query\GetBlockEntryList;
    use Firegento\ContentProvisioning\Model\Validator\CanApplyBlockEntry;
    use Psr\Log\LoggerInterface;
    
    class BlockInstaller
    {
        /**
         * @var LoggerInterface
         */
        private $logger;
    
        /**
         * @var GetBlockEntryList
         */
        private $getAllBlockEntries;
    
        /**
         * @var CanApplyBlockEntry
         */
        private $canApplyBlockEntry;
    
        /**
         * @var ApplyBlockEntry
         */
        private $applyBlockEntry;
    
        /**
         * @var ApplyMediaFiles
         */
        private $applyMediaFiles;
    
        /**
         * @param LoggerInterface $logger
         * @param GetBlockEntryList $getAllBlockEntries
         * @param CanApplyBlockEntry $canApplyBlockEntry
         * @param ApplyBlockEntry $applyBlockEntry
         * @param ApplyMediaFiles $applyMediaFiles
         */
        public function __construct(
            LoggerInterface $logger,
            GetBlockEntryList $getAllBlockEntries,
            CanApplyBlockEntry $canApplyBlockEntry,
            ApplyBlockEntry $applyBlockEntry,
            ApplyMediaFiles $applyMediaFiles
        ) {
            $this->logger = $logger;
            $this->getAllBlockEntries = $getAllBlockEntries;
            $this->canApplyBlockEntry = $canApplyBlockEntry;
            $this->applyBlockEntry = $applyBlockEntry;
            $this->applyMediaFiles = $applyMediaFiles;
        }
    
        /**
         * Apply all configured CMS page changes
         *
         * @return void
         */
        public function install(): void
        {
            foreach ($this->getAllBlockEntries->get() as $blockEntry) {
                try {
                    if ($this->canApplyBlockEntry->execute($blockEntry)) {