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 | |
---|---|---|---|
Wire::callUnknown() Wire::callUnknown(string $method, array $arguments) Wire::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) | (nothing) | Hookable method that is called whenever a property has changed while change tracking is enabled. | |
Wire::trackException() Wire::trackException($e) Wire::trackException($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.
Name | Return | Summary | |
---|---|---|---|
Wire::cache() Wire::cache() Wire::cache($name = '', $expire = null, $func = null) | WireCache string array PageArray null | Access the $cache API variable as a function. | |
Wire::config() Wire::config() Wire::config($key = '', $value = null) | Config mixed | Access the $config API variable as a function. | |
Wire::database() Wire::database() Wire::database() | WireDatabasePDO | Access the $database API variable as a function. | |
Wire::datetime() Wire::datetime() Wire::datetime($format = '', $value = '') | WireDateTime string int | Access the $datetime API variable as a function. | |
Wire::fields() Wire::fields() Wire::fields($name = '') | Field Fields null | Access the $fields API variable as a function. | |
Wire::files() Wire::files() Wire::files() | WireFileTools | Access the $files API variable as a function. | |
Wire::input() Wire::input() Wire::input($type = '', $key = '', $sanitizer = '') | WireInput WireInputData WireInputDataCookie array string int null | Access the $input API variable as a function. | |
Wire::inputCookie() Wire::inputCookie() Wire::inputCookie($key = '', $sanitizer = '') | WireInputDataCookie string int array null | Access the $input->cookie() API variable as a function. | |
Wire::inputGet() Wire::inputGet() Wire::inputGet($key = '', $sanitizer = '') | WireInputData string int array null | Access the $input->get() API variable as a function. | |
Wire::inputPost() Wire::inputPost() Wire::inputPost($key = '', $sanitizer = '') | WireInputData string int array null | Access the $input->post() API variable as a function. | |
Wire::languages() Wire::languages() Wire::languages($name = '') | Languages Language NullPage null | Access the $languages API variable as a function. | |
Wire::modules() Wire::modules() Wire::modules($name = '') | Modules Module ConfigurableModule null | Access the $modules API variable as a function. | |
Wire::page() Wire::page() Wire::page($key = '', $value = null) | Page Mixed | Access the $page API variable as a function. | |
Wire::pages() Wire::pages() Wire::pages($selector = '') | Pages PageArray Page NullPage | Access the $pages API variable as a function. | |
Wire::permissions() Wire::permissions() Wire::permissions($selector = '') | Permissions Permission PageArray null NullPage | Access the $permissions API variable as a function. | |
Wire::roles() Wire::roles() Wire::roles($selector = '') | Roles Role PageArray null NullPage | Access the $roles API variable as a function. | |
Wire::sanitizer() Wire::sanitizer() Wire::sanitizer($name = '', $value = '') | Sanitizer string int array null mixed | Access the $sanitizer API variable as a function. | |
Wire::session() Wire::session() Wire::session($key = '', $value = null) | Session mixed | Access the $session API variable as a function. | |
Wire::templates() Wire::templates() Wire::templates($name = '') | Templates Template null | Access the $templates API variable as a function. | |
Wire::user() Wire::user() Wire::user($key = '', $value = null) | User mixed | Access the $user API variable as a function. | |
Wire::users() Wire::users() Wire::users($selector = '') | Users PageArray User mixed | Access the $users API variable as a function. |
API reference based on ProcessWire core version 3.0.236