getToolbox() public method

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.
public getToolbox ( ) : ToolBox
return ToolBox
Ejemplo n.º 1
0
 /**
  * Counts all shared beans of type $type.
  * Also works with via(), with() and withCondition().
  *
  * @param string $type type of bean you wish to count
  *
  * @return integer
  */
 public function countShared($type)
 {
     $toolbox = $this->beanHelper->getToolbox();
     $redbean = $toolbox->getRedBean();
     $writer = $toolbox->getWriter();
     if ($this->via) {
         $oldName = $writer->getAssocTable(array($this->__info['type'], $type));
         if ($oldName !== $this->via) {
             //set the new renaming rule
             $writer->renameAssocTable($oldName, $this->via);
             $this->via = NULL;
         }
     }
     $type = $this->beau($type);
     $count = 0;
     if ($this->getID()) {
         $count = $redbean->getAssociationManager()->relatedCount($this, $type, $this->withSql, $this->withParams);
     }
     $this->clearModifiers();
     return (int) $count;
 }