Page extends Item
Page class. Represents a page in the collection, which can be created from a file or be virtual. Provides methods to manage page properties, variables, and rendering.
Table of Contents
Constants
- SLUGIFY_PATTERN = '/(^\/|[^._a-z0-9\/]|-)+/'
Properties
- $body : string
- $file : SplFileInfo
- $fmVariables : array<string|int, mixed>
- $folder : string
- $frontmatter : string
- $html : string
- $id : string
- $file : SplFileInfo
- Item's identifier.
- $paginator : array<string|int, mixed>
- $path : string
- $properties : array<string|int, mixed>
- $path : string
- Item's properties.
- $rendered : array<string|int, mixed>
- $section : string
- $slug : string
- $subPages : Collection
- $terms : Vocabulary
- $type : Type
- $virtual : bool
- $slugifier : Slugify
- $section : string
Methods
- __construct() : mixed
- __toString() : string
- toString magic method to prevent Twig get_attribute fatal error.
- addRendered() : self
- Add rendered.
- createIdFromFile() : string
- Creates the ID from the file (path).
- getBody() : string|null
- Get body as raw.
- getBodyHtml() : string|null
- Get body as HTML.
- getContent() : string|null
- getFileName() : string|null
- Returns file name, with extension.
- getFilePath() : string|null
- Returns file real path.
- getFmVariables() : array<string|int, mixed>
- Get front matter variables.
- getFolder() : string|null
- Get path without slug.
- getFrontmatter() : string|null
- Get front matter.
- getId() : string
- Returns the item's identifier.
- getIdWithoutLang() : string
- Returns the ID of a page without language.
- getPages() : Collection|null
- Get Subpages.
- getPagination() : array<string|int, mixed>
- Paginator backward compatibility.
- getPaginator() : array<string|int, mixed>
- Get paginator.
- getPath() : string|null
- Get path.
- getPathname() : string|null
- getRendered() : array<string|int, mixed>
- Get rendered.
- getSection() : string|null
- Get section.
- getSlug() : string
- Get slug.
- getTerms() : Vocabulary
- Get vocabulary terms.
- getType() : string
- Get page type.
- getVariable() : mixed|null
- Get a variable.
- getVariables() : array<string|int, mixed>
- Get all variables.
- hasVariable() : bool
- Is variable exists?
- isVirtual() : bool
- Is current page is virtual?
- offsetExists() : bool
- Implements \ArrayAccess.
- offsetGet() : mixed|null
- Implements \ArrayAccess.
- offsetSet() : void
- Implements \ArrayAccess.
- offsetUnset() : void
- Implements \ArrayAccess.
- parse() : self
- Parse file content.
- setBodyHtml() : self
- Set body as HTML.
- setFile() : self
- Set file.
- setFmVariables() : self
- Set front matter (only) variables.
- setFolder() : self
- Set path without slug.
- setId() : self
- Set the item's identifier.
- setPages() : self
- Set Subpages.
- setPaginator() : self
- Set paginator.
- setPath() : self
- Set path.
- setSection() : self
- Set section.
- setSlug() : self
- Set slug.
- setTerms() : self
- Set vocabulary terms.
- setType() : self
- Set page type.
- setVariable() : self
- Set a variable.
- setVariables() : self
- Set an array as variables.
- setVirtual() : self
- Set virtual status.
- slugify() : string
- Turns a path (string) into a slug (URI).
- toArray() : array<string|int, mixed>
- Returns properties as array.
- unSection() : self
- Unset section.
- unVariable() : self
- Unset a variable.
- filterBool() : bool|mixed
- Cast "boolean" string (or array of strings) to boolean.
Constants
SLUGIFY_PATTERN
public
mixed
SLUGIFY_PATTERN
= '/(^\/|[^._a-z0-9\/]|-)+/'
Properties
$body
protected
string
$body
Body before conversion.
$file
protected
SplFileInfo
$file
$fmVariables
protected
array<string|int, mixed>
$fmVariables
= []
Front matter before conversion.
$folder
protected
string
$folder
$frontmatter
protected
string
$frontmatter
$html
protected
string
$html
Body after conversion.
$id
Item's identifier.
protected
string
$id
$paginator
protected
array<string|int, mixed>
$paginator
= []
$path
protected
string
$path
path = folder + slug.
$properties
Item's properties.
protected
array<string|int, mixed>
$properties
= []
$rendered
protected
array<string|int, mixed>
$rendered
= []
Output, by format
$section
protected
string
$section
$slug
protected
string
$slug
$subPages
protected
Collection
$subPages
Subpages of a list page.
$terms
protected
Vocabulary
$terms
Terms of a vocabulary.
$type
protected
Type
$type
Type
$virtual
protected
bool
$virtual
True if page is not created from a file.
$slugifier
private
static Slugify
$slugifier
Methods
__construct()
public
__construct(string $id) : mixed
Parameters
- $id : string
__toString()
toString magic method to prevent Twig get_attribute fatal error.
public
__toString() : string
Return values
stringaddRendered()
Add rendered.
public
addRendered(array<string|int, mixed> $rendered) : self
Parameters
- $rendered : array<string|int, mixed>
Return values
selfcreateIdFromFile()
Creates the ID from the file (path).
public
static createIdFromFile(SplFileInfo $file) : string
Parameters
- $file : SplFileInfo
Return values
stringgetBody()
Get body as raw.
public
getBody() : string|null
Return values
string|nullgetBodyHtml()
Get body as HTML.
public
getBodyHtml() : string|null
Return values
string|nullgetContent()
public
getContent() : string|null
Tags
Return values
string|nullgetFileName()
Returns file name, with extension.
public
getFileName() : string|null
Return values
string|nullgetFilePath()
Returns file real path.
public
getFilePath() : string|null
Return values
string|nullgetFmVariables()
Get front matter variables.
public
getFmVariables() : array<string|int, mixed>
Return values
array<string|int, mixed>getFolder()
Get path without slug.
public
getFolder() : string|null
Return values
string|nullgetFrontmatter()
Get front matter.
public
getFrontmatter() : string|null
Return values
string|nullgetId()
Returns the item's identifier.
public
getId() : string
Return values
stringgetIdWithoutLang()
Returns the ID of a page without language.
public
getIdWithoutLang() : string
Return values
stringgetPages()
Get Subpages.
public
getPages() : Collection|null
Return values
Collection|nullgetPagination()
Paginator backward compatibility.
public
getPagination() : array<string|int, mixed>
Return values
array<string|int, mixed>getPaginator()
Get paginator.
public
getPaginator() : array<string|int, mixed>
Return values
array<string|int, mixed>getPath()
Get path.
public
getPath() : string|null
Return values
string|nullgetPathname()
public
getPathname() : string|null
Tags
Return values
string|nullgetRendered()
Get rendered.
public
getRendered() : array<string|int, mixed>
Return values
array<string|int, mixed>getSection()
Get section.
public
getSection() : string|null
Return values
string|nullgetSlug()
Get slug.
public
getSlug() : string
Return values
stringgetTerms()
Get vocabulary terms.
public
getTerms() : Vocabulary
Return values
VocabularygetType()
Get page type.
public
getType() : string
Return values
stringgetVariable()
Get a variable.
public
getVariable(string $name[, mixed|null $default = null ]) : mixed|null
Parameters
- $name : string
-
Name of the variable
- $default : mixed|null = null
-
Default value
Return values
mixed|nullgetVariables()
Get all variables.
public
getVariables() : array<string|int, mixed>
Return values
array<string|int, mixed>hasVariable()
Is variable exists?
public
hasVariable(string $name) : bool
Parameters
- $name : string
-
Name of the variable
Return values
boolisVirtual()
Is current page is virtual?
public
isVirtual() : bool
Return values
booloffsetExists()
Implements \ArrayAccess.
public
offsetExists(mixed $offset) : bool
Parameters
- $offset : mixed
Attributes
- #[ReturnTypeWillChange]
Return values
booloffsetGet()
Implements \ArrayAccess.
public
offsetGet(mixed $offset) : mixed|null
Parameters
- $offset : mixed
Attributes
- #[ReturnTypeWillChange]
Return values
mixed|nulloffsetSet()
Implements \ArrayAccess.
public
offsetSet(mixed $offset, mixed $value) : void
Parameters
- $offset : mixed
- $value : mixed
Attributes
- #[ReturnTypeWillChange]
offsetUnset()
Implements \ArrayAccess.
public
offsetUnset(mixed $offset) : void
Parameters
- $offset : mixed
Attributes
- #[ReturnTypeWillChange]
parse()
Parse file content.
public
parse() : self
Return values
selfsetBodyHtml()
Set body as HTML.
public
setBodyHtml(string $html) : self
Parameters
- $html : string
Return values
selfsetFile()
Set file.
public
setFile(SplFileInfo $file) : self
Parameters
- $file : SplFileInfo
Return values
selfsetFmVariables()
Set front matter (only) variables.
public
setFmVariables(array<string|int, mixed> $variables) : self
Parameters
- $variables : array<string|int, mixed>
Return values
selfsetFolder()
Set path without slug.
public
setFolder(string $folder) : self
Parameters
- $folder : string
Return values
selfsetId()
Set the item's identifier.
public
setId(string $id) : self
Parameters
- $id : string
Return values
selfsetPages()
Set Subpages.
public
setPages(Collection $subPages) : self
Parameters
- $subPages : Collection
Return values
selfsetPaginator()
Set paginator.
public
setPaginator(array<string|int, mixed> $paginator) : self
Parameters
- $paginator : array<string|int, mixed>
Return values
selfsetPath()
Set path.
public
setPath(string $path) : self
Parameters
- $path : string
Return values
selfsetSection()
Set section.
public
setSection(string $section) : self
Parameters
- $section : string
Return values
selfsetSlug()
Set slug.
public
setSlug(string $slug) : self
Parameters
- $slug : string
Return values
selfsetTerms()
Set vocabulary terms.
public
setTerms(Vocabulary $terms) : self
Parameters
- $terms : Vocabulary
Return values
selfsetType()
Set page type.
public
setType(string $type) : self
Parameters
- $type : string
Return values
selfsetVariable()
Set a variable.
public
setVariable(string $name, mixed $value) : self
Parameters
- $name : string
-
Name of the variable
- $value : mixed
-
Value of the variable
Tags
Return values
selfsetVariables()
Set an array as variables.
public
setVariables(array<string|int, mixed> $variables) : self
Parameters
- $variables : array<string|int, mixed>
Tags
Return values
selfsetVirtual()
Set virtual status.
public
setVirtual(bool $virtual) : self
Parameters
- $virtual : bool
Return values
selfslugify()
Turns a path (string) into a slug (URI).
public
static slugify(string $path) : string
Parameters
- $path : string
Return values
stringtoArray()
Returns properties as array.
public
toArray() : array<string|int, mixed>
Return values
array<string|int, mixed>unSection()
Unset section.
public
unSection() : self
Return values
selfunVariable()
Unset a variable.
public
unVariable(string $name) : self
Parameters
- $name : string
-
Name of the variable
Return values
selffilterBool()
Cast "boolean" string (or array of strings) to boolean.
private
filterBool(mixed &$value) : bool|mixed
Parameters
- $value : mixed
-
Value to filter