Example #1
0
 /**
  * Handles method calls when a method is not implemented
  *
  * @param string $method
  * @param array|null $arguments
  * @return mixed
  * @throws Exception
  */
 public function __call($method, $arguments = null)
 {
     if (is_string($method) === false) {
         throw new Exception('Invalid parameter type.');
     }
     if (is_null($arguments) === true) {
         $arguments = array();
     } elseif (is_array($arguments) === false) {
         throw new Exception('Invalid parameter type.');
     }
     //Check if there is a default action using the magic getter
     $records = $this->_getRelatedRecords(__CLASS__, $method, $arguments);
     if (is_null($records) === false) {
         return $records;
     }
     //Try to find a replacement for the missing method in a behavior/listener
     $status = $this->_modelsManager->missingMethod($this, $method, $arguments);
     if (is_null($status) === false) {
         return $status;
     }
     //The method doesn't exist - throw an exception
     throw new Exception('The method "' . $method . '" doesn\'t exist on model "' . __CLASS__ . '"');
 }