Rev 243 | Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |
<?phpdeclare(strict_types=1);namespace LeadersLinked\Command;use Symfony\Component\Console\Command\Command;use Symfony\Component\Console\Input\InputInterface;use Symfony\Component\Console\Output\OutputInterface;use Laminas\Db\Adapter\AdapterInterface;use LeadersLinked\Cache\CacheInterface;use Laminas\Log\LoggerInterface;use LeadersLinked\Mapper\UserMapper;use LeadersLinked\Mapper\CompanyMapper;use LeadersLinked\Mapper\CompanyUserMapper;use LeadersLinked\Model\User;use LeadersLinked\Model\UserType;use LeadersLinked\Model\CompanyUser;use LeadersLinked\Mapper\FeedMapper;class CheckPreviewPosterForFeedCommand extends Command{/**** @var AdapterInterface*/private $adapter;/**** @var CacheInterface*/private $cache;/**** @var LoggerInterface*/private $logger;/**** @var array*/private $config;/**** @param AdapterInterface $adapter* @param CacheInterface $cache* @param LoggerInterface $logger* @param array $config*/public function __construct($adapter, $cache, $logger, $config){$this->adapter = $adapter;$this->cache = $cache;$this->logger = $logger;$this->config = $config;parent::__construct();}protected function execute(InputInterface $input, OutputInterface $output) : int{$output->writeln('Cargando los feed');$feedMapper = FeedMapper::getInstance($this->adapter);$feeds = $feedMapper->fetchAllTypeVideo();$size = $this->config['leaderslinked.image_sizes.feed_image_size'];foreach($feeds as $feed){$target_path = $this->config['leaderslinked.fullpath.feed'] . $feed->uuid;if(!file_exists($target_path)) {mkdir($target_path, 0755);}$full_video_filename = $target_path . DIRECTORY_SEPARATOR . $feed->file_name;$full_filename_preview = substr($feed->file_name, 0, strrpos($feed->file_name, '.'));$full_filename_preview = $target_path . DIRECTORY_SEPARATOR . $full_filename_preview . '.png';if(!file_exists($full_filename_preview)) {echo 'Procesando el Video ' . PHP_EOL;echo 'UUID : ' . $feed->uuid . PHP_EOL;echo 'Image : ' . $feed->file_image_preview . PHP_EOL;echo 'Video : ' . $feed->file_name . PHP_EOL;echo 'Video Filename : ' . $full_video_filename . PHP_EOL;echo 'Cover Filename : ' . $full_filename_preview . PHP_EOL;@unlink($full_filename_preview);$cmd = "/usr/bin/ffmpeg -i $full_video_filename -frames:v 1 -s $size $full_filename_preview";echo 'CMD = ' . $cmd . PHP_EOL. PHP_EOL;exec($cmd);}$feed->file_image_preview = basename($full_filename_preview);$feedMapper->update($feed);}$output->writeln('Fin del proceso');return 0;}}