Guides

DirectiveSourceLocation
in package

FinalYes

Static facts about where in the source a directive was written -- captured at parse time since createNode() has no access to BlockContext/ DocumentParserContext itself. Covers two needs:

  • Logging: file/line, built from the project-wide "logger information" convention (BlockContext, DocumentParserContext, ParserContext, DocumentNode, ...), which is a plain array by necessity -- it ultimately feeds PSR-3's LoggerInterface, whose $context parameter is a plain array -- but that leaves a directive with no indication of which keys actually exist. This narrows it to the three keys that convention ever actually sets.
  • Resolving asset-relative paths (images, includes) written in the directive's own data: the directory containing the current document, safe to snapshot once because -- unlike e.g. the code-block default language -- it's fixed for a document's entire parse, never mutated mid-document.

Table of Contents

Properties

$currentLine  : string|null
$documentDirectory  : string|null
$file  : string|null
$lineNumber  : int|null

Methods

__construct()  : mixed
fromLoggerInformation()  : self
toLoggerInformation()  : array<string, int|string>
The plain array PSR-3's LoggerInterface::warning()/error() expects as $context.

Properties

Methods

__construct()

public __construct([string|null $file = null ][, int|null $lineNumber = null ][, string|null $currentLine = null ][, string|null $documentDirectory = null ]) : mixed
Parameters
$file : string|null = null
$lineNumber : int|null = null
$currentLine : string|null = null
$documentDirectory : string|null = null

fromLoggerInformation()

public static fromLoggerInformation(array<string, int|string> $loggerInformation[, string|null $documentDirectory = null ]) : self
Parameters
$loggerInformation : array<string, int|string>
$documentDirectory : string|null = null
Return values
self

toLoggerInformation()

The plain array PSR-3's LoggerInterface::warning()/error() expects as $context.

public toLoggerInformation() : array<string, int|string>
Return values
array<string, int|string>
On this page

Search results