1. As a getter (option 1):
==========================
Usage: $this->wire('name'); // name is an API variable name
If 'name' does not exist, a WireException will be thrown.
Specify '*' or 'all' for name to retrieve all API vars (as a Fuel object)
2. As a getter (option 2):
==========================
Usage: $this->wire()->name; // name is an API variable name
Null will be returned if API var does not exist (no Exception thrown).
3. As a setter:
===============
$this->wire('name', $value);
$this->wire('name', $value, true); // lock the API variable so nothing else can overwrite it
$this->wire()->set('name', $value);
$this->wire()->set('name', $value, true); // lock the API variable so nothing else can overwrite it
4. As a dependency injector (PW 3.0 only)
=========================================
$this->wire(new Page());
When creating a new object, this makes it inject the current PW instance into that object.
public wire ( string | object $name = '', null | mixed $value = null, boolean $lock = false ) : ProcessWire | Wire | Session | Page | Pages | Modules | User | Users | Roles | Permissions | Templates | Fields | Fieldtypes | Sanitizer | Config | Notices | WireDatabasePDO | WireInput | string | mixed | ||
$name | string | object | Name of API variable to retrieve, set, or omit to retrieve the master ProcessWire object |
$value | null | mixed | Value to set if using this as a setter, otherwise omit. |
$lock | boolean | When using as a setter, specify true if you want to lock the value from future changes (default=false) |
return | ProcessWire | Wire | Session | Page | Pages | Modules | User | Users | Roles | Permissions | Templates | Fields | Fieldtypes | Sanitizer | Config | Notices | WireDatabasePDO | WireInput | string | mixed |
<?php /** * ProcessWire PhpStorm Meta * * This file is not a CODE, it makes no sense and won't run or validate * Its AST serves PhpStorm IDE as DATA source to make advanced type inference decisions. * * @see https://confluence.jetbrains.com/display/PhpStorm/PhpStorm+Advanced+Metadata */ namespace PHPSTORM_META; $STATIC_METHOD_TYPES = [\wire('') => ['' == '@', 'config' instanceof Config, 'wire' instanceof ProcessWire, 'log' instanceof WireLog, 'notices' instanceof Notices, 'sanitizer' instanceof Sanitizer, 'database' instanceof WireDatabasePDO, 'db' instanceof DatabaseMysqli, 'cache' instanceof MarkupCache, 'modules' instanceof Modules, 'procache' instanceof ProCache, 'fieldtypes' instanceof Fieldtypes, 'fields' instanceof Fields, 'fieldgroups' instanceof Fieldgroups, 'templates' instanceof Templates, 'pages' instanceof Pages, 'permissions' instanceof Permissions, 'roles' instanceof Roles, 'users' instanceof Users, 'user' instanceof User, 'session' instanceof Session, 'input' instanceof WireInput, 'languages' instanceof Languages, 'page' instanceof Page], \Wire::wire('') => ['' == '@', 'config' instanceof Config, 'wire' instanceof ProcessWire, 'log' instanceof WireLog, 'notices' instanceof Notices, 'sanitizer' instanceof Sanitizer, 'database' instanceof WireDatabasePDO, 'db' instanceof DatabaseMysqli, 'cache' instanceof MarkupCache, 'modules' instanceof Modules, 'procache' instanceof ProCache, 'fieldtypes' instanceof Fieldtypes, 'fields' instanceof Fields, 'fieldgroups' instanceof Fieldgroups, 'templates' instanceof Templates, 'pages' instanceof Pages, 'permissions' instanceof Permissions, 'roles' instanceof Roles, 'users' instanceof Users, 'user' instanceof User, 'session' instanceof Session, 'input' instanceof WireInput, 'languages' instanceof Languages, 'page' instanceof Page]];