Example #1
0
 /**
  * Configures the facade, want to have a new Writer? A new Object Database or a new
  * Adapter and you want it on-the-fly? Use this method to hot-swap your facade with a new
  * toolbox.
  *
  * @param RedBean_ToolBox $tb toolbox
  *
  * @return RedBean_ToolBox $tb old, rusty, previously used toolbox
  */
 public static function configureFacadeWithToolbox(RedBean_ToolBox $tb)
 {
     $oldTools = static::$toolbox;
     static::$toolbox = $tb;
     static::$writer = static::$toolbox->getWriter();
     static::$adapter = static::$toolbox->getDatabaseAdapter();
     static::$redbean = static::$toolbox->getRedBean();
     static::$associationManager = new RedBean_AssociationManager(static::$toolbox);
     static::$redbean->setAssociationManager(static::$associationManager);
     static::$extAssocManager = new RedBean_ExtAssociationManager(static::$toolbox);
     $helper = new RedBean_ModelHelper();
     static::$redbean->addEventListener('update', $helper);
     static::$redbean->addEventListener('open', $helper);
     static::$redbean->addEventListener('delete', $helper);
     static::$associationManager->addEventListener('delete', $helper);
     static::$redbean->addEventListener('after_delete', $helper);
     static::$redbean->addEventListener('after_update', $helper);
     static::$redbean->addEventListener('dispense', $helper);
     static::$tagManager = new RedBean_TagManager(static::$toolbox);
     static::$f = new RedBean_SQLHelper(static::$adapter);
     return $oldTools;
 }
Example #2
0
 public function __construct()
 {
     static::$f = 1;
 }