49 lines
1.4 KiB
PHP
49 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Command;
|
|
|
|
use Doctrine\ORM\EntityManagerInterface;
|
|
use Symfony\Component\Console\Attribute\AsCommand;
|
|
use Symfony\Component\Console\Command\Command;
|
|
use Symfony\Component\Console\Input\InputArgument;
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
use Symfony\Component\Console\Input\InputOption;
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
|
|
|
#[AsCommand(
|
|
name: 'startup:status',
|
|
description: 'Add a short description for your command',
|
|
)]
|
|
class StartupStatusCommand extends Command
|
|
{
|
|
private EntityManagerInterface $entityManager;
|
|
|
|
public function __construct(EntityManagerInterface $entityManager)
|
|
{
|
|
parent::__construct();
|
|
$this->entityManager = $entityManager;
|
|
}
|
|
|
|
protected function execute(InputInterface $input, OutputInterface $output): int
|
|
{
|
|
$io = new SymfonyStyle($input, $output);
|
|
|
|
$ready = true;
|
|
$messengerTableExists = $this->doesMessengerTableExist();
|
|
|
|
if (false === $messengerTableExists) {
|
|
$ready = false;
|
|
}
|
|
|
|
return (true === $ready) ? Command::SUCCESS : Command::FAILURE;
|
|
}
|
|
|
|
private function doesMessengerTableExist()
|
|
{
|
|
return $this->entityManager->getConnection()
|
|
->createSchemaManager()
|
|
->tablesExist('messenger_messages');
|
|
}
|
|
}
|