class HtmlInjector (View source)

Class for matching HTML elements and injecting text.

Methods

array
getMap()

Get a map of function names to locations. We don't have unique callbacks for all targets, because in practice they end up in about the same location

void
inject(WidgetInterface $widget, Response $response)

No description

string
beforeContent(string $snippet, string $rawHtml)

insert some HTML into the very beginning of HTML / Content.

string
afterContent(string $snippet, string $rawHtml)

insert some HTML into the very end of HTML / Content.

static string
nowhere(string $snippet, string $rawHtml)

Nowhere, don't replace anything.

string
headTagStart(string $snippet, string $rawHtml)

insert some HTML into the start of the head section of an HTML page, right after the tag.

string
headTagEnd(string $snippet, string $rawHtml)

insert some HTML into the head section of an HTML page, right before the tag.

string
bodyTagStart(string $snippet, string $rawHtml)

insert some HTML into the start of the head section of an HTML page, right after the tag.

string
bodyTagEnd(string $snippet, string $rawHtml)

insert some HTML into the body section of an HTML page, right before the tag.

string
htmlTagEnd(string $snippet, string $rawHtml)

insert some HTML into the html section of an HTML page, right before the tag.

string
metaTagsAfter(string $snippet, string $rawHtml)

insert some HTML into the head section of an HTML page.

string
cssTagsAfter(string $snippet, string $rawHtml)

insert some HTML into the head section of an HTML page.

string
cssTagsBefore(string $snippet, string $rawHtml)

insert some HTML before the first CSS include in the page.

string
jsTagsBefore(string $snippet, string $rawHtml)

insert some HTML before the first javascript include in the page.

string
jsTagsAfter(string $snippet, string $rawHtml)

insert some HTML after the last javascript include.

static string
injectBeforeTagStart(string $rawHtml, string $htmlTag, string $injection)

No description

static string
injectAfterTagStart(string $rawHtml, string $htmlTag, string $injection)

No description

static string
injectBeforeTagEnd(string $rawHtml, string $htmlTag, string $injection)

No description

static string
injectAfterTagEnd(string $rawHtml, string $htmlTag, string $injection)

No description

Details

array getMap()

Get a map of function names to locations. We don't have unique callbacks for all targets, because in practice they end up in about the same location

Return Value

array

void inject(WidgetInterface $widget, Response $response)

Parameters

WidgetInterface $widget
Response $response

Return Value

void

protected string beforeContent(string $snippet, string $rawHtml)

insert some HTML into the very beginning of HTML / Content.

Parameters

string $snippet
string $rawHtml

Return Value

string

protected string afterContent(string $snippet, string $rawHtml)

insert some HTML into the very end of HTML / Content.

Parameters

string $snippet
string $rawHtml

Return Value

string

static string nowhere(string $snippet, string $rawHtml)

Nowhere, don't replace anything.

Parameters

string $snippet
string $rawHtml

Return Value

string

protected string headTagStart(string $snippet, string $rawHtml)

insert some HTML into the start of the head section of an HTML page, right after the tag.

Parameters

string $snippet
string $rawHtml

Return Value

string

protected string headTagEnd(string $snippet, string $rawHtml)

insert some HTML into the head section of an HTML page, right before the tag.

Parameters

string $snippet
string $rawHtml

Return Value

string

protected string bodyTagStart(string $snippet, string $rawHtml)

insert some HTML into the start of the head section of an HTML page, right after the tag.

Parameters

string $snippet
string $rawHtml

Return Value

string

protected string bodyTagEnd(string $snippet, string $rawHtml)

insert some HTML into the body section of an HTML page, right before the tag.

Parameters

string $snippet
string $rawHtml

Return Value

string

protected string htmlTagEnd(string $snippet, string $rawHtml)

insert some HTML into the html section of an HTML page, right before the tag.

Parameters

string $snippet
string $rawHtml

Return Value

string

protected string metaTagsAfter(string $snippet, string $rawHtml)

insert some HTML into the head section of an HTML page.

If there is no Metatag anywhere, place it right before end of head.

Parameters

string $snippet
string $rawHtml

Return Value

string

protected string cssTagsAfter(string $snippet, string $rawHtml)

insert some HTML into the head section of an HTML page.

If there is no CSS anywhere, place it right before end of head.

Parameters

string $snippet
string $rawHtml

Return Value

string

protected string cssTagsBefore(string $snippet, string $rawHtml)

insert some HTML before the first CSS include in the page.

If there is no CSS anywhere, place it right after start of head.

Parameters

string $snippet
string $rawHtml

Return Value

string

protected string jsTagsBefore(string $snippet, string $rawHtml)

insert some HTML before the first javascript include in the page.

If there is no JS anywhere, place it right after start of body.

Parameters

string $snippet
string $rawHtml

Return Value

string

protected string jsTagsAfter(string $snippet, string $rawHtml)

insert some HTML after the last javascript include.

If there is no JS anywhere, place it right before end of body.

Parameters

string $snippet
string $rawHtml

Return Value

string

static string injectBeforeTagStart(string $rawHtml, string $htmlTag, string $injection)

Parameters

string $rawHtml
string $htmlTag
string $injection

Return Value

string

static string injectAfterTagStart(string $rawHtml, string $htmlTag, string $injection)

Parameters

string $rawHtml
string $htmlTag
string $injection

Return Value

string

static string injectBeforeTagEnd(string $rawHtml, string $htmlTag, string $injection)

Parameters

string $rawHtml
string $htmlTag
string $injection

Return Value

string

static string injectAfterTagEnd(string $rawHtml, string $htmlTag, string $injection)

Parameters

string $rawHtml
string $htmlTag
string $injection

Return Value

string