Wire::___callUnknown PHP Method

___callUnknown() protected method

This standard implementation just throws an exception. This is a template method, so the reason it exists is so that other classes can override and provide their own handler. Classes that provide their own handler should not do a parent::__callUnknown() unless they also fail.
protected ___callUnknown ( string $method, array $arguments ) : null | mixed
$method string Requested method name
$arguments array Arguments provided
return null | mixed
    protected function ___callUnknown($method, $arguments)
    {
        if ($this->wire('config')->disableUnknownMethodException) {
            return null;
        }
        throw new WireException("Method " . $this->className() . "::{$method} does not exist or is not callable in this context");
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * Handler for when an unknown/unhooked function call is executed
  *
  * @param string $method Requested method name
  * @param array $arguments Arguments provided
  * @return null|mixed
  * @throws WireException
  *
  */
 protected function ___callUnknown($method, $arguments)
 {
     if (!isset($arguments[0])) {
         // explode the property to an array
         return $this->explode($method);
     } else {
         if (is_string($arguments[0])) {
             // implode the property identified by $method and glued by $arguments[0]
             // with optional $options as second argument
             $delimiter = $arguments[0];
             $options = array();
             if (isset($arguments[1]) && is_array($arguments[1])) {
                 $options = $arguments[1];
             }
             return $this->implode($delimiter, $method, $options);
         } else {
             // fail
             return parent::___callUnknown($method, $arguments);
         }
     }
 }