resq/src/Command/CountTotalPendingWarrantySerialFilesCommand.php

54 lines
1.3 KiB
PHP

<?php
namespace App\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Doctrine\ORM\EntityManagerInterface;
use App\Entity\WarrantySerialQueue;
class CountTotalPendingWarrantySerialFilesCommand extends Command
{
protected $em;
public function __construct(EntityManagerInterface $em)
{
$this->em = $em;
parent::__construct();
}
protected function configure()
{
$this->setName('warrantyserial:count')
->setDescription('Count number of pending warranty serial files.')
->setHelp('Count number of pending warranty serial files.');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$em = $this->em;
$status = 'pending';
$db = $em->getConnection();
$ws_query_sql = 'SELECT COUNT(*) AS total FROM warranty_serial_queue
WHERE status = :status';
$ws_query_stmt = $db->prepare($ws_query_sql);
$ws_query_stmt->bindValue('status', $status);
$ws_results = $ws_query_stmt->executeQuery();
$results = $ws_results->fetchAssociative();
$output->write($results['total']);
return 0;
}
}