v2.0.0
Upgrading from 1.0 to 2.0
SeoService
The clear
Method
The clear
method has been renamed to a more consistent clearStructs
method.
- seo()->clear();
+ seo()->clearStructs();
The render
Method
The render
method now returns a RenderConductor
which implements the Renderable
, Htmlable
and Arrayable
interfaces instead of a HtmlString
.
/** @var $content string */
- $content = (string) seo()->render();
+ $content = seo()->render()->toHtml();
You can still use {{ seo()->render() }}
in Blade templates.
/** @var $content array */
- $content = seo()->renderContentsArray();
+ $content = seo()->render()->toArray();
/** @var $content Illuminate\Support\HtmlString */
- $content = seo()->render();
+ $content = seo()->render()->build();
Structs
The defaults
Method
The romanzipp\Seo\Structs\Struct::defaults() method now has a return type of void
.
class CustomStruct extends Struct
{
- public static function defaults(Struct $struct)
+ public static function defaults(Struct $struct): void
{
$struct->addAttribute('name', 'custom');
}
}
Fluent Setters
All fluent setter methods now share the same return type of romanzipp\Seo\Structs\Struct
.
use romanzipp\Seo\Structs\Struct;
class CustomStruct extends Meta
{
- public function property($value = null, bool $escape = true): self
+ public function property($value = null, bool $escape = true): Struct
{
$this->addAttribute('property', 'custom:' . $value, $escape);
return $this;
}
}
Laravel-Mix
The filter
and reject
Methods
Both filter
and reject
methods in the Laravel-Mix integration have been replaced with a more general map
method.
seo()
->mix()
- ->filter(function ($path, $url) {
- // ...
- })
- ->reject(function ($path, $url) {
- // ...
- });
+ ->map(static function (ManifestAsset $asset): ?ManifestAsset {
+ // ...
+ });
The rel
Method
The rel
setter for the Laravel-Mix integration has been removed.
seo()
->mix()
- ->rel('preload');
+ ->map(static function (ManifestAsset $asset): ?ManifestAsset {
+ $asset->rel = 'preload';
+ return $asset;
+ });
The getAssets
Method
The MixManifestConductor::getAssets()
method now returns an array of type ManifestAsset[]
.