getId(), name: $news->getName(), createAt: $news->getCreatedAt()->format('Y-m-d H:i:s'), detailLink: "api/v1/news/" . $news->getId(), description: $news->getPreviewText(), image: $news->getPreviewImage() !== null ? $this->fileFactory->create($news->getPreviewImage()) :null, ); } /** * @param Collection $news * @return DtoCollection */ public function createCollection(Collection $news): DtoCollection { return new DtoCollection( NewsListingElementDto::class, $news->map(function(News $oneNews) { return $this->create($oneNews); }) ->toArray() ); } }