Completed
Push — master ( 8afce9...d9c6a8 )
by Peter
27:47 queued 23:46
created

EmbeddedDocument::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
ccs 6
cts 6
cp 1
rs 9.4285
cc 1
eloc 5
nc 1
nop 2
crap 1
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();
0 ignored issues
show
Deprecated Code introduced by
The method Maslosoft\Mangan\EmbeddedDocument::init() has been deprecated with message: since version number

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.

Loading history...
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