Skip to content

Commit 1c2fd93

Browse files
committed
BC break: item can now have only 1 enclosure now
1 parent 603013e commit 1c2fd93

5 files changed

Lines changed: 7 additions & 28 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Version 0.16.0-dev
44
- possible BC break: Source no longer extends stdClass
55
- added validation for e-mail address for channel's managingEditor and webMaster and item's author
66
- added validation for url
7+
- BC break: item can now have only 1 enclosure now
78

89
Version 0.15.1
910
- fixed isPermaLink attribute name for element guid

‎RELEASE_NOTES‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ A new version of Rss is out. lastBuildDate and pubDate for channel now have be t
22

33
Channel's managingEditor and webMaster and item's author now has to be e-mail addresses; the validation is not perfect but should work in most cases, please report any false positives and negatives that you find. There is basic validation of url for various elements, for now it only support http and https protocols.
44

5+
An item can now have only 1 enclosure now. It is not explicitly said in the specification but it is the intent.
6+
57
It is now possible to use special types for elements in BaseElement::registerElements().
68

79
For complete list of changes since previous version, see CHANGELOG.md.

‎src/EnclosuresCollection.php‎

Lines changed: 0 additions & 24 deletions
This file was deleted.

‎src/Extensions/RssCore.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use Nexendrie\Rss\CategoriesCollection;
99
use Nexendrie\Rss\Category;
1010
use Nexendrie\Rss\Cloud;
11-
use Nexendrie\Rss\EnclosuresCollection;
11+
use Nexendrie\Rss\Enclosure;
1212
use Nexendrie\Rss\Extensions\ElementTypes\EmailAddress;
1313
use Nexendrie\Rss\Extensions\ElementTypes\NonNegativeInteger;
1414
use Nexendrie\Rss\Extensions\ElementTypes\Url;
@@ -140,7 +140,7 @@ public function configureItemOptions(OptionsResolver $resolver, Generator $gener
140140
$resolver->setAllowedTypes("link", "string");
141141
$resolver->setAllowedValues("link", (new Url())->getValidator());
142142
$resolver->setDefined([
143-
"pubDate", "author", "comments", "guid", "source", "categories", "enclosures",
143+
"pubDate", "author", "comments", "guid", "source", "categories", "enclosure",
144144
]);
145145
$resolver->setAllowedTypes("pubDate", DateTime::class);
146146
$resolver->setNormalizer(
@@ -161,7 +161,7 @@ static function (Options $options, DateTime $value) use ($generator): GenericEle
161161
);
162162
$resolver->setAllowedTypes("source", Source::class);
163163
$resolver->setAllowedTypes("categories", CategoriesCollection::class);
164-
$resolver->setAllowedTypes("enclosures", EnclosuresCollection::class);
164+
$resolver->setAllowedTypes("enclosure", Enclosure::class);
165165
}
166166

167167
protected function shortenDescription(string $description, int $maxLength): string

‎tests/Nexendrie/Rss/RssChannelItemTest.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function testToXml(): void
2424
$category = new Category("abc");
2525
$data["categories"] = CategoriesCollection::fromArray([$category,]);
2626
$enclosure = new Enclosure("https://example.com/music/test.mp3", 15, "audio/mpeg");
27-
$data["enclosures"] = EnclosuresCollection::fromArray([$enclosure,]);
27+
$data["enclosure"] = $enclosure;
2828
$item = new RssChannelItem($data);
2929
$xml = new \SimpleXMLElement("<test></test>");
3030
$item->toXml($xml, new Generator());

0 commit comments

Comments
 (0)