Ejemplo n.º 1
0
 /**
  * 圖片上傳至 Yahoo Api
  * 
  * @param  GoodsPassport $product
  * @param  Session       $session
  * @param  Client        $client
  * @return $this                
  */
 protected function uploadImageFlow(GoodsPassport $product, Session $session, Client $client)
 {
     if (!($img = $product->getImg())) {
         $session->getFlashBag()->add('error', $product->getName() . '還沒有主圖!');
         return false;
     }
     if (!($desimg = $product->getDesImg())) {
         $session->getFlashBag()->add('error', $product->getName() . '還沒有附圖!');
         return false;
     }
     // 切圖片, 把 desimg 切成五張小圖
     $this->get('factory.desimg')->spliceDesImage($desimg);
     $response = $client->uploadImage($product);
     if ($response->Response->Status === 'fail') {
         $session->getFlashBag()->add('error', $product->getName() . '商城圖片更新失敗!:' . json_encode($response));
         return false;
     } else {
         $session->getFlashBag()->add('success', $product->getName() . '商城圖片更新成功!');
         return true;
     }
 }