1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of slick/orm package |
5
|
|
|
* |
6
|
|
|
* For the full copyright and license information, please view the LICENSE |
7
|
|
|
* file that was distributed with this source code. |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace Slick\Orm\Repository; |
11
|
|
|
|
12
|
|
|
use Slick\Database\Adapter\AdapterInterface; |
13
|
|
|
use Slick\Orm\Descriptor\EntityDescriptorInterface; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Abstract entity Repository |
17
|
|
|
* |
18
|
|
|
* @package Slick\Orm |
19
|
|
|
* @author Filipe Silva <[email protected]> |
20
|
|
|
*/ |
21
|
|
|
abstract class AbstractRepository |
22
|
|
|
{ |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @var AdapterInterface |
26
|
|
|
*/ |
27
|
|
|
protected $adapter; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var EntityDescriptorInterface |
31
|
|
|
*/ |
32
|
|
|
protected $entityDescriptor; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Sets the adapter for this statement |
36
|
|
|
* |
37
|
|
|
* @param AdapterInterface $adapter |
38
|
|
|
* |
39
|
|
|
* @return $this|self|AbstractRepository |
40
|
|
|
*/ |
41
|
|
|
public function setAdapter(AdapterInterface $adapter) |
42
|
|
|
{ |
43
|
|
|
$this->adapter = $adapter; |
44
|
|
|
return $this; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Retrieves the current adapter |
49
|
|
|
* |
50
|
|
|
* @return AdapterInterface |
51
|
|
|
*/ |
52
|
|
|
public function getAdapter() |
53
|
|
|
{ |
54
|
|
|
return $this->adapter; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Set the entity descriptor interface |
59
|
|
|
* |
60
|
|
|
* @param EntityDescriptorInterface $descriptor |
61
|
|
|
* @return $this|self|AbstractRepository |
62
|
|
|
*/ |
63
|
|
|
public function setEntityDescriptor(EntityDescriptorInterface $descriptor) |
64
|
|
|
{ |
65
|
|
|
$this->entityDescriptor = $descriptor; |
66
|
|
|
return $this; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Gets entity descriptor |
71
|
|
|
* |
72
|
|
|
* @return EntityDescriptorInterface |
73
|
|
|
*/ |
74
|
|
|
public function getEntityDescriptor() |
75
|
|
|
{ |
76
|
|
|
return $this->entityDescriptor; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
} |