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

Provider.php

Blame
  • AddPageCommand.php 1.85 KiB
    <?php
    declare(strict_types=1);
    
    namespace Firegento\ContentProvisioning\Model\Console;
    
    use Firegento\ContentProvisioning\Model\Command\ApplyPageEntry;
    use Firegento\ContentProvisioning\Model\Query\GetPageEntryByKey;
    use Firegento\ContentProvisioning\Model\Query\GetPageEntryByKeyFactory;
    use Symfony\Component\Console\Command\Command;
    use Symfony\Component\Console\Input\InputArgument;
    use Symfony\Component\Console\Input\InputInterface;
    use Symfony\Component\Console\Output\OutputInterface;
    
    class AddPageCommand extends Command
    {
        const ARG_PAGE_KEY = 'key';
    
        /**
         * @var GetPageEntryByKey
         */
        private $getPageEntryByKeyFactory;
    
        /**
         * @var ApplyPageEntry
         */
        private $applyPageEntry;
    
        /**
         * @param GetPageEntryByKeyFactory $getPageEntryByKey
         * @param ApplyPageEntry $applyPageEntry
         * @param string|null $name
         */
        public function __construct(
            GetPageEntryByKeyFactory $getPageEntryByKeyFactory,
            ApplyPageEntry $applyPageEntry,
            string $name = null
        ) {
            parent::__construct($name);
            $this->getPageEntryByKeyFactory = $getPageEntryByKeyFactory;
            $this->applyPageEntry           = $applyPageEntry;
        }
    
        /**
         * {@inheritdoc}
         */
        protected function execute(InputInterface $input, OutputInterface $output)
        {
            $key = $input->getArgument(self::ARG_PAGE_KEY);
            $page = $this->getPageEntryByKeyFactory->create()->get($key);
            $this->applyPageEntry->execute($page);
        }
    
        /**
         * {@inheritdoc}
         */
        protected function configure()
        {
            $this->setName('content-provisioning:page:apply');
            $this->setDescription('Add a page by key');
            $this->addArgument(
                self::ARG_PAGE_KEY,
                InputArgument::REQUIRED,
                'The key of the page to apply.'
            );
            parent::configure();
        }
    }