/** * {@inheritdoc} */ protected function doTransform(MediaInterface $media) { $media->setName($media->getBinaryContent()); $path = $this->createQrCode($media); d($path); $media->setBinaryContent($path); parent::doTransform($media); }
public function getProvider() { $resizer = $this->getMock('Sonata\\MediaBundle\\Resizer\\ResizerInterface'); $resizer->expects($this->any())->method('resize')->will($this->returnValue(true)); $resizer->expects($this->any())->method('getBox')->will($this->returnValue(new Box(100, 100))); $adapter = $this->getMock('Gaufrette\\Adapter'); $filesystem = $this->getMock('Gaufrette\\Filesystem', array('get'), array($adapter)); $file = $this->getMock('Gaufrette\\File', array(), array('foo', $filesystem)); $filesystem->expects($this->any())->method('get')->will($this->returnValue($file)); $cdn = new \Sonata\MediaBundle\CDN\Server('/uploads/media'); $generator = new \Sonata\MediaBundle\Generator\DefaultGenerator(); $thumbnail = new FormatThumbnail('jpg'); $size = $this->getMock('Imagine\\Image\\BoxInterface'); $size->expects($this->any())->method('getWidth')->will($this->returnValue(100)); $size->expects($this->any())->method('getHeight')->will($this->returnValue(100)); $image = $this->getMock('Imagine\\Image\\ImageInterface'); $image->expects($this->any())->method('getSize')->will($this->returnValue($size)); $adapter = $this->getMock('Imagine\\Image\\ImagineInterface'); $adapter->expects($this->any())->method('open')->will($this->returnValue($image)); $provider = new ImageProvider('file', $filesystem, $cdn, $generator, $thumbnail, array(), array(), $adapter); $provider->setResizer($resizer); return $provider; }