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.

Show class?             Show args?        

Common

NameReturnSummary 
wire()
mixedGet an API variable, create an API variable, or inject dependencies. 

Notices

NameReturnSummary 
error($text)
$thisRecord an non-fatal error message in the system-wide notices. 
errors()
Notices array stringReturn or manage errors recorded by just this object or all Wire objects 
log()
WireLogLog a message for this class
message($text)
$thisRecord an informational or “success” message in the system-wide notices. 
messages()
Notices array stringReturn or manage messages recorded by just this object or all Wire objects 
warning($text)
$thisRecord a warning error message in the system-wide notices. 
warnings()
Notices array stringReturn or manage warnings recorded by just this object or all Wire objects 

Identification

NameReturnSummary 
className()
stringReturn this object’s class name 
getInstanceNum()
intGet this Wire object’s instance number 

For hooks

These methods are only useful for hooking and should not be called directly.

NameReturnSummary 
callUnknown(string $method, array $arguments)
null mixedIf method call resulted in no handler, this hookable method is called.
changed(string $what)
(nothing)Hookable method that is called whenever a property has changed while change tracking is enabled.
trackException(\Exception $e)
$thisHookable 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.

NameReturnSummary 
getChanges()
arrayReturn an array of properties that have changed while change tracking was on. 
isChanged()
boolDoes the object have changes, or has the given property changed? 
resetTrackChanges()
$thisClears out any tracked changes and turns change tracking ON or OFF 
setTrackChanges()
$thisTurn change tracking ON or OFF 
trackChange(string $what)
$thisTrack a change to a property in this object 
trackChanges()
intReturns true or 1 if change tracking is on, or false or 0 if it is not, or mode bitmask (int) if requested. 
trackChangesOn const2For setTrackChanges() method flags: track names only (default). 
trackChangesValues const4For setTrackChanges() method flags: track names and values. 
untrackChange(string $what)
$thisUntrack 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.

NameReturnSummary 
cache()
WireCache string array PageArray nullAccess the $cache API variable as a function.
config()
Config mixedAccess the $config API variable as a function.
database()
WireDatabasePDOAccess the $database API variable as a function.
datetime()
WireDateTime string intAccess the $datetime API variable as a function.
fields()
Field Fields nullAccess the $fields API variable as a function.
files()
WireFileToolsAccess the $files API variable as a function.
input()
WireInput WireInputData WireInputDataCookie array string int nullAccess the $input API variable as a function.
inputCookie()
WireInputDataCookie string int array nullAccess the $input->cookie() API variable as a function.
inputGet()
WireInputData string int array nullAccess the $input->get() API variable as a function.
inputPost()
WireInputData string int array nullAccess the $input->post() API variable as a function.
languages()
Languages Language NullPage nullAccess the $languages API variable as a function.
modules()
Modules Module ConfigurableModule nullAccess the $modules API variable as a function.
page()
Page MixedAccess the $page API variable as a function.
pages()
Pages PageArray Page NullPageAccess the $pages API variable as a function.
permissions()
Permissions Permission PageArray null NullPageAccess the $permissions API variable as a function.
roles()
Roles Role PageArray null NullPageAccess the $roles API variable as a function.
sanitizer()
Sanitizer string int array null mixedAccess the $sanitizer API variable as a function.
session()
Session mixedAccess the $session API variable as a function.
templates()
Templates Template nullAccess the $templates API variable as a function.
user()
User mixedAccess the $user API variable as a function.
users()
Users PageArray User mixedAccess the $users API variable as a function.

API reference based on ProcessWire core version 3.0.244

“To Drupal, or to ProcessWire? The million dollar choice. We decided to make an early switch to PW. And in retrospect, ProcessWire was probably the best decision we made. Thanks are due to ProcessWire and the amazing system and set of modules that are in place.” —Unni Krishnan, Founder of PigtailPundits