/** * Get or inject a MAB API variable * * 1. As a getter (option 1): * ========================== * Usage: $this->MAB('name'); // name is an API variable name * If 'name' does not exist, a WireException will be thrown. * * 2. As a getter (option 2): * ========================== * Usage: $this->MAB()->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->MAB('name', $value); * $this->MAB('name', $value, true); // lock the API variable so nothing else can overwrite it * $this->MAB()->set('name', $value); * $this->MAB()->set('name', $value, true); // lock the API variable so nothing else can overwrite it * * @param string $name Name of API variable to retrieve, set, or omit to retrieve the master ProcessWire object * @param null|mixed $value Value to set if using this as a setter, otherwise omit. * @param bool $lock When using as a setter, specify true if you want to lock the value from future changes (default=false) * @return mixed|ProcessWire * @throws WireException * * */ public function MAB($name = '', $value = null, $lock = false) { if (is_null(self::$fuel)) { self::$fuel = new MAB_Fuel(); } if (!is_null($value)) { return self::$fuel->set($name, $value, $lock); } if (empty($name)) { return self::$fuel->MAB; } $value = self::$fuel->{$name}; if (is_null($value)) { throw new MAB_Exception("Unknown API variable: {$name}"); } return $value; }