forked from webiny/Entity
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEntity.php
More file actions
executable file
·55 lines (46 loc) · 1.06 KB
/
Entity.php
File metadata and controls
executable file
·55 lines (46 loc) · 1.06 KB
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
<?php
/**
* Webiny Framework (http://www.webiny.com/framework)
*
* @copyright Copyright Webiny LTD
*/
namespace Webiny\Component\Entity;
use Webiny\Component\Mongo\Mongo;
use Webiny\Component\Mongo\MongoTrait;
use Webiny\Component\StdLib\ComponentTrait;
use Webiny\Component\StdLib\SingletonTrait;
use Webiny\Component\StdLib\StdLibTrait;
/**
* Entity component main class
* Use this class to configure Entity component.
*
* @package \Webiny\Component\Entity
*/
class Entity
{
use MongoTrait, ComponentTrait, SingletonTrait;
/**
* @var null|Mongo
*/
protected static $database = null;
/**
* Get entity database
* @return Mongo
*/
public function getDatabase()
{
if (self::$database === null) {
self::$database = self::mongo(self::getConfig()->Database);
}
return self::$database;
}
/**
* Set entity database
*
* @param Mongo $mongoDatabase
*/
public function setDatabase(Mongo $mongoDatabase)
{
self::$database = $mongoDatabase;
}
}