\RedBeanPHP\BeanHelperDynamicBeanHelper

Dynamic Bean Helper.

The dynamic bean helper allows you to use differently namespaced classes for models per database connection.

Summary

Methods
Properties
Constants
factory()
setFactoryFunction()
getToolbox()
getModelForBean()
getExtractedToolbox()
__construct()
No public properties found
No constants found
resolveModel()
No protected properties found
N/A
No private methods found
$factory
$modelPrefix
N/A

Properties

$factory

$factory : callable|NULL

Factory function to create instance of Simple Model, if any.

Type

callable|NULL

$modelPrefix

$modelPrefix : string

Model prefix to be used for the current database connection.

Type

string

Methods

factory()

factory(string  $modelClassName) : \RedBeanPHP\BeanHelper\SimpleModel

Factory method using a customizable factory function to create the instance of the Simple Model.

Parameters

string $modelClassName

name of the class

Returns

\RedBeanPHP\BeanHelper\SimpleModel

setFactoryFunction()

setFactoryFunction(callable|NULL  $factory) : void

Sets the factory function to create the model when using FUSE to connect a bean to a model.

Parameters

callable|NULL $factory

factory function

getToolbox()

getToolbox() : \RedBeanPHP\ToolBox

Returns a toolbox to empower the bean.

This allows beans to perform OODB operations by themselves, as such the bean is a proxy for OODB. This allows beans to implement their magic getters and setters and return lists.

Returns

\RedBeanPHP\ToolBox

getModelForBean()

getModelForBean(\RedBeanPHP\OODBBean  $bean) : \RedBeanPHP\SimpleModel|\RedBeanPHP\CustomModel|NULL

Given a certain bean this method will return the corresponding model.

Parameters

\RedBeanPHP\OODBBean $bean

bean to obtain the corresponding model of

Returns

\RedBeanPHP\SimpleModel|\RedBeanPHP\CustomModel|NULL

getExtractedToolbox()

getExtractedToolbox() : array

Does approximately the same as getToolbox but also extracts the toolbox for you.

This method returns a list with all toolbox items in Toolbox Constructor order: OODB, adapter, writer and finally the toolbox itself!.

Returns

array

__construct()

__construct(string  $modelPrefix) 

Constructor

Usage:

R::addDatabase( ..., new DynamicBeanHelper('Prefix1_') );

Parameters

string $modelPrefix

prefix

resolveModel()

resolveModel(string  $prefix, string  $model, \RedBeanPHP\OODBBean  $bean) : \RedBeanPHP\BeanHelper\SimpleModel|\RedBeanPHP\BeanHelper\CustomModel|NULL

Resolves the model associated with the bean using the model name (type), the prefix and the bean.

Parameters

string $prefix

Prefix to use for resolution

string $model

Type name

\RedBeanPHP\OODBBean $bean

Bean to resolve model for

Returns

\RedBeanPHP\BeanHelper\SimpleModel|\RedBeanPHP\BeanHelper\CustomModel|NULL