public function testDefaultImage() { $this->assertNull($this->service->getDefaultArticleImage(self::ARTICLE_NUMBER)); $this->service->addArticleImage(self::ARTICLE_NUMBER, new LocalImage('first')); $this->assertContains('first', $this->service->getDefaultArticleImage(self::ARTICLE_NUMBER)->getPath()); $this->assertTrue($this->service->getDefaultArticleImage(self::ARTICLE_NUMBER)->isDefault()); $image = $this->service->addArticleImage(self::ARTICLE_NUMBER, new LocalImage('second')); $this->service->setDefaultArticleImage(self::ARTICLE_NUMBER, $image); $this->assertTrue($image->isDefault()); $this->assertContains('second', $this->service->getDefaultArticleImage(self::ARTICLE_NUMBER)->getPath()); }
/** * Get article renditions * * @param int $articleNumber * @return array */ public function getArticleRenditions($articleNumber) { try { $articleRenditions = $this->orm->getRepository('Newscoop\\Image\\ArticleRendition')->findBy(array('articleNumber' => (int) $articleNumber)); } catch (\Exception $e) { $this->createSchemaIfMissing($e); $articleRenditions = array(); } $defaultArticleImage = $this->imageService->getDefaultArticleImage($articleNumber); return new ArticleRenditionCollection($articleNumber, $articleRenditions, $defaultArticleImage ? $defaultArticleImage->getImage() : null); }