コード例 #1
0
ファイル: WatermarkTest.php プロジェクト: webowy/zend-filter
 /**
  * Basic usage
  *
  * @return void
  */
 public function testInvalidWatermarkType()
 {
     $this->expectException(Watermark\Exception\RuntimeException::class);
     $this->expectExceptionMessage('Watermark is not an instance of AdapterInterface!');
     $filter = new Watermark();
     $filter->filter($this->image);
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 public function filter($value)
 {
     $return = parent::filter($value);
     $imagePath = isset($return['tmp_name']) ? $return['tmp_name'] : $return;
     $watermarkOptions = $this->getWatermark();
     $watermark = new Watermark();
     if (!$watermarkOptions['image'] instanceof Watermark\Adapter\AdapterInterface) {
         $watermarkOptions['image'] = new $watermarkOptions['adapter']($watermarkOptions['image']);
     }
     $watermark->setWatermark($watermarkOptions['image']);
     $watermark->setPosition($watermarkOptions['position']);
     $watermark->setMargins($watermarkOptions['margins']);
     if (!$imagePath instanceof Watermark\Adapter\AdapterInterface) {
         $imagePath = new $watermarkOptions['adapter']($imagePath);
     }
     $watermark->filter($imagePath);
     return $return;
 }