當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Image::setImageFile方法代碼示例

本文整理匯總了PHP中Magento\Catalog\Helper\Image::setImageFile方法的典型用法代碼示例。如果您正苦於以下問題:PHP Image::setImageFile方法的具體用法?PHP Image::setImageFile怎麽用?PHP Image::setImageFile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Magento\Catalog\Helper\Image的用法示例。


在下文中一共展示了Image::setImageFile方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testGetResizedImageInfo

 /**
  * @param string $imageId
  * @param string $imageFile
  * @param string $baseFile
  * @param string $newFile
  * @param string $destination
  * @param boolean $setImageFile
  * @param boolean $isCached
  * @param boolean $isBaseFilePlaceholder
  * @param array $resizedImageInfo
  * @dataProvider getResizedImageInfoDataProvider
  */
 public function testGetResizedImageInfo($imageId, $imageFile, $baseFile, $newFile, $destination, $setImageFile, $isCached, $isBaseFilePlaceholder, $resizedImageInfo)
 {
     $productMock = $this->getMockBuilder('Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->getMock();
     $productMock->expects($this->any())->method('getData')->with($destination)->willReturn($imageFile);
     $this->image->expects($this->any())->method('setBaseFile')->with($imageFile)->willReturnSelf();
     $this->image->expects($this->once())->method('getBaseFile')->willReturn($baseFile);
     $this->image->expects($this->any())->method('getDestinationSubdir')->willReturn($destination);
     $this->image->expects($this->any())->method('isCached')->willReturn($isCached);
     $this->image->expects($this->any())->method('resize')->willReturnSelf();
     $this->image->expects($this->any())->method('saveFile')->willReturnSelf();
     $this->image->expects($this->once())->method('getResizedImageInfo')->willReturn($resizedImageInfo);
     $this->image->expects($this->any())->method('isBaseFilePlaceholder')->willReturn($isBaseFilePlaceholder);
     $this->image->expects($this->any())->method('getNewFile')->willReturn($newFile);
     $this->prepareAttributes([], $imageId);
     $this->helper->init($productMock, $imageId);
     if ($setImageFile) {
         $this->helper->setImageFile($imageFile);
     }
     $result = $this->helper->getResizedImageInfo();
     $this->assertEquals($resizedImageInfo, $result);
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:33,代碼來源:ImageTest.php

示例2: processImageData

 /**
  * Process image data
  *
  * @param Product $product
  * @param array $imageData
  * @param string $file
  * @return $this
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 protected function processImageData(Product $product, array $imageData, $file)
 {
     $this->imageHelper->init($product, $imageData['id'], $imageData);
     $this->imageHelper->setImageFile($file);
     if (isset($imageData['aspect_ratio'])) {
         $this->imageHelper->keepAspectRatio($imageData['aspect_ratio']);
     }
     if (isset($imageData['frame'])) {
         $this->imageHelper->keepFrame($imageData['frame']);
     }
     if (isset($imageData['transparency'])) {
         $this->imageHelper->keepTransparency($imageData['transparency']);
     }
     if (isset($imageData['constrain'])) {
         $this->imageHelper->constrainOnly($imageData['constrain']);
     }
     if (isset($imageData['background'])) {
         $this->imageHelper->backgroundColor($imageData['background']);
     }
     $this->imageHelper->save();
     return $this;
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:32,代碼來源:Cache.php


注:本文中的Magento\Catalog\Helper\Image::setImageFile方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。