-
Notifications
You must be signed in to change notification settings - Fork 280
/
SimpleModel.php
executable file
·83 lines (75 loc) · 1.56 KB
/
SimpleModel.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
/**
* SimpleModel
*
* @file RedBean/SimpleModel.php
* @description Part of FUSE
* @author Gabor de Mooij and the RedBeanPHP Team
* @license BSD/GPLv2
*
* 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.
*/
class RedBean_SimpleModel {
/**
* Contains the inner bean.
* @var RedBean_OODBBean
*/
protected $bean;
/**
* Used by FUSE: the ModelHelper class to connect a bean to a model.
* This method loads a bean in the model.
*
* @param RedBean_OODBBean $bean bean
*/
public function loadBean( RedBean_OODBBean $bean ) {
$this->bean = $bean;
}
/**
* Magic Getter to make the bean properties available from
* the $this-scope.
*
* @param string $prop property
*
* @return mixed $propertyValue value
*/
public function __get( $prop ) {
return $this->bean->$prop;
}
/**
* Magic Setter
*
* @param string $prop property
* @param mixed $value value
*/
public function __set( $prop, $value ) {
$this->bean->$prop = $value;
}
/**
* Isset implementation
*
* @param string $key key
*
* @return
*/
public function __isset($key) {
return (isset($this->bean->$key));
}
/**
* Box the bean using the current model.
*
* @return RedBean_SimpleModel $box a bean in a box
*/
public function box() {
return $this;
}
/**
* Unbox the bean from the model.
*
* @return RedBean_OODBBean $bean bean
*/
public function unbox(){
return $this->bean;
}
}