Xpressengine\Media\Handlers\ImageHandler::make PHP Метод

make() публичный Метод

media 객체로 반환
public make ( File $file, array $addInfo = [] ) : Image
$file Xpressengine\Storage\File file instance
$addInfo array additional information
Результат Xpressengine\Media\Models\Image
    public function make(File $file, array $addInfo = [])
    {
        if ($this->isAvailable($file->mime) !== true) {
            throw new NotAvailableException();
        }
        $image = $this->createModel($file);
        if (!$image->meta) {
            list($width, $height) = $this->extractDimension($image);
            $meta = $image->meta()->create(array_merge(['width' => $width, 'height' => $height], $addInfo));
            $image->setRelation('meta', $meta);
        }
        return $image;
    }

Usage Example

 public function testMakeThrownExceptionWhenGivenFileIsNotAvailable()
 {
     list($storage) = $this->getMocks();
     $instance = new ImageHandler($storage);
     $mockFile = m::mock('Xpressengine\\Storage\\File');
     $mockFile->shouldReceive('getAttribute')->with('mime')->once()->andReturn('text/plain');
     try {
         $instance->make($mockFile);
         $this->assertTrue(false);
     } catch (\Exception $e) {
         $this->assertInstanceOf('Xpressengine\\Media\\Exceptions\\NotAvailableException', $e);
     }
 }