FeaturedImageFactory
extends PageDataFactory
in package
implements
FeaturedImageSchema
Streamlines the data dynamic construction specific to a HydePHP page.
Simply pass along the data the class needs to run, then access the parsed data using the toArray() method.
Commonly, all data can be set using front matter in the page source file.
However, as all front matter is optional in Hyde, if no front matter is set for the given key, the factory may attempt to generate and discover the values based on the page's contents, as well as the project's overall configuration.
In other words, this is where the magic happens.
Table of Contents
Interfaces
- FeaturedImageSchema
- Front matter schema interfaces are used by various Hyde components to specify what data they provide or contain. They also serve as a convenient way to see the supported front matter properties.
Constants
- SCHEMA = \Hyde\Markdown\Contracts\FrontMatter\SubSchemas\FeaturedImageSchema::FEATURED_IMAGE_SCHEMA
- The front matter properties supported by this factory.
Properties
- $altText : string|null
- $authorName : string|null
- $authorUrl : string|null
- $copyrightText : string|null
- $licenseName : string|null
- $licenseUrl : string|null
- $source : string
- $titleText : string|null
- $filePath : string|null
- $matter : FrontMatter
Methods
- __construct() : mixed
- make() : FeaturedImage
- toArray() : array{source: string, altText: string|null, titleText: string|null, authorName: string|null, authorUrl: string|null, copyrightText: string|null, licenseName: string|null, licenseUrl: string|null}
- Get the generated data as an associative array.
- getStringMatter() : string|null
- makeSource() : string
- normalizeLocalImagePath() : string
Constants
SCHEMA
The front matter properties supported by this factory.
public
final array<string, string|array<string|int, mixed>>
SCHEMA
= \Hyde\Markdown\Contracts\FrontMatter\SubSchemas\FeaturedImageSchema::FEATURED_IMAGE_SCHEMA
Properties
$altText read-only
protected
string|null
$altText
$authorName read-only
protected
string|null
$authorName
$authorUrl read-only
protected
string|null
$authorUrl
$copyrightText read-only
protected
string|null
$copyrightText
$licenseName read-only
protected
string|null
$licenseName
$licenseUrl read-only
protected
string|null
$licenseUrl
$source read-only
protected
string
$source
$titleText read-only
protected
string|null
$titleText
$filePath read-only
private
string|null
$filePath
= null
$matter read-only
private
FrontMatter
$matter
Methods
__construct()
public
__construct(FrontMatter $matter[, string|null $filePath = null ]) : mixed
Parameters
- $matter : FrontMatter
- $filePath : string|null = null
make()
public
static make(FrontMatter $matter[, string|null $filePath = null ]) : FeaturedImage
Parameters
- $matter : FrontMatter
- $filePath : string|null = null
Return values
FeaturedImagetoArray()
Get the generated data as an associative array.
public
toArray() : array{source: string, altText: string|null, titleText: string|null, authorName: string|null, authorUrl: string|null, copyrightText: string|null, licenseName: string|null, licenseUrl: string|null}
Return values
array{source: string, altText: string|null, titleText: string|null, authorName: string|null, authorUrl: string|null, copyrightText: string|null, licenseName: string|null, licenseUrl: string|null}getStringMatter()
protected
getStringMatter(string $key) : string|null
Parameters
- $key : string
Return values
string|nullmakeSource()
protected
makeSource() : string
Return values
stringnormalizeLocalImagePath()
protected
static normalizeLocalImagePath(string $path) : string
Parameters
- $path : string