Yaffs site version 1.1
[yaffs-website] / vendor / gabordemooij / redbean / RedBeanPHP / ToolBox.php
1 <?php
2
3 namespace RedBeanPHP;
4
5 use RedBeanPHP\OODB as OODB;
6 use RedBeanPHP\QueryWriter as QueryWriter;
7 use RedBeanPHP\Adapter\DBAdapter as DBAdapter;
8 use RedBeanPHP\Adapter as Adapter;
9
10 /**
11  * ToolBox.
12  *
13  * The toolbox is an integral part of RedBeanPHP providing the basic
14  * architectural building blocks to manager objects, helpers and additional tools
15  * like plugins. A toolbox contains the three core components of RedBeanPHP:
16  * the adapter, the query writer and the core functionality of RedBeanPHP in
17  * OODB.
18  *
19  * @file      RedBeanPHP/ToolBox.php
20  * @author    Gabor de Mooij and the RedBeanPHP community
21  * @license   BSD/GPLv2
22  *
23  * @copyright
24  * copyright (c) G.J.G.T. (Gabor) de Mooij and the RedBeanPHP Community.
25  * This source file is subject to the BSD/GPLv2 License that is bundled
26  * with this source code in the file license.txt.
27  */
28 class ToolBox
29 {
30         /**
31          * @var OODB
32          */
33         protected $oodb;
34
35         /**
36          * @var QueryWriter
37          */
38         protected $writer;
39
40         /**
41          * @var DBAdapter
42          */
43         protected $adapter;
44
45         /**
46          * Constructor.
47          * The toolbox is an integral part of RedBeanPHP providing the basic
48          * architectural building blocks to manager objects, helpers and additional tools
49          * like plugins. A toolbox contains the three core components of RedBeanPHP:
50          * the adapter, the query writer and the core functionality of RedBeanPHP in
51          * OODB.
52          *
53          * @param OODB        $oodb    Object Database, OODB
54          * @param DBAdapter   $adapter Database Adapter
55          * @param QueryWriter $writer  Query Writer
56          */
57         public function __construct( OODB $oodb, Adapter $adapter, QueryWriter $writer )
58         {
59                 $this->oodb    = $oodb;
60                 $this->adapter = $adapter;
61                 $this->writer  = $writer;
62                 return $this;
63         }
64
65         /**
66          * Returns the query writer in this toolbox.
67          * The Query Writer is responsible for building the queries for a
68          * specific database and executing them through the adapter.
69          *
70          * @return QueryWriter
71          */
72         public function getWriter()
73         {
74                 return $this->writer;
75         }
76
77         /**
78          * Returns the OODB instance in this toolbox.
79          * OODB is responsible for creating, storing, retrieving and deleting
80          * single beans. Other components rely
81          * on OODB for their basic functionality.
82          *
83          * @return OODB
84          */
85         public function getRedBean()
86         {
87                 return $this->oodb;
88         }
89
90         /**
91          * Returns the database adapter in this toolbox.
92          * The adapter is responsible for executing the query and binding the values.
93          * The adapter also takes care of transaction handling.
94          *
95          * @return DBAdapter
96          */
97         public function getDatabaseAdapter()
98         {
99                 return $this->adapter;
100         }
101 }