|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This software package is licensed under AGPL or Commercial license. |
|
5
|
|
|
* |
|
6
|
|
|
* @package maslosoft/mangan |
|
7
|
|
|
* @licence AGPL or Commercial |
|
8
|
|
|
* @copyright Copyright (c) Piotr Masełkowski <[email protected]> |
|
9
|
|
|
* @copyright Copyright (c) Maslosoft |
|
10
|
|
|
* @copyright Copyright (c) Others as mentioned in code |
|
11
|
|
|
* @link http://maslosoft.com/mangan/ |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
namespace Maslosoft\Mangan; |
|
15
|
|
|
|
|
16
|
|
|
use Maslosoft\Addendum\Collections\Meta; |
|
17
|
|
|
use Maslosoft\Mangan\Interfaces\ActiveDocumentInterface; |
|
18
|
|
|
use Maslosoft\Mangan\Interfaces\InitInterface; |
|
19
|
|
|
use Maslosoft\Mangan\Meta\ManganMeta; |
|
20
|
|
|
use Maslosoft\Mangan\Sanitizers\MongoObjectId; |
|
21
|
|
|
use MongoId; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* EmbeddedDocument |
|
25
|
|
|
* |
|
26
|
|
|
* @author Ianaré Sévi |
|
27
|
|
|
* @author Dariusz Górecki <[email protected]> |
|
28
|
|
|
* @author Invenzzia Group, open-source division of CleverIT company http://www.invenzzia.org |
|
29
|
|
|
* @author Piotr Maselkowski, Maslosoft |
|
30
|
|
|
* @copyright 2011 CleverIT http://www.cleverit.com.pl |
|
31
|
|
|
* @copyright 2013 Maslosoft http://maslosoft.com |
|
32
|
|
|
* @since v1.0.8 |
|
33
|
|
|
* @property Meta $meta Model metadata |
|
34
|
|
|
*/ |
|
35
|
|
|
abstract class EmbeddedDocument implements ActiveDocumentInterface, InitInterface |
|
36
|
|
|
{ |
|
37
|
|
|
|
|
38
|
|
|
use \Maslosoft\Mangan\Traits\I18NAbleTrait, |
|
39
|
|
|
\Maslosoft\Mangan\Traits\OwneredTrait, |
|
40
|
|
|
\Maslosoft\Mangan\Traits\ScenariosTrait, |
|
41
|
|
|
\Maslosoft\Mangan\Traits\ValidatableTrait; |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* Mongo id field |
|
45
|
|
|
* NOTE: This is usefull for embedded documents too, as it is used for keeping order |
|
46
|
|
|
* @Label('Database ID') |
|
47
|
|
|
* @Sanitizer(MongoObjectId) |
|
48
|
|
|
* @see MongoObjectId |
|
49
|
|
|
* @var MongoId|null |
|
50
|
|
|
*/ |
|
51
|
|
|
public $_id = null; |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* This holds key for document order |
|
55
|
|
|
* TODO Is this even nessesary? |
|
56
|
|
|
* @SafeValidator |
|
57
|
|
|
* @var string |
|
58
|
|
|
*/ |
|
59
|
|
|
public $_key = ''; |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* This holds type of this embedded document |
|
63
|
|
|
* TODO Is this even nessesary? |
|
64
|
|
|
* @SafeValidator |
|
65
|
|
|
* @var string |
|
66
|
|
|
*/ |
|
67
|
|
|
public $_class = null; |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* Constructor. |
|
71
|
|
|
* @param string $scenario name of the scenario that this model is used in. |
|
72
|
|
|
* See {@link Model::scenario} on how scenario is used by models. |
|
73
|
|
|
* @see getScenario |
|
74
|
|
|
* @since v1.0.8 |
|
75
|
|
|
*/ |
|
76
|
9 |
|
public function __construct($scenario = 'insert', $lang = '') |
|
77
|
|
|
{ |
|
78
|
9 |
|
$this->_class = get_class($this); |
|
79
|
|
|
|
|
80
|
9 |
|
$this->setLang($lang); |
|
81
|
9 |
|
$this->setScenario($scenario); |
|
82
|
9 |
|
$this->init(); |
|
|
|
|
|
|
83
|
9 |
|
} |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* Initializes this model. |
|
87
|
|
|
* This method is invoked in the constructor right after {@link scenario} is set. |
|
88
|
|
|
* You may override this method to provide code that is needed to initialize the model (e.g. setting |
|
89
|
|
|
* initial property values.) |
|
90
|
|
|
* @deprecated since version number |
|
91
|
|
|
* @since 1.0.8 |
|
92
|
|
|
*/ |
|
93
|
|
|
public function init() |
|
94
|
|
|
{ |
|
95
|
|
|
|
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
} |
|
99
|
|
|
|
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.