Пример #1
0
 /**
  * Get cover from source id
  *
  * @param \AnimeDb\Bundle\CatalogBundle\Entity\Item $item
  * @param string $id
  * @param string $type
  *
  * @return boolean
  */
 private function setCover(Item $item, $id, $type)
 {
     $item->setCover(self::NAME . '/' . $id . '/1.jpg');
     return $this->uploadImage($this->getCoverUrl($id, $type), $item);
 }
Пример #2
0
 /**
  * @param Item $item
  * @param Crawler $body
  * @param string $id
  *
  * @return Item
  */
 public function setCover(Item $item, Crawler $body, $id)
 {
     if ($image = $body->filter('picture')->text()) {
         try {
             $image = $this->browser->getImageUrl($image);
             if ($path = parse_url($image, PHP_URL_PATH)) {
                 $ext = pathinfo($path, PATHINFO_EXTENSION);
                 $item->setCover(self::NAME . '/' . $id . '/cover.' . $ext);
                 $this->uploadImageFromUrl($image, $item);
             }
         } catch (\Exception $e) {
             // error while retrieving images is not critical
         }
     }
     return $item;
 }
Пример #3
0
 /**
  * @param Item $item
  * @param array $body
  *
  * @return Item
  */
 public function setCover(Item $item, $body)
 {
     if (!empty($body['image']) && !empty($body['image']['original'])) {
         try {
             if ($path = parse_url($body['image']['original'], PHP_URL_PATH)) {
                 $item->setCover(self::NAME . '/' . $body['id'] . '/cover.' . pathinfo($path, PATHINFO_EXTENSION));
                 $this->uploadImage($this->browser->getHost() . $body['image']['original'], $item);
             }
         } catch (\Exception $e) {
             // error while retrieving images is not critical
         }
     }
     return $item;
 }