class Element implements LocatableFileInterface (View source)

An object-oriented wrapper for core element functionality, with support for events, locators, controllers and elements.

Properties

protected string $element

The element name.

protected array $variables

The list of variables to be "set" in the view.

protected string|null $pkgHandle

The handle of the package defining this element.

protected FileLocator $locator

The locator instance to be used to get the actual PHP file that implements the view.

protected Page|null $page

The page where the element will be rendered.

protected ElementController|null $controller

The element controller.

protected array $controllerArguments

The arguments to be used when calling the constructor of the element controller.

Methods

__construct(string $element)

Element constructor.

populateFromArguments(array $args)

Initialize this instance.

getLocator()

Get the locator instance to be used to get the actual PHP file that implements the view.

string
getElementPath()

Get the path of the element view (relative to the webroot).

bool
exists()

Check if the element view file exists.

getFileLocatorRecord()

No description

$this
set(string $key, mixed $value)

Set a variable to be used in the view.

getElementController()

Get the element controller.

render()

Render the element.

string
getContents()

No description

getBaseLocator()

No description

createLocator()

No description

Details

__construct(string $element)

Element constructor.

Parameters

string $element

the element name

populateFromArguments(array $args)

Initialize this instance.

Parameters

array $args

the first element will be discarded; other arguments can be of type:

  • Page: the page where the element will be rendered
  • array: the arguments to be used when calling the constructor of the element controller
  • string: the handle of the package defining this element

FileLocator getLocator()

Get the locator instance to be used to get the actual PHP file that implements the view.

Return Value

FileLocator

string getElementPath()

Get the path of the element view (relative to the webroot).

Return Value

string

bool exists()

Check if the element view file exists.

Return Value

bool

Record getFileLocatorRecord()

No description

$this set(string $key, mixed $value)

Set a variable to be used in the view.

Parameters

string $key

The name of the variable

mixed $value

The value of the variable

Return Value

$this

ElementController|null getElementController()

Get the element controller.

Return Value

ElementController|null

render()

Render the element.

string getContents()

No description

Return Value

string

protected FileLocator getBaseLocator()

No description

Return Value

FileLocator

protected FileLocator createLocator()

No description

Return Value

FileLocator