class Navigation

Traits

Adds event related features to any class.

Properties

array $vars from  ViewMaker
array $viewPath from  ViewMaker
array $layoutPath from  ViewMaker
array $partialPath from  ViewMaker
string $layout from  ViewMaker
bool $suppressLayout from  ViewMaker
protected $viewFileExtension from  ViewMaker
protected array $emitterSingleEvents from  EventEmitter
protected array $emitterEvents from  EventEmitter
protected array $emitterEventSorted from  EventEmitter
protected $navItems
protected $mainItems
protected $navItemsLoaded
protected $navContextItemCode
protected $navContextParentCode
protected $callbacks

Methods

getViewPath($view, $viewPath = null)

No description

guessViewFileExtension($path)

No description

string
guessViewPath(string $suffix = '', bool $isPublic = false)

Guess the package path from a specified class.

mixed
makeLayout(string $name = null, array $vars = [], bool $throwException = true)

Render a layout.

string
makeView(string $view)

Loads a view with the name specified.

mixed
makePartial(string $partial, array $vars = [], bool $throwException = true)

Render a partial file contents located in the views or partial folder.

string
makeFileContent(string $filePath, array $extraParams = [])

Includes a file path using output buffering.

compileFileContent($filePath)

No description

void
handleViewException(Exception $e, int $obLevel)

Handle a view exception.

array
gatherViewData($data)

Get the data bound to the view instance.

bindEvent(string $event, callable $callback, int $priority = 0)

Create a new event binding.

bindEventOnce(string $event, callable $callback)

Create a new event binding that fires once only

void
emitterEventSortEvents(string $eventName)

Sort the listeners for a given event by priority.

unbindEvent(string $event = null)

Destroys an event binding.

string|array
fireEvent(string $event, array $params = [], bool $halt = false)

Fire an event and call the listeners.

mixed
fireSystemEvent(string $event, array $params = [], bool $halt = true)

Fires a combination of local and global events. The first segment is removed from the event name locally and the local object is passed as the first argument to the event globally. Halting is also enabled by default.

__construct($path = null)

No description

setContext($itemCode, $parentCode = null)

No description

getNavItems()

No description

isCollapsed()

No description

getVisibleNavItems()

No description

isActiveNavItem($code)

No description

getMainItems()

No description

render($partial)

No description

addNavItem($itemCode, array $options = [], $parentCode = null)

No description

mergeNavItem($itemCode, array $options = [], $parentCode = null)

No description

removeNavItem($itemCode, $parentCode = null)

No description

loadItems()

No description

filterPermittedNavItems($items)

No description

registerMainItems($definitions = null)

No description

registerNavItems($definitions = null, $parent = null)

No description

registerNavItem($code, $item, $parent = null)

No description

registerCallback(callable $callback)

Registers a callback function that defines navigation items.

Details

in ViewMaker at line 50
getViewPath($view, $viewPath = null)

No description

Parameters

$view
$viewPath

in ViewMaker at line 78
guessViewFileExtension($path)

No description

Parameters

$path

in ViewMaker at line 98
string guessViewPath(string $suffix = '', bool $isPublic = false)

Guess the package path from a specified class.

Parameters

string $suffix

An extra path to attach to the end

bool $isPublic

Return Value

string

in ViewMaker at line 119
mixed makeLayout(string $name = null, array $vars = [], bool $throwException = true)

Render a layout.

Parameters

string $name

Specifies the layout name. If this parameter is omitted, the $layout property will be used.

array $vars

Parameter variables to pass to the view.

bool $throwException

Throw an exception if the layout is not found

Return Value

mixed

The layout contents, or false.

Exceptions

SystemException

in ViewMaker at line 147
string makeView(string $view)

Loads a view with the name specified.

Applies layout if its name is provided by the parent object. The view file must be situated in the views directory, and has the extension "htm" or "php".

Parameters

string $view

Specifies the view name, without extension. Eg: "index".

Return Value

string

in ViewMaker at line 171
mixed makePartial(string $partial, array $vars = [], bool $throwException = true)

Render a partial file contents located in the views or partial folder.

Parameters

string $partial

The view to load.

array $vars

Parameter variables to pass to the view.

bool $throwException

Throw an exception if the partial is not found.

Return Value

mixed

Partial contents or false if not throwing an exception.

Exceptions

SystemException

in ViewMaker at line 199
string makeFileContent(string $filePath, array $extraParams = [])

Includes a file path using output buffering.

Ensures that vars are available.

Parameters

string $filePath

Absolute path to the view file.

array $extraParams

Parameters that should be available to the view.

Return Value

string

in ViewMaker at line 235
compileFileContent($filePath)

No description

Parameters

$filePath

in ViewMaker at line 256
protected void handleViewException(Exception $e, int $obLevel)

Handle a view exception.

Parameters

Exception $e
int $obLevel

Return Value

void

in ViewMaker at line 271
protected array gatherViewData($data)

Get the data bound to the view instance.

Parameters

$data

Return Value

array

in EventEmitter at line 36
EventEmitter bindEvent(string $event, callable $callback, int $priority = 0)

Create a new event binding.

Parameters

string $event

The event name to listen for

callable $callback

The callback to call when emitted

int $priority

Return Value

EventEmitter

in EventEmitter at line 52
EventEmitter bindEventOnce(string $event, callable $callback)

Create a new event binding that fires once only

Parameters

string $event

The event name

callable $callback

Return Value

EventEmitter

in EventEmitter at line 66
protected void emitterEventSortEvents(string $eventName)

Sort the listeners for a given event by priority.

Parameters

string $eventName

Return Value

void

in EventEmitter at line 84
EventEmitter unbindEvent(string $event = null)

Destroys an event binding.

Parameters

string $event

Event to destroy

Return Value

EventEmitter

in EventEmitter at line 124
string|array fireEvent(string $event, array $params = [], bool $halt = false)

Fire an event and call the listeners.

Parameters

string $event

Event name

array $params

Event parameters

bool $halt

Halt after first non-null result

Return Value

string|array

Collection of event results / Or single result (if halted)

in EventEmitter at line 178
mixed fireSystemEvent(string $event, array $params = [], bool $halt = true)

Fires a combination of local and global events. The first segment is removed from the event name locally and the local object is passed as the first argument to the event globally. Halting is also enabled by default.

For example:

$this->fireSystemEvent('admin.form.myEvent', ['my value']);

Is equivalent to:

$this->fireEvent('form.myEvent', ['myvalue'], true);

Event::fire('admin.form.myEvent', [$this, 'myvalue'], true);

Parameters

string $event

Event name

array $params

Event parameters

bool $halt

Halt after first non-null result

Return Value

mixed

at line 28
__construct($path = null)

No description

Parameters

$path

at line 33
setContext($itemCode, $parentCode = null)

No description

Parameters

$itemCode
$parentCode

at line 39
getNavItems()

No description

at line 47
isCollapsed()

No description

at line 52
getVisibleNavItems()

No description

at line 77
isActiveNavItem($code)

No description

Parameters

$code

at line 88
getMainItems()

No description

at line 96
render($partial)

No description

Parameters

$partial

at line 105
addNavItem($itemCode, array $options = [], $parentCode = null)

No description

Parameters

$itemCode
array $options
$parentCode

at line 134
mergeNavItem($itemCode, array $options = [], $parentCode = null)

No description

Parameters

$itemCode
array $options
$parentCode

at line 146
removeNavItem($itemCode, $parentCode = null)

No description

Parameters

$itemCode
$parentCode

at line 156
loadItems()

No description

at line 187
filterPermittedNavItems($items)

No description

Parameters

$items

at line 201
registerMainItems($definitions = null)

No description

Parameters

$definitions

at line 212
registerNavItems($definitions = null, $parent = null)

No description

Parameters

$definitions
$parent

at line 229
registerNavItem($code, $item, $parent = null)

No description

Parameters

$code
$item
$parent

at line 252
registerCallback(callable $callback)

Registers a callback function that defines navigation items.

The callback function should register permissions by calling the manager's registerNavItems() function. The manager instance is passed to the callback function as an argument. Usage:

  Template::registerCallback(function($manager){
      $manager->registerNavItems([...]);
  });

Parameters

callable $callback

A callable function.