Skip to content

Commit c8f85d2

Browse files
Merge pull request #89 from TheDragonCode/1.x
Added data transformers
2 parents 3d68359 + f083b9b commit c8f85d2

28 files changed

+336
-120
lines changed

config/feeds.php

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,41 @@
22

33
declare(strict_types=1);
44

5+
use DragonCode\LaravelFeed\Transformers\BooleanTransformer;
6+
use DragonCode\LaravelFeed\Transformers\DateTimeTransformer;
7+
8+
/**
9+
* Laravel Feeds configuration
10+
*
11+
* This file defines how feeds are generated and presented, including
12+
* formatting, persistence, scheduling, console UX and value transformers.
13+
* Adjust the options below or override them via environment variables.
14+
*/
515
return [
616
/**
717
* Pretty-print the generated feed output.
818
*
919
* When enabled, the resulting XML/JSON will include indentation and
1020
* human‑friendly formatting. Disable for slightly smaller payload size.
1121
*
12-
* By default, false
22+
* Default: false
1323
*/
1424
'pretty' => (bool) env('FEED_PRETTY', false),
1525

26+
/**
27+
* Output format options.
28+
*/
29+
'formats' => [
30+
/**
31+
* Date/time format used when serializing timestamps to feeds.
32+
* You may use any PHP date format constant, e.g. DATE_ATOM, DATE_RFC3339
33+
* or a custom PHP date() format string.
34+
*
35+
* Default: DATE_ATOM
36+
*/
37+
'date' => DATE_ATOM,
38+
],
39+
1640
/**
1741
* Database table settings used by the package (e.g., for generation logs or state).
1842
*/
@@ -22,11 +46,15 @@
2246
*
2347
* Should match a connection defined in config/database.php under
2448
* the "connections" array.
49+
*
50+
* Default: sqlite
2551
*/
2652
'connection' => env('DB_CONNECTION', 'sqlite'),
2753

2854
/**
2955
* The database table name used by the package.
56+
*
57+
* Default: feeds
3058
*/
3159
'table' => env('FEED_TABLE', 'feeds'),
3260
],
@@ -40,6 +68,8 @@
4068
*
4169
* Controls how frequently a scheduled job may be executed to avoid
4270
* overlapping or excessively frequent runs.
71+
*
72+
* Default: 1440 (24 hours)
4373
*/
4474
'ttl' => (int) env('FEED_SCHEDULE_TTL', 1440),
4575

@@ -48,6 +78,8 @@
4878
*
4979
* When true, tasks will be dispatched to run asynchronously so they do
5080
* not block the current process. Set to false to run in the foreground.
81+
*
82+
* Default: true
5183
*/
5284
'background' => (bool) env('FEED_SCHEDULE_RUN_BACKGROUND', true),
5385
],
@@ -62,8 +94,22 @@
6294
* When set to true, the feed:generate command will display a
6395
* progress bar showing the execution progress.
6496
*
65-
* Default is false.
97+
* Default: false
6698
*/
6799
'progress_bar' => (bool) env('FEED_CONSOLE_PROGRESS_BAR_ENABLED', false),
68100
],
101+
102+
/**
103+
* Transformers convert rich/complex values to simple scalar representations
104+
* suitable for feeds (XML/JSON). Order matters: the first transformer that
105+
* supports the value will handle it.
106+
*
107+
* You may add your own transformers by implementing
108+
* DragonCode\LaravelFeed\Contracts\Transformer and registering the class
109+
* here, or publish a stub via the package's make command if available.
110+
*/
111+
'transformers' => [
112+
DateTimeTransformer::class,
113+
BooleanTransformer::class,
114+
],
69115
];

docs/snippets/advanced-directive-array.xml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
<array_directive>
33

44
<user>
5-
<name>Kayley Hermann</name>
6-
<avatar>https://via.placeholder.com/640x480.png/00aa77?text=eos</avatar>
7-
<avatar>https://via.placeholder.com/640x480.png/00ff66?text=voluptatem</avatar>
8-
<images name="itaque repudiandae quod">https://via.placeholder.com/640x480.png/00ee33?text=qui</images>
9-
<images name="nemo quasi et">https://via.placeholder.com/640x480.png/005555?text=aut</images>
5+
<name>Justen Barrows</name>
6+
<avatar>https://via.placeholder.com/640x480.png/008877?text=reprehenderit</avatar>
7+
<avatar>https://via.placeholder.com/640x480.png/0066aa?text=quasi</avatar>
8+
<images name="et sed consequuntur">https://via.placeholder.com/640x480.png/00bb55?text=ab</images>
9+
<images name="hic porro maiores">https://via.placeholder.com/640x480.png/006666?text=eum</images>
1010
</user>
1111
<user>
12-
<name>Dr. Alek Stamm PhD</name>
13-
<avatar>https://via.placeholder.com/640x480.png/0077dd?text=necessitatibus</avatar>
14-
<avatar>https://via.placeholder.com/640x480.png/00ee00?text=nulla</avatar>
15-
<images name="rerum voluptas est">https://via.placeholder.com/640x480.png/003377?text=id</images>
16-
<images name="velit qui perspiciatis">https://via.placeholder.com/640x480.png/0022bb?text=necessitatibus</images>
12+
<name>Mr. Maximo Brown DDS</name>
13+
<avatar>https://via.placeholder.com/640x480.png/00ddaa?text=velit</avatar>
14+
<avatar>https://via.placeholder.com/640x480.png/0000ee?text=maxime</avatar>
15+
<images name="id officia ut">https://via.placeholder.com/640x480.png/005533?text=eos</images>
16+
<images name="maiores excepturi rerum">https://via.placeholder.com/640x480.png/0000bb?text=ullam</images>
1717
</user>
1818

1919
</array_directive>
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<attributes_directive>
33

4-
<company since="1979"/>
4+
<company since="1998"/>
55
<url>https://example.com</url>
66

77
<user>
8-
<name>Lila Jones</name>
9-
<contact email="lavada04@example.org" phone="555-000-1"/>
8+
<name>Lera Fay</name>
9+
<contact email="vthompson@example.com" phone="555-000-1"/>
1010
</user>
1111
<user>
12-
<name>Denis Hane</name>
13-
<contact email="gibson.maynard@example.com" phone="555-000-2"/>
12+
<name>Ernest Stanton</name>
13+
<contact email="norwood.cronin@example.net" phone="555-000-2"/>
1414
</user>
1515

1616
</attributes_directive>

docs/snippets/advanced-directive-cdata.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
<cdata_directive>
33

44
<user>
5-
<name><![CDATA[<h1>Jazmyne Carroll</h1>]]></name>
6-
<email>qcrona@example.org</email>
5+
<name><![CDATA[<h1>Abe Jenkins</h1>]]></name>
6+
<email>zpredovic@example.net</email>
77
</user>
88
<user>
9-
<name><![CDATA[<h1>Prof. Aida Gusikowski</h1>]]></name>
10-
<email>will.amber@example.org</email>
9+
<name><![CDATA[<h1>Mr. Hayden Stokes II</h1>]]></name>
10+
<email>blind@example.org</email>
1111
</user>
1212

1313
</cdata_directive>

docs/snippets/advanced-directive-mixed.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
<mixed_directive>
33

44
<user>
5-
<name>Jana Purdy</name>
5+
<name>Prof. Giovanni Hessel</name>
66
<some>
77
<first>Foo</first>
8-
<second>greenfelder.karley@example.net</second>
8+
<second>cullen.farrell@example.net</second>
99
</some>
1010
</user>
1111
<user>
12-
<name>Brandt Bernhard</name>
12+
<name>Dr. Remington Torphy</name>
1313
<some>
1414
<first>Foo</first>
15-
<second>king.orlando@example.com</second>
15+
<second>balistreri.erica@example.org</second>
1616
</some>
1717
</user>
1818

docs/snippets/advanced-directive-value.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
<value_directive>
33

44
<user>
5-
<name>Elvie Lowe I</name>
6-
<contact type="email">zwalker@example.org</contact>
5+
<name>Johnathan Moore MD</name>
6+
<contact type="email">jena94@example.net</contact>
77
</user>
88
<user>
9-
<name>Trenton Lindgren DDS</name>
10-
<contact type="email">josefa42@example.com</contact>
9+
<name>Kianna Schimmel I</name>
10+
<contact type="email">garrison65@example.org</contact>
1111
</user>
1212

1313
</value_directive>

docs/snippets/advanced-element-attribute-item.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class AttributeFeedItem extends FeedItem
1111
public function attributes(): array
1212
{
1313
return [
14-
'created_at' => $this->model->created_at->toDateTimeString(),
14+
'created_at' => $this->model->created_at,
1515
];
1616
}
1717
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<attribute>
33

4-
<user created_at="2025-09-05 01:30:20">
4+
<user created_at="2025-09-05T02:09:32+00:00">
55
<id>1</id>
6-
<name>Jarrett Stark</name>
6+
<name>Jeremie Legros</name>
77
</user>
8-
<user created_at="2025-09-05 01:30:20">
8+
<user created_at="2025-09-05T02:09:32+00:00">
99
<id>2</id>
10-
<name>Nathan Shields</name>
10+
<name>Regan Hauck</name>
1111
</user>
1212

1313
</attribute>

docs/snippets/advanced-element-header-footer.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33

44
<user>
55
<id>1</id>
6-
<name>Miss Myrtice Durgan Jr.</name>
6+
<name>Dr. Stuart Raynor II</name>
77
</user>
88
<user>
99
<id>2</id>
10-
<name>Wayne Padberg</name>
10+
<name>Zackery Crona</name>
1111
</user>
1212

1313
</header_footer>

docs/snippets/advanced-element-info-before-false.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66

77
<user>
88
<id>1</id>
9-
<name>Earnest Bashirian Jr.</name>
9+
<name>Austyn Hand I</name>
1010
</user>
1111
<user>
1212
<id>2</id>
13-
<name>Noemi Altenwerth III</name>
13+
<name>Kathleen Dare</name>
1414
</user>
1515

1616
</info_method>

0 commit comments

Comments
 (0)