com\setasign\SetaFramework\View\Helper

HtmlHead Class HtmlHead

File: /SetaFramework/src/View/Helper/HtmlHead.php

ViewHelper to add & set head data

Class hierarchy

Implements

Summary

Properties

$css

private array<array<string, null|string>> HtmlHead::$css = array()

Variable for paths to CSS files

$cssOrder

private string[] HtmlHead::$cssOrder = array()

Variable for the order of CSS files

$custom

private array<string, true> HtmlHead::$custom = array()

$javascript

private array<array{path: string, attributes: array<string|int, null|string>}> HtmlHead::$javascript = array()

Variable for paths to JavaScripts

$link

private array<array<string, null|string>> HtmlHead::$link = array()

Variable for link tags

$meta

private array<array<string, null|string>> HtmlHead::$meta = array()

Variable for Meta tags

$title

private ?string HtmlHead::$title

The title


Methods

__toString()

public HtmlHead::__toString (
void
): string

Overrides the __toString method Returns all set information as HTML tags in their special appearance for each type

addCss()

public HtmlHead::addCss (
string $path,
?string $media = null,
array<string, string> $attributes = array ( )
): self

Adds a path of a CSS file

Parameters
$path : string
 
$media : ?string
 
$attributes : array<string, string>
 

addCustom()

public HtmlHead::addCustom (
string $value
): self

Note: This will not be escaped by default!

Parameters
$value : string
 

addJs()

public HtmlHead::addJs (
string $path,
array<string, string> $attributes = array ( )
): self

Adds a JavaScript path

Parameters
$path : string
 
$attributes : array<string, string>
 
Exceptions

Throws \InvalidArgumentException

addLink()

public HtmlHead::addLink (
array<string, string> $values
): self

Adds an entry to the $link array if the entry with a name already exists, it is overwritten

Parameters
$values : array<string, string>
 

addMeta()

public HtmlHead::addMeta (
array<string, string> $values
): self

Adds an entry to the $meta array if the entry with a name already exists, it is overwritten

Parameters
$values : array<string, string>
 

getCssString()

private HtmlHead::getCssString (
void
): string

getJsString()

private HtmlHead::getJsString (
void
): string

getLinkString()

private HtmlHead::getLinkString (
void
): string

getMetaString()

private HtmlHead::getMetaString (
void
): string

getTitle()

public HtmlHead::getTitle (
void
): ?string

Returns the title

Return Values

The Title is a string. If not set, null will be returned.

hasJs()

public HtmlHead::hasJs (
string $path,
array<string, string> $attributes = array ( )
): bool
Parameters
$path : string
 
$attributes : array<string, string>
 
Exceptions

Throws \InvalidArgumentException

prependCss()

public HtmlHead::prependCss (
string $path,
?string $media = null,
array<string, string> $attributes = array ( ),
?string $beforePath = null
): self

Prepends a path of a CSS file before an other If the path to prepend before doesn't exist an exception is thrown

Parameters
$path : string
 
$media : ?string
 
$attributes : array<string, string>
 
$beforePath : ?string
 
Exceptions

Throws \InvalidArgumentException

prependJs()

public HtmlHead::prependJs (
string $path,
?string $beforePath = null,
array<string, string> $attributes = array ( )
): self

Prepends a JavaScript path before an other.

If the path is already registered

Parameters
$path : string
 
$beforePath : ?string
 
$attributes : array<string, string>
 
Exceptions

Throws \InvalidArgumentException If the path to prepend before doesn't exist

setTitle()

public HtmlHead::setTitle (
string $title
): self

Sets the title

Parameters
$title : string