Skip to content
Snippets Groups Projects
BaseCommand.php 884 B
Newer Older
  • Learn to ignore specific revisions
  • <?php
    
    namespace LakeDrops\Component\Composer;
    
    use Composer\Command\BaseCommand as ComposerBaseCommand;
    use Symfony\Component\Console\Input\InputInterface;
    use Symfony\Component\Console\Output\OutputInterface;
    
    /**
    
    jurgenhaas's avatar
    jurgenhaas committed
     * Base class for Composer commands to easily initialize the handler.
    
     *
     * @package LakeDrops\Component\Composer
     */
    abstract class BaseCommand extends ComposerBaseCommand implements BaseCommandInterface {
    
      /**
       * The handler object to do the real work then.
       *
       * @var \LakeDrops\Component\Composer\BaseHandlerInterface
       */
    
    jurgenhaas's avatar
    jurgenhaas committed
      protected BaseHandlerInterface $handler;
    
    
      /**
       * {@inheritdoc}
       */
    
      protected function execute(InputInterface $input, OutputInterface $output): int {
    
        $class = $this->getHandlerClass();
    
    jurgenhaas's avatar
    jurgenhaas committed
        $this->handler = new $class($this->requireComposer(), $this->getIO());
    
        $this->handler->setInput($input);