OpenGraph
class OpenGraph extends GroupedTagBuilder
Properties
| protected bool | $imagesAreDefaults | ||
| protected bool | $videosAreDefaults | ||
| protected bool | $audiosAreDefaults |
Methods
Get the builder key.
Determine whether no properties or media are defined.
Get the dot-notated key this builder occupies in the Head::toArray() result.
Grouped tag builders are represented as an empty array when absent from the Head::toArray() result.
Get the supported route attribute names.
Build Open Graph metadata from a route attribute.
Determine if the builder should render even when no data was set.
Mark all media as fallback values for higher layers.
Resolve a string or string-backed enum value.
Normalize a route attribute value into a list of items.
Create the Open Graph properties and media.
Create Open Graph metadata from named values.
Create Open Graph metadata from an attribute map.
Build Open Graph images from route values.
Build Open Graph videos from route values.
Build Open Graph audio from route values.
Add or replace an image by URL.
Add or replace a video by URL.
Add or replace audio by URL.
Media inherited from the defaults layer is a fallback, so media defined by a higher layer replaces it rather than merging with it.
Determine whether any media is defined.
Get the Open Graph properties, falling back to the page title, description, and canonical URL.
Get the image definitions keyed by URL.
Get nonempty Open Graph properties and media lists.
Set each specified Open Graph property.
Normalize a media definition, omitting unspecified attributes.
Resolve an Open Graph type value.
Resolve an image MIME type.
Render each media item with its associated attributes.
Details
at line 44
static string
key()
Get the builder key.
at line 259
TagBuilder
overlayOn(TagBuilder|null $base)
Overlay properties and media onto the lower layer.
at line 321
bool
isEmpty()
Determine whether no properties or media are defined.
in
TagBuilder at line 32
static string
headArrayKey()
Get the dot-notated key this builder occupies in the Head::toArray() result.
in
GroupedTagBuilder at line 13
static mixed
headArrayDefault()
Grouped tag builders are represented as an empty array when absent from the Head::toArray() result.
at line 54
static array
routeAttributeKeys()
Get the supported route attribute names.
at line 104
static TagBuilder|null
fromRouteAttribute(string $key, mixed $value)
Build Open Graph metadata from a route attribute.
in
TagBuilder at line 66
static bool
rendersWhenEmpty(ResolvedHead $head)
Determine if the builder should render even when no data was set.
at line 283
TagBuilder
asDefaults()
Mark all media as fallback values for higher layers.
at line 366
mixed
toHeadArray(ResolvedHead $head)
Get the resolved Open Graph metadata for the head array.
at line 376
array
toTags(ResolvedHead $head, TagRenderer $tags)
Render Open Graph properties and grouped media tags.
in
TagBuilder at line 100
static protected string|null
string(mixed $value)
Return the value when it is a string.
in
TagBuilder at line 108
static protected string|null
stringOrBackedEnum(mixed $value)
Resolve a string or string-backed enum value.
in
TagBuilder at line 124
static protected bool|null
bool(mixed $value)
Return the value when it is a boolean.
in
TagBuilder at line 132
static protected int|null
int(mixed $value)
Return the value when it is an integer.
in
TagBuilder at line 142
static protected array
items(mixed $value)
Normalize a route attribute value into a list of items.
in
TagBuilder at line 153
static protected array
named(array $values)
Filter an array down to its string-keyed values.
at line 27
__construct(array $properties = [], array $images = [], array $videos = [], array $audios = [])
Create the Open Graph properties and media.
at line 62
static OpenGraph
make(OgType|string|null $type = null, string|null $title = null, string|null $description = null, string|null $url = null, string|null $image = null, string|null $video = null, string|null $audio = null, string|null $siteName = null, string|null $locale = null, string|null $determiner = null)
Create Open Graph metadata from named values.
at line 120
static OpenGraph
fromAttributes(array $values)
Create Open Graph metadata from an attribute map.
at line 139
static OpenGraph
fromImageAttributes(mixed $images)
Build Open Graph images from route values.
at line 166
static OpenGraph
fromVideoAttributes(mixed $videos)
Build Open Graph videos from route values.
at line 193
static OpenGraph
fromAudioAttributes(mixed $audios)
Build Open Graph audio from route values.
at line 217
OpenGraph
image(string $url, string|null $alt = null, int|null $width = null, int|null $height = null, ImageType|string|null $type = null, string|null $secureUrl = null)
Add or replace an image by URL.
at line 233
OpenGraph
video(string $url, string|null $alt = null, int|null $width = null, int|null $height = null, string|null $type = null, string|null $secureUrl = null)
Add or replace a video by URL.
at line 249
OpenGraph
audio(string $url, string|null $type = null, string|null $secureUrl = null)
Add or replace audio by URL.
at line 301
protected array
overlayMedia(array $base, array $overlay, bool $baseIsDefaults)
Media inherited from the defaults layer is a fallback, so media defined by a higher layer replaces it rather than merging with it.
at line 313
protected bool
hasMedia()
Determine whether any media is defined.
at line 332
array
render(string|null $title = null, string|null $description = null, string|null $url = null)
Get the Open Graph properties, falling back to the page title, description, and canonical URL.
at line 356
array
images()
Get the image definitions keyed by URL.
at line 398
protected array
headArray(string|null $title = null, string|null $description = null, string|null $url = null)
Get nonempty Open Graph properties and media lists.
at line 413
protected void
set(array $properties)
Set each specified Open Graph property.
at line 427
static protected array
media(string $url, string|null $alt = null, int|null $width = null, int|null $height = null, string|null $type = null, string|null $secureUrl = null)
Normalize a media definition, omitting unspecified attributes.
at line 448
static protected OgType|string|null
ogType(mixed $value)
Resolve an Open Graph type value.
at line 456
static protected string|null
imageType(mixed $value)
Resolve an image MIME type.
at line 467
protected array
mediaTags(TagRenderer $tags, string $property, array $media)
Render each media item with its associated attributes.