0

So I have a class I have included:

require_once('../../application/libraries/video.php');
$video = new Video();
$url = $video->load_thumb($this->project_id, $this->hash_name);

Problem is that the class doesn't seem to load. So I checked its existance:

if (class_exists('Video'))
{
    $array = get_class_methods('Video');
    die(var_dump($array));
}

Which returns me:

array (size=3)
  0 => string '__construct' (length=11)
  1 => string 'load_url' (length=8)
  2 => string 'load_thumb' (length=10)

So I removed all that die crap and put the original code above back in. No matter what though I can't call load_thumb. If I die $video nothing is returned. No errors no warnings, nothing.

Why does the class not get loaded?

EDIT: Contents of video.php

use TwentyTwenty\QualBoard\IoC; use Intervention\Image\ImageManagerStatic as ImageManager;

class Video
{
    var $CI;
    var $files;

    function __construct()
    {
        $this->files = IoC::resolve('files');
    }

    function load_url ($projectId, $storageName, $width = null, $height = null)
    {
        $file = $this->files->projectVideo($projectId, $storageName, $width, $height);

        if ($file->exists())
        {
            return $file->getLink();
        }

        return null;
    }

    function load_thumb($projectId, $storageName, $width = 400, $height = 400)
    {
        $file = $this->files->projectVideoScreenshot($projectId, $storageName, $width, $height);

        if(!$file->exists())
        {
            $original = $this->files->projectVideoScreenshot($projectId, $storageName);

            if($original->exists())
            {
                $tmpImg = tempnam(TEMP_PATH, 'img');
                $original->saveToFile($tmpImg);

                ImageManager::make($tmpImg)
                    ->resize($width, $height, function ($constraint)
                    {
                        $constraint->aspectRatio();
                        $constraint->upsize();
                    })
                    ->save($tmpImg)
                    ->destroy();

                $newImage = $this->files->projectVideoScreenshot($projectId, $storageName, $width, $height);
                $newImage->loadFromFile($tmpImg);

                return $newImage->getLink();
            }
        }
        else
        {
            return $file->getLink();
        }
        return null;
    }
}
allencoded
  • 7,015
  • 17
  • 72
  • 126

0 Answers0