ModalRegistry
in package
Registry of modal windows kept in the session.
Stores only the data needed to render a modal. The data is removed from the session when the modal closes.
Table of Contents
Constants
- SESSION_SECTION : mixed = 'modalWindows'
Properties
- $debugMode : bool
- $section : SessionSection
- $session : Session
Methods
- __construct() : mixed
- clear() : void
- Clears the whole session section (for debugging and reset).
- closeAllVisible() : void
- Closes all visible modals (use on a non-AJAX request).
- exists() : bool
- Returns whether the modal exists in the registry.
- getAllModals() : array<string, ModalWindowEvent>
- Returns all registered modals.
- getAllTargets() : array<string|int, string>
- Returns all registered targets.
- getModal() : ModalWindowEvent|null
- Returns the `ModalWindowEvent` for the given target.
- getVisibleModals() : array<string, ModalWindowEvent>
- Returns only the visible modals.
- hide() : void
- Marks the modal as invisible but keeps it in the session.
- isVisible() : bool
- Returns whether the modal is visible.
- register() : void
- Registers a new modal.
- remove() : void
- Removes the modal from the session (called on close).
- show() : void
- Marks the modal as visible; an unknown target is ignored.
- update() : void
- Updates an existing modal and keeps its visibility.
- entry() : array<string|int, mixed>|null
- Returns the modal entry from the session (the array stored by `register()`), null when missing.
- log() : void
- Debug logging
Constants
SESSION_SECTION
private
mixed
SESSION_SECTION
= 'modalWindows'
Properties
$debugMode read-only
private
bool
$debugMode
= false
$section
private
SessionSection
$section
$session read-only
private
Session
$session
Methods
__construct()
public
__construct(Session $session[, bool $debugMode = false ]) : mixed
Parameters
- $session : Session
- $debugMode : bool = false
clear()
Clears the whole session section (for debugging and reset).
public
clear() : void
closeAllVisible()
Closes all visible modals (use on a non-AJAX request).
public
closeAllVisible() : void
exists()
Returns whether the modal exists in the registry.
public
exists(string $target) : bool
Parameters
- $target : string
Return values
boolgetAllModals()
Returns all registered modals.
public
getAllModals() : array<string, ModalWindowEvent>
Return values
array<string, ModalWindowEvent>getAllTargets()
Returns all registered targets.
public
getAllTargets() : array<string|int, string>
Return values
array<string|int, string>getModal()
Returns the `ModalWindowEvent` for the given target.
public
getModal(string $target) : ModalWindowEvent|null
Parameters
- $target : string
Return values
ModalWindowEvent|nullgetVisibleModals()
Returns only the visible modals.
public
getVisibleModals() : array<string, ModalWindowEvent>
Return values
array<string, ModalWindowEvent>hide()
Marks the modal as invisible but keeps it in the session.
public
hide(string $target) : void
Parameters
- $target : string
isVisible()
Returns whether the modal is visible.
public
isVisible(string $target) : bool
Parameters
- $target : string
Return values
boolregister()
Registers a new modal.
public
register(ModalWindowEvent $event[, bool $visible = false ]) : void
Parameters
- $event : ModalWindowEvent
-
modal data
- $visible : bool = false
-
whether the modal is visible immediately
remove()
Removes the modal from the session (called on close).
public
remove(string $target) : void
Parameters
- $target : string
show()
Marks the modal as visible; an unknown target is ignored.
public
show(string $target) : void
Parameters
- $target : string
update()
Updates an existing modal and keeps its visibility.
public
update(string $target, ModalWindowEvent $event) : void
Parameters
- $target : string
- $event : ModalWindowEvent
Tags
entry()
Returns the modal entry from the session (the array stored by `register()`), null when missing.
private
entry(string $target) : array<string|int, mixed>|null
Parameters
- $target : string
Return values
array<string|int, mixed>|nulllog()
Debug logging
private
log(string $message) : void
Parameters
- $message : string