Skip to content
Merged
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,19 @@ composer require gpslab/sitemap
```php
// URLs on your site
$urls = [
new Url(
Url::create(
'/', // loc
new \DateTimeImmutable('2020-06-15 13:39:46'), // lastmod
ChangeFrequency::always(), // changefreq
10 // priority
),
new Url(
Url::create(
'/contacts.html',
new \DateTimeImmutable('2020-05-26 09:28:12'),
ChangeFrequency::monthly(),
7
),
new Url('/about.html'),
Url::create('/about.html'),
];

// file into which we will write a sitemap
Expand Down Expand Up @@ -182,7 +182,7 @@ region.
```php
// URLs on your site
$urls = [
new Url(
Url::create(
'/english/page.html',
new \DateTimeImmutable('2020-06-15 13:39:46'),
ChangeFrequency::monthly(),
Expand All @@ -195,7 +195,7 @@ $urls = [
'x-default' => '/english/page.html',
]
),
new Url(
Url::create(
'/deutsch/page.html',
new \DateTimeImmutable('2020-06-15 13:39:46'),
ChangeFrequency::monthly(),
Expand All @@ -208,7 +208,7 @@ $urls = [
'x-default' => '/english/page.html',
]
),
new Url(
Url::create(
'/schweiz-deutsch/page.html',
new \DateTimeImmutable('2020-06-15 13:39:46'),
ChangeFrequency::monthly(),
Expand Down Expand Up @@ -292,19 +292,19 @@ class MySiteUrlBuilder implements UrlBuilder
{
// add URLs on your site
return new \ArrayIterator([
new Url(
Url::create(
'/', // loc
new \DateTimeImmutable('2020-06-15 13:39:46'), // lastmod
ChangeFrequency::always(), // changefreq
10 // priority
),
new Url(
Url::create(
'/contacts.html',
new \DateTimeImmutable('2020-05-26 09:28:12'),
ChangeFrequency::monthly(),
7
),
new Url(
Url::create(
'/about.html',
new \DateTimeImmutable('2020-05-02 17:12:38'),
ChangeFrequency::monthly(),
Expand Down Expand Up @@ -337,15 +337,15 @@ class ArticlesUrlBuilder implements UrlBuilder
$update_at = new \DateTimeImmutable($row['update_at']);
$section_update_at = max($section_update_at, $update_at);

// SmartUrl automatically fills fields that it can
yield new SmartUrl(
// smart URL automatically fills fields that it can
yield Url::createSmart(
sprintf('/article/%d', $row['id']),
$update_at
);
}

// link to section
yield new Url(
yield Url::create(
'/article/',
$section_update_at ?: new \DateTimeImmutable('-1 day'),
ChangeFrequency::daily(),
Expand Down
57 changes: 49 additions & 8 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
Before:

```php
PlainTextSitemapRender::sitemap(string $path, ?\DateTimeInterface $last_modify = null)
$render = PlainTextSitemapRender::sitemap(string $path, ?\DateTimeInterface $last_modify = null)
```

After:

```php
PlainTextSitemapRender::sitemap(Sitemap $sitemap)
$render = PlainTextSitemapRender::sitemap(Sitemap $sitemap)
```

* The `$host` argument in `RenderIndexFileStream::__construct()` was removed.
Expand Down Expand Up @@ -58,31 +58,31 @@

```php
$render = new PlainTextSitemapRender();
$render->url(new Url('https://example.com'));
$render->url(new Url('https://example.com/about'));
$render->url(Url::create('https://example.com'));
$render->url(Url::create('https://example.com/about'));
```

After:

```php
$web_path = 'https://example.com'; // No slash in end of path!
$render = new PlainTextSitemapRender($web_path);
$render->url(new Url('/'));
$render->url(new Url('/about'));
$render->url(Url::create('/'));
$render->url(Url::create('/about'));
```

* The `$priority` in `URL` class was changed from `string` to `int`.

Before:

```php
new Url('/contacts.html', new \DateTimeImmutable('-1 month'), ChangeFrequency::MONTHLY, '0.7');
$url = Url::create('/contacts.html', new \DateTimeImmutable('-1 month'), ChangeFrequency::MONTHLY, '0.7');
```

After:

```php
new Url('/contacts.html', new \DateTimeImmutable('-1 month'), ChangeFrequency::monthly(), 7);
$url = Url::create('/contacts.html', new \DateTimeImmutable('-1 month'), ChangeFrequency::monthly(), 7);
```

* The `CallbackStream` was removed.
Expand Down Expand Up @@ -160,3 +160,44 @@
* The `Stream::BYTE_LIMIT` constants was removed. Use `Limiter::BYTE_LIMIT` instead.
* The return value of `Url::getLocation()` was changed to a `Location` object.
* The return value of `Url::getChangeFrequency()` was changed to a `ChangeFrequency` object.
* The `Url` changed to final.
* The `Url::__construct` require objects as arguments.

Before:

```php
$url = new Url('/contacts.html', new \DateTimeImmutable('-1 month'), ChangeFrequency::MONTHLY, '0.7');
```

After:

```php

$url = Url::create('/contacts.html', new \DateTimeImmutable('-1 month'), ChangeFrequency::MONTHLY, '0.7');
```

Or

```php

$url = new Url(
new Location('/contacts.html'),
new \DateTimeImmutable('-1 month'),
ChangeFrequency::monthly(),
Priority::create(7)
);
```

* The `SmartUrl` was removed.

Before:

```php
$url = new SmartUrl('/article/123');
```

After:

```php
$url = Url::createSmart('/article/123');
```
52 changes: 0 additions & 52 deletions src/Url/SmartUrl.php

This file was deleted.

Loading