CoreFiles by mySites.guru
SingleCommandApplication.php55 lines, 1,469 bytes, from Joomla_4.0.0-beta5-Beta-Full_Package.zip
Raw History Compare with 4.0.0-beta4
md5
ccf28176bc260a0ebfe8fb9ac4715fa3
sha1
f8eb2a573b980e48db147a99e95ee992624ec7d2
sha256
b92ed3e1e90a77fe73ae655aa496d54db69a0376552a1e716636e2a0a41922b2
<?php

/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <[email protected]>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Console;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

/**
 * @author GrĂ©goire Pineau <[email protected]>
 */
class SingleCommandApplication extends Command
{
    private $version = 'UNKNOWN';
    private $running = false;

    public function setVersion(string $version): self
    {
        $this->version = $version;

        return $this;
    }

    public function run(InputInterface $input = null, OutputInterface $output = null): int
    {
        if ($this->running) {
            return parent::run($input, $output);
        }

        // We use the command name as the application name
        $application = new Application($this->getName() ?: 'UNKNOWN', $this->version);
        // Fix the usage of the command displayed with "--help"
        $this->setName($_SERVER['argv'][0]);
        $application->add($this);
        $application->setDefaultCommand($this->getName(), true);

        $this->running = true;
        try {
            $ret = $application->run($input, $output);
        } finally {
            $this->running = false;
        }

        return $ret ?? 1;
    }
}

The same content is in 2 releases, Joomla 4.0.0-beta4 to 4.0.0-beta5. See them all, or every version of this file.