mirror of
https://github.com/shlinkio/shlink.git
synced 2025-02-25 18:45:27 -06:00
40 lines
1.2 KiB
PHP
40 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Shlinkio\Shlink\CLI\Command\Db;
|
|
|
|
use Shlinkio\Shlink\CLI\Command\Util\AbstractLockedCommand;
|
|
use Shlinkio\Shlink\CLI\Command\Util\LockedCommandConfig;
|
|
use Shlinkio\Shlink\CLI\Util\ProcessRunnerInterface;
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
use Symfony\Component\Lock\LockFactory;
|
|
use Symfony\Component\Process\PhpExecutableFinder;
|
|
|
|
abstract class AbstractDatabaseCommand extends AbstractLockedCommand
|
|
{
|
|
private ProcessRunnerInterface $processRunner;
|
|
private string $phpBinary;
|
|
|
|
public function __construct(
|
|
LockFactory $locker,
|
|
ProcessRunnerInterface $processRunner,
|
|
PhpExecutableFinder $phpFinder
|
|
) {
|
|
parent::__construct($locker);
|
|
$this->processRunner = $processRunner;
|
|
$this->phpBinary = $phpFinder->find(false) ?: 'php';
|
|
}
|
|
|
|
protected function runPhpCommand(OutputInterface $output, array $command): void
|
|
{
|
|
$command = [$this->phpBinary, ...$command, '--no-interaction'];
|
|
$this->processRunner->run($output, $command);
|
|
}
|
|
|
|
protected function getLockConfig(): LockedCommandConfig
|
|
{
|
|
return LockedCommandConfig::blocking($this->getName());
|
|
}
|
|
}
|