Wire class
Wire is the base class for most ProcessWire classes and modules.
Wire derived classes have a $this->wire()
method that provides access to ProcessWire’s API variables.
API variables can also be accessed as local properties in most cases. Wire also provides basic methods
for tracking changes and managing runtime notices specific to the instance.
Wire derived classes can specify which methods are “hookable” by precending the method name with 3 underscores like this: ___myMethod()
. Other classes can then hook either before or after that method, modifying arguments or return values. Several other hook methods are also provided for Wire derived
classes that are hooking into others.
Click any linked item for full usage details and examples. Hookable methods are indicated with the icon.
Common
Name | Return | Summary | |
---|---|---|---|
Wire::wire() Wire::wire() Wire::wire($name = '', $value = null, bool $lock = false) | mixed | Get an API variable, create an API variable, or inject dependencies. |
Notices
Name | Return | Summary | |
---|---|---|---|
Wire::error() Wire::error($text) Wire::error($text, $flags = 0) | $this | Record an non-fatal error message in the system-wide notices. | |
Wire::errors() Wire::errors() Wire::errors($options = []) | Notices array string | Return or manage errors recorded by just this object or all Wire objects | |
Wire::log() Wire::log() Wire::log(string $str = '', array $options = []) | WireLog | Log a message for this class | |
Wire::message() Wire::message($text) Wire::message($text, $flags = 0) | $this | Record an informational or “success” message in the system-wide notices. | |
Wire::messages() Wire::messages() Wire::messages($options = []) | Notices array string | Return or manage messages recorded by just this object or all Wire objects | |
Wire::warning() Wire::warning($text) Wire::warning($text, $flags = 0) | $this | Record a warning error message in the system-wide notices. | |
Wire::warnings() Wire::warnings() Wire::warnings($options = []) | Notices array string | Return or manage warnings recorded by just this object or all Wire objects |
Identification
Name | Return | Summary | |
---|---|---|---|
Wire::className() Wire::className() Wire::className($options = null) | string | Return this object’s class name | |
Wire::getInstanceNum() Wire::getInstanceNum() Wire::getInstanceNum(bool $getTotal = false) | int | Get this Wire object’s instance number |
For hooks
These methods are only useful for hooking and should not be called directly.
Name | Return | Summary | |
---|---|---|---|
$this->callUnknown() $this->callUnknown(string $method, array $arguments) $this->callUnknown(string $method, array $arguments) | null mixed | If method call resulted in no handler, this hookable method is called. | |
Wire::changed() Wire::changed(string $what) Wire::changed(string $what, mixed $old = null, mixed $new = null) | None | Hookable method that is called whenever a property has changed while change tracking is enabled. | |
Wire::trackException() Wire::trackException(\Exception $e) Wire::trackException(\Exception $e, $severe = true, $text = null) | $this | Hookable method called when an Exception occurs |
Hooks
Methods for managing hooks for an object instance or class.
Changes
Methods to support tracking and retrieval of changes made to the object.
Name | Return | Summary | |
---|---|---|---|
Wire::getChanges() Wire::getChanges() Wire::getChanges(bool $getValues = false) | array | Return an array of properties that have changed while change tracking was on. | |
Wire::isChanged() Wire::isChanged() Wire::isChanged(string $what = '') | bool | Does the object have changes, or has the given property changed? | |
Wire::resetTrackChanges() Wire::resetTrackChanges() Wire::resetTrackChanges(bool $trackChanges = true) | $this | Clears out any tracked changes and turns change tracking ON or OFF | |
Wire::setTrackChanges() Wire::setTrackChanges() Wire::setTrackChanges($trackChanges = true) | $this | Turn change tracking ON or OFF | |
Wire::trackChange() Wire::trackChange(string $what) Wire::trackChange(string $what, mixed $old = null, mixed $new = null) | $this | Track a change to a property in this object | |
Wire::trackChanges() Wire::trackChanges() Wire::trackChanges(bool $getMode = false) | int | Returns true or 1 if change tracking is on, or false or 0 if it is not, or mode bitmask (int) if requested. | |
Wire::trackChangesOn const | 2 | For setTrackChanges() method flags: track names only (default). | |
Wire::trackChangesValues const | 4 | For setTrackChanges() method flags: track names and values. | |
Wire::untrackChange() Wire::untrackChange(string $what) Wire::untrackChange(string $what) | $this | Untrack a change to a property in this object |
Api helpers
Shortcuts to ProcessWire API variables. Access without any arguments returns the API variable. Some support arguments as shortcuts to methods in the API variable.
API reference based on ProcessWire core version 3.0.251