WordPress

Briefly unavailable for scheduled maintenance.
Check back in a some hours.
403WebShell
403Webshell
Server IP : 38.242.244.58  /  Your IP : 216.73.217.126
Web Server : Apache/2.4.41 (Ubuntu)
System : Linux vmi1486879.contaboserver.net 5.4.0-166-generic #183-Ubuntu SMP Mon Oct 2 11:28:33 UTC 2023 x86_64
User : root ( 0)
PHP Version : 7.4.3-4ubuntu2.19
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/html/sura/src/Command/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/sura/src/Command/RegenerateVideoSizesCommand.php
<?php

namespace App\Command;

use App\Entity\Stock;
use App\Repository\StockRepository;
use App\Service\VideoHelper;
use Doctrine\ORM\EntityManagerInterface;
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;

class RegenerateVideoSizesCommand extends Command
{
    protected static $defaultName = 'app:regenerate-video-sizes';

    private $videoHelper;
    private $em;

    public function __construct(VideoHelper $videoHelper, EntityManagerInterface $em)
    {
        parent::__construct();
        $this->videoHelper = $videoHelper;
        $this->em = $em;
    }

    protected function configure()
    {
        $this
            ->setDescription('Regenerate video sizes for approved videos')
            ->addOption('stockId',null,InputOption::VALUE_OPTIONAL,"The stock ID of the video to process")
            ->addOption('suraId',null,InputOption::VALUE_OPTIONAL,"The Sura ID of the video to process. This will be overriden if stock id option is entered")
        ;
    }

    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $io = new SymfonyStyle($input, $output);

        /**@var $stockRepo StockRepository**/
        $stockRepo = $this->em->getRepository(Stock::class);

        $stocks = $stockRepo->createQueryBuilder('s')
            ->join('s.type', 'type')
            ->where('type.id = :typeId')
            ->setParameters(['typeId'=>5])
            ->getQuery()
            ->getResult();

        if ($input->getOption('suraId') && !$input->getOption('stockId')) {
            $sura_id = $input->getOption('suraId');
            if (is_numeric($sura_id) && $stock = $stockRepo->findOneBy(['suraID' => $sura_id])){
                if ($stock->getType()->getId() == 5){
                    $stocks = [$stock];
                }else{
                    $io->error("Stock found, but it's not a video!");
                    return 0;
                }
            }else{
                $io->error("Enter a valid sura Id. No stock found!");
                return 0;
            }
        }


        if ($stock_id = $input->getOption('stockId')) {
            if (is_numeric($stock_id) && $stock = $stockRepo->find($stock_id)){
                if ($stock->getType()->getId() == 5){
                    $stocks = [$stock];
                }else{
                    $io->error("Stock found, but it's not a video!");
                    return 0;
                }
            }else{
                $io->error("Enter a valid stock Id. No stock found!");
                return 0;
            }
        }

        if (count($stocks) > 0){
            $io->note(sprintf("Beginning regeneration of %s video file(s)", count($stocks)));

            /**
             * @var Stock $stock
             */
            foreach ($stocks as $stock){
                try {
                    $this->videoHelper->generateVideoSizes($stock,false);
                    $io->note(sprintf("Regenerated stock: %s, SuraId: %s", $stock->getId(), $stock->getSuraId()));
                }catch (\Exception $exception){
                    $io->error(sprintf("Error regenerating stock: %s, SuraId: %s. Exception: %s", $stock->getId(), $stock->getSuraId(), $exception->getMessage()));
                }
            }
        }else{
            $io->note("No video files to process.");
        }

        $io->success('You have a new command! Now make it your own! Pass --help to see your options.');

        return 0;
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit