1 | <?php |
||
2 | |||
3 | namespace Astrotomic\Stancy\Factories; |
||
4 | |||
5 | use Astrotomic\Stancy\Contracts\FeedFactory as FeedFactoryContract; |
||
6 | use Astrotomic\Stancy\Contracts\PageFactory as PageFactoryContract; |
||
7 | use Spatie\Sheets\Facades\Sheets; |
||
8 | use Spatie\Sheets\Repository as SheetRepository; |
||
9 | use Spatie\Sheets\Sheet; |
||
10 | |||
11 | class FeedFactory implements FeedFactoryContract |
||
12 | { |
||
13 | /** @var PageFactoryContract */ |
||
14 | protected $pageFactory; |
||
15 | |||
16 | 3 | public function __construct(PageFactoryContract $pageFactory) |
|
17 | { |
||
18 | 3 | $this->pageFactory = $pageFactory; |
|
19 | 3 | } |
|
20 | |||
21 | 1 | public function makeFromSheetCollection(SheetRepository $collection): array |
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
22 | { |
||
23 | return $collection->all()->map(function (Sheet $sheet) { |
||
24 | 1 | return $this->pageFactory->makeFromSheet($sheet); |
|
25 | 1 | })->all(); |
|
26 | } |
||
27 | |||
28 | 1 | public function makeFromSheetCollectionName(string $name): array |
|
0 ignored issues
–
show
|
|||
29 | { |
||
30 | 1 | $collection = Sheets::collection($name); |
|
31 | |||
32 | 1 | return $this->makeFromSheetCollection($collection); |
|
33 | } |
||
34 | } |
||
35 |