-
-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathCronJobController.php
More file actions
33 lines (25 loc) · 869 Bytes
/
CronJobController.php
File metadata and controls
33 lines (25 loc) · 869 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
declare(strict_types=1);
namespace Shapecode\Bundle\CronBundle\Controller;
use Shapecode\Bundle\CronBundle\Command\CronRunCommand;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\StringInput;
use Symfony\Component\Console\Output\BufferedOutput;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\KernelInterface;
final readonly class CronJobController
{
public function __construct(
private KernelInterface $kernel,
) {
}
public function __invoke(): Response
{
$application = new Application($this->kernel);
$application->setAutoExit(false);
$input = new StringInput(CronRunCommand::NAME);
$output = new BufferedOutput();
$application->run($input, $output);
return new Response($output->fetch());
}
}