Overview

Namespaces

  • None
  • RedBeanPHP
    • Adapter
    • BeanHelper
    • Cursor
    • Driver
    • Logger
      • RDefault
    • QueryWriter
    • RedException
    • Repository
    • Util

Classes

  • AssociationManager
  • BeanCollection
  • DuplicationManager
  • Facade
  • Finder
  • Jsonable
  • LabelMaker
  • Observable
  • OODB
  • OODBBean
  • R
  • Repository
  • SimpleModel
  • SimpleModelHelper
  • TagManager
  • ToolBox

Interfaces

  • Adapter
  • BeanHelper
  • Cursor
  • Driver
  • Logger
  • Observer
  • Plugin
  • QueryWriter

Exceptions

  • RedException
  • Overview
  • Namespace
  • Class

Interface BeanHelper

Bean Helper Interface.

Interface for Bean Helper. A little bolt that glues the whole machinery together.

Direct known implementers

RedBeanPHP\BeanHelper\SimpleFacadeBeanHelper
Namespace: RedBeanPHP
Copyright:

copyright (c) G.J.G.T. (Gabor) de Mooij and the RedBeanPHP Community This source file is subject to the BSD/GPLv2 License that is bundled with this source code in the file license.txt.


License: BSD/GPLv2
Author: Gabor de Mooij and the RedBeanPHP Community
File: RedBeanPHP/IBeanHelper.php
Located at BeanHelper.php
Methods summary
public RedBeanPHP\ToolBox
# getToolbox( )

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 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
public array
# getExtractedToolbox( )

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!.

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
public RedBeanPHP\SimpleModel|CustomModel|null
# getModelForBean( RedBeanPHP\OODBBean $bean )

Given a certain bean this method will return the corresponding model. If no model is returned (NULL), RedBeanPHP might ask again.

Given a certain bean this method will return the corresponding model. If no model is returned (NULL), RedBeanPHP might ask again.

Parameters

$bean
bean to obtain the corresponding model of

Returns

RedBeanPHP\SimpleModel|CustomModel|null

Note

You can make RedBeanPHP faster by doing the setup wiring yourself. The event listeners take time, so to speed-up RedBeanPHP you can drop 'FUSE', if you're not interested in the Models.


You can do funny stuff with this method but please be careful. You could create a model depending on properties of the bean, but it's a bit well... adventurous, here is an example:

class Book extends RedBeanPHP\SimpleModel {};
class Booklet extends RedBeanPHP\SimpleModel {};

class FlexBeanHelper extends RedBeanPHP\BeanHelper\SimpleFacadeBeanHelper {
 public function getModelForBean( RedBeanPHP\OODBBean $bean ) {
  if (!isset($bean->pages)) return NULL; //will ask again
  if ($bean->pages <= 10) return new Booklet;
  return new Book;
 }
}

$h = new FlexBeanHelper;
R::getRedBean()->setBeanHelper($h);
$book = R::dispense('book');
var_dump($book->box()); //NULL cant reach model
$book->pages = 5;
var_dump($book->box()); //Booklet
$book->pages = 15;
var_dump($book->box()); //still.. Booklet, model has been set
$book2 = R::dispense('book');
$book2->pages = 15;
var_dump($book2->box()); //Book, more than 10 pages

API documentation generated by ApiGen