Pimcore\Console\Command\ThumbnailsVideoCommand::execute PHP Метод

execute() защищенный Метод

protected execute ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output )
$input Symfony\Component\Console\Input\InputInterface
$output Symfony\Component\Console\Output\OutputInterface
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        // disable versioning
        Version::disable();
        // get all thumbnails
        $thumbnails = [];
        $list = new Asset\Video\Thumbnail\Config\Listing();
        $items = $list->load();
        foreach ($items as $item) {
            $thumbnails[] = $item->getName();
        }
        $allowedThumbs = [];
        if ($input->getOption("thumbnails")) {
            $allowedThumbs = explode(",", $input->getOption("thumbnails"));
        }
        // get only images
        $conditions = ["type = 'video'"];
        if ($input->getOption("parent")) {
            $parent = Asset::getById($input->getOption("parent"));
            if ($parent instanceof Asset\Folder) {
                $conditions[] = "path LIKE '" . $parent->getRealFullPath() . "/%'";
            } else {
                $this->writeError($input->getOption("parent") . " is not a valid asset folder ID!");
                exit;
            }
        }
        $list = new Asset\Listing();
        $list->setCondition(implode(" AND ", $conditions));
        $total = $list->getTotalCount();
        $perLoop = 10;
        for ($i = 0; $i < ceil($total / $perLoop); $i++) {
            $list->setLimit($perLoop);
            $list->setOffset($i * $perLoop);
            $videos = $list->load();
            foreach ($videos as $video) {
                foreach ($thumbnails as $thumbnail) {
                    if (empty($allowedThumbs) && !$input->getOption("system") || in_array($thumbnail, $allowedThumbs)) {
                        $this->output->writeln("generating thumbnail for video: " . $video->getRealFullPath() . " | " . $video->getId() . " | Thumbnail: " . $thumbnail . " : " . formatBytes(memory_get_usage()));
                        $video->getThumbnail($thumbnail);
                        $this->waitTillFinished($video->getId(), $thumbnail);
                    }
                }
                if ($input->getOption("system")) {
                    $this->output->writeln("generating thumbnail for video: " . $video->getRealFullPath() . " | " . $video->getId() . " | Thumbnail: System Preview : " . formatBytes(memory_get_usage()));
                    $thumbnail = Asset\Video\Thumbnail\Config::getPreviewConfig();
                    $video->getThumbnail($thumbnail);
                    $this->waitTillFinished($video->getId(), $thumbnail);
                }
            }
        }
    }