/** * @see RedBean_BeanHelper::getModelForBean */ public function getModelForBean(RedBean_OODBBean $bean) { $modelName = $this->helper->getModelName($bean->getMeta('type'), $bean); if (!class_exists($modelName)) { return NULL; } $obj = $this->helper->factory($modelName); $obj->loadBean($bean); return $obj; }
/** * Reroutes a call to Model if exists. (new fuse) * @param string $method * @param array $args * @return mixed $mixed */ public function __call($method, $args) { if (!isset($this->__info['model'])) { $modelName = RedBean_ModelHelper::getModelName($this->getMeta('type'), $this); if (!class_exists($modelName)) { return null; } $obj = RedBean_ModelHelper::factory($modelName); $obj->loadBean($this); $this->__info['model'] = $obj; } if (!method_exists($this->__info['model'], $method)) { return null; } return call_user_func_array(array($this->__info['model'], $method), $args); }
/** * Fuse connector. * Gets the model for a bean $bean. * Allows you to implement your own way to find the * right model for a bean and to do dependency injection * etc. * * @param RedBean_OODBBean $bean bean * * @return type */ public function getModelForBean(RedBean_OODBBean $bean) { $modelName = RedBean_ModelHelper::getModelName($bean->getMeta('type'), $bean); if (!class_exists($modelName)) { return null; } $obj = RedBean_ModelHelper::factory($modelName); $obj->loadBean($bean); return $obj; }