/** * singleton pattern * * @return Text2Image */ public static function getInstance() { if (!isset(self::$instance) || !self::$instance instanceof Text2Image) { self::$instance = new Text2Image(); } return self::$instance; }
/** * Create multiple versions of the image and then passes these versions directly to ->execute() * * @param number $numberOfImages */ public function pushTestImage2API($numberOfImages = 2) { if (strlen($this->imageUrl) && $this->itemId > 0) { for ($i = 1; $i <= $numberOfImages; $i++) { $base64 = Text2Image::getInstance()->setImageUrl($this->imageUrl)->pushText2Image('#' . $i, 20, 110, 96)->getFileBase64(); $fileEnding = Text2Image::getInstance()->getFileEnding(); if (strlen($base64)) { $oPlentySoapObject_FileBase64Encoded = new PlentySoapObject_FileBase64Encoded(); $oPlentySoapObject_FileBase64Encoded->FileData = $base64; $oPlentySoapObject_FileBase64Encoded->FileEnding = $fileEnding; $oPlentySoapObject_FileBase64Encoded->FileName = 'plentymarkets_testimage_' . $this->itemId . '_' . $i; $oPlentySoapObject_ItemImage = new PlentySoapObject_ItemImage(); $oPlentySoapObject_ItemImage->ImageData = $oPlentySoapObject_FileBase64Encoded; $oPlentySoapObject_ItemImage->Availability = 1; $oPlentySoapObject_ItemImage->Position = $i - 1; $this->oPlentySoapRequest_AddItemsImage = new PlentySoapRequest_AddItemsImage(); $this->oPlentySoapRequest_AddItemsImage->Image = $oPlentySoapObject_ItemImage; $this->oPlentySoapRequest_AddItemsImage->ItemID = $this->itemId; $this->execute(); } else { $this->getLogger()->crit(__FUNCTION__ . ' I did not get base64 data.'); } } } else { $this->getLogger()->crit(__FUNCTION__ . ' I miss some data - itemId:' . $this->itemId . ' imageUrl:' . $this->imageUrl); } }