getModelForBean() public method

If no model is returned (NULL), RedBeanPHP might ask again.
public getModelForBean ( RedBeanPHP\OODBBean $bean ) : redbeanphp\SimpleModel | CustomModel | null
$bean RedBeanPHP\OODBBean bean to obtain the corresponding model of
return redbeanphp\SimpleModel | CustomModel | null
Ejemplo n.º 1
0
 /**
  * Sends the call to the registered model.
  *
  * @param string $method name of the method
  * @param array  $args   argument list
  *
  * @return mixed
  */
 public function __call($method, $args)
 {
     if (!isset($this->__info['model'])) {
         $model = $this->beanHelper->getModelForBean($this);
         if (!$model) {
             return NULL;
         }
         $this->__info['model'] = $model;
     }
     if (!method_exists($this->__info['model'], $method)) {
         return NULL;
     }
     return call_user_func_array(array($this->__info['model'], $method), $args);
 }
Ejemplo n.º 2
0
 /**
  * Sends the call to the registered model.
  *
  * @param string $method name of the method
  * @param array  $args   argument list
  *
  * @return mixed
  */
 public function __call($method, $args)
 {
     if (!isset($this->__info['model'])) {
         $model = $this->beanHelper->getModelForBean($this);
         if (!$model) {
             return NULL;
         }
         $this->__info['model'] = $model;
     }
     if (!method_exists($this->__info['model'], $method)) {
         if (self::$errorHandlingFUSE === FALSE) {
             return NULL;
         }
         if (in_array($method, array('update', 'open', 'delete', 'after_delete', 'after_update', 'dispense'), TRUE)) {
             return NULL;
         }
         $message = "FUSE: method does not exist in model: {$method}";
         if (self::$errorHandlingFUSE === self::C_ERR_LOG) {
             error_log($message);
             return NULL;
         } elseif (self::$errorHandlingFUSE === self::C_ERR_NOTICE) {
             trigger_error($message, E_USER_NOTICE);
             return NULL;
         } elseif (self::$errorHandlingFUSE === self::C_ERR_WARN) {
             trigger_error($message, E_USER_WARNING);
             return NULL;
         } elseif (self::$errorHandlingFUSE === self::C_ERR_EXCEPTION) {
             throw new \Exception($message);
         } elseif (self::$errorHandlingFUSE === self::C_ERR_FUNC) {
             $func = self::$errorHandler;
             return $func(array('message' => $message, 'method' => $method, 'args' => $args, 'bean' => $this));
         }
         trigger_error($message, E_USER_ERROR);
         return NULL;
     }
     return call_user_func_array(array($this->__info['model'], $method), $args);
 }