Skip to content

Commit 13e0d59

Browse files
Added a page of documentation for presets
1 parent c07f2f9 commit 13e0d59

File tree

5 files changed

+63
-3
lines changed

5 files changed

+63
-3
lines changed

docs/laravel-feeds.tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
<toc-element topic="directives.topic" />
2525
<toc-element topic="eloquent.topic" />
2626
<toc-element topic="location.topic" />
27+
<toc-element topic="presets.topic" />
2728
<toc-element topic="events.topic" />
2829
</toc-element>
2930
<toc-element toc-title="Receipts">

docs/snippets/presets-all.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use DragonCode\LaravelFeed\Presets\InstagramFeedPreset;
6+
use DragonCode\LaravelFeed\Presets\RssFeedPreset;
7+
use DragonCode\LaravelFeed\Presets\SitemapFeedPreset;
8+
use DragonCode\LaravelFeed\Presets\YandexFeedPreset;
9+
10+
class ProductFeed extends InstagramFeedPreset {}
11+
class ProductFeed extends YandexFeedPreset {}
12+
class ProductFeed extends SitemapFeedPreset {}
13+
class ProductFeed extends RssFeedPreset {}

docs/topics/presets.topic

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE topic
3+
SYSTEM "https://resources.jetbrains.com/writerside/1.0/xhtml-entities.dtd">
4+
<topic
5+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6+
xsi:noNamespaceSchemaLocation="https://resources.jetbrains.com/writerside/1.0/topic.v2.xsd"
7+
title="Presets" id="presets">
8+
9+
<link-summary>Generate feeds quickly with built-in presets (Instagram, Yandex, Sitemap, RSS)</link-summary>
10+
<card-summary>Generate feeds quickly with built-in presets (Instagram, Yandex, Sitemap, RSS)</card-summary>
11+
<web-summary>Generate feeds quickly with built-in presets (Instagram, Yandex, Sitemap, RSS)</web-summary>
12+
13+
<show-structure depth="3" />
14+
15+
<p>
16+
You can quickly create feeds using the out-of-the-box presets:
17+
</p>
18+
19+
<list>
20+
<li><code>DragonCode\LaravelFeed\Presets\InstagramFeedPreset</code></li>
21+
<li><code>DragonCode\LaravelFeed\Presets\YandexFeedPreset</code></li>
22+
<li><code>DragonCode\LaravelFeed\Presets\SitemapFeedPreset</code></li>
23+
<li><code>DragonCode\LaravelFeed\Presets\RssFeedPreset</code></li>
24+
</list>
25+
26+
<p>
27+
Create a feed class manually or via the
28+
<code>%command-make%</code> console command and extend the preset you need. For example:
29+
</p>
30+
31+
<code-block lang="php" src="presets-all.php" include-lines="5-" />
32+
33+
<p>
34+
Then implement the two required methods — <code>builder</code> and <code>item</code>. For example:
35+
</p>
36+
37+
<code-block lang="php" src="receipt-instagram-feed.php" include-lines="5-" />
38+
39+
<p>
40+
If needed, you can also override the <code>filename</code> method to change the output file name.
41+
</p>
42+
43+
<p>
44+
Technically, preset classes are the same as the base
45+
<code>Feed</code> class, except they include the service-specific logic they target, including how information blocks and items are built.
46+
</p>
47+
</topic>

workbench/app/Feeds/Docs/ReceiptInstagramFeed.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function item(Model $model): FeedItem
2424
->title($model->title)
2525
->description($model->description)
2626
->brand($model->brand)
27-
->url(route('products.show', $model->slug))
27+
->url($model->url)
2828
->price($model->price)
2929
->image(Arr::first($model->images))
3030
->images($model->images)

workbench/app/Feeds/Docs/ReceiptYandexFeed.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use Workbench\App\Models\Product;
1313

1414
use function config;
15-
use function route;
1615

1716
class ReceiptYandexFeed extends YandexFeedPreset
1817
{
@@ -34,7 +33,7 @@ public function info(): FeedInfo
3433
public function item(Model $model): FeedItem
3534
{
3635
return parent::item($model)
37-
->url(route('products.show', $model->slug))
36+
->url($model->url)
3837
->barcode($model->article)
3938
->title($model->title)
4039
->description($model->description)

0 commit comments

Comments
 (0)