1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* WebHemi. |
4
|
|
|
* |
5
|
|
|
* PHP version 7.2 |
6
|
|
|
* |
7
|
|
|
* @copyright 2012 - 2019 Gixx-web (http://www.gixx-web.com) |
8
|
|
|
* @license https://opensource.org/licenses/MIT The MIT License (MIT) |
9
|
|
|
* |
10
|
|
|
* @link http://www.gixx-web.com |
11
|
|
|
*/ |
12
|
|
|
declare(strict_types = 1); |
13
|
|
|
|
14
|
|
|
namespace WebHemi\Data\Storage; |
15
|
|
|
|
16
|
|
|
use WebHemi\Data\Entity\DomainEntity; |
17
|
|
|
use WebHemi\Data\Entity\EntitySet; |
18
|
|
|
use WebHemi\Data\Query\QueryInterface; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Class DomainStorage. |
22
|
|
|
*/ |
23
|
|
|
class DomainStorage extends AbstractStorage |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* Returns every Domain entity. |
27
|
|
|
* |
28
|
|
|
* @param int|null $limit |
29
|
|
|
* @param int|null $offset |
30
|
|
|
* @return EntitySet |
31
|
|
|
*/ |
32
|
|
|
public function getDomainList( |
33
|
|
|
? int $limit = null, |
34
|
|
|
? int $offset = null |
35
|
|
|
) : EntitySet { |
36
|
|
|
$limit = $limit ?? QueryInterface::MAX_ROW_LIMIT; |
37
|
|
|
$offset = $offset ?? 0; |
38
|
|
|
|
39
|
|
|
$this->normalizeLimitAndOffset($limit, $offset); |
40
|
|
|
|
41
|
|
|
$data = $this->getQueryAdapter()->fetchData( |
42
|
|
|
'getDomainList', |
43
|
|
|
[ |
44
|
|
|
':limit' => $limit, |
45
|
|
|
':offset' => $offset |
46
|
|
|
] |
47
|
|
|
); |
48
|
|
|
|
49
|
|
|
return $this->getEntitySet(DomainEntity::class, $data); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Returns a Domain entity identified by (unique) ID. |
54
|
|
|
* |
55
|
|
|
* @param int $identifier |
56
|
|
|
* @return null|DomainEntity |
57
|
|
|
*/ |
58
|
|
|
public function getDomainById(int $identifier) : ? DomainEntity |
59
|
|
|
{ |
60
|
|
|
$data = $this->getQueryAdapter()->fetchData( |
61
|
|
|
'getDomainById', |
62
|
|
|
[ |
63
|
|
|
':idDomain' => $identifier |
64
|
|
|
] |
65
|
|
|
); |
66
|
|
|
|
67
|
|
|
/** @var null|DomainEntity $entity */ |
68
|
|
|
$entity = $this->getEntity(DomainEntity::class, $data[0] ?? []); |
69
|
|
|
|
70
|
|
|
return $entity; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* Returns an Domain entity by name. |
75
|
|
|
* |
76
|
|
|
* @param string $name |
77
|
|
|
* @return null|DomainEntity |
78
|
|
|
*/ |
79
|
|
|
public function getDomainByDomainName(string $name) : ? DomainEntity |
80
|
|
|
{ |
81
|
|
|
$data = $this->getQueryAdapter()->fetchData( |
82
|
|
|
'getDomainByDomainName', |
83
|
|
|
[ |
84
|
|
|
':name' => $name |
85
|
|
|
] |
86
|
|
|
); |
87
|
|
|
|
88
|
|
|
/** @var null|DomainEntity $entity */ |
89
|
|
|
$entity = $this->getEntity(DomainEntity::class, $data[0] ?? []); |
90
|
|
|
|
91
|
|
|
return $entity; |
92
|
|
|
} |
93
|
|
|
} |
94
|
|
|
|