1
|
|
|
<?php |
2
|
|
|
namespace Ajir\RabbitMqSqlBundle\Model; |
3
|
|
|
|
4
|
|
|
use Ajir\RabbitMqSqlBundle\DataMapper\DataMapper; |
5
|
|
|
use Ajir\RabbitMqSqlBundle\DataTransformer\DataTransformer; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Class ManyToManyRelation |
9
|
|
|
* |
10
|
|
|
* @author Florian Ajir <[email protected]> |
11
|
|
|
*/ |
12
|
|
|
class ManyToManyRelation extends AbstractRelation implements RelationInterface |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* @var array |
16
|
|
|
*/ |
17
|
|
|
protected $entities; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @var string |
21
|
|
|
*/ |
22
|
|
|
protected $joinTableName; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @var string |
26
|
|
|
*/ |
27
|
|
|
protected $inverseJoinColumnName; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var string |
31
|
|
|
*/ |
32
|
|
|
protected $inverseJoinColumnReferencedColumnName; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @param array $data |
36
|
|
|
*/ |
37
|
2 |
|
public function __construct(array $data) |
38
|
|
|
{ |
39
|
2 |
|
parent::__construct($data); |
40
|
2 |
|
$relation = $data[DataTransformer::RELATED_RELATION_KEY]; |
41
|
2 |
|
$joinTable = $relation[DataMapper::RELATION_KEY_JOIN_TABLE]; |
42
|
2 |
|
$this->joinTableName = $joinTable[DataMapper::RELATION_KEY_JOIN_COLUMN_NAME]; |
43
|
2 |
|
$joinColumn = $joinTable[DataMapper::RELATION_KEY_JOIN_COLUMN]; |
44
|
2 |
|
$this->joinColumnName = $joinColumn[DataMapper::RELATION_KEY_JOIN_COLUMN_NAME]; |
45
|
2 |
|
$this->joinColumnReferencedColumnName = |
46
|
2 |
|
$joinColumn[DataMapper::RELATION_KEY_JOIN_COLUMN_REFERENCED_COLUMN_NAME]; |
47
|
2 |
|
$inverseJoinColumn = $joinTable[DataMapper::RELATION_KEY_INVERSE_JOIN_COLUMN]; |
48
|
2 |
|
$this->inverseJoinColumnName = $inverseJoinColumn[DataMapper::RELATION_KEY_JOIN_COLUMN_NAME]; |
49
|
2 |
|
$this->inverseJoinColumnReferencedColumnName = |
50
|
2 |
|
$inverseJoinColumn[DataMapper::RELATION_KEY_JOIN_COLUMN_REFERENCED_COLUMN_NAME]; |
51
|
2 |
|
$this->entities = $data[DataTransformer::RELATED_DATA_KEY]; |
52
|
2 |
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @return array |
56
|
|
|
*/ |
57
|
1 |
|
public function getEntities() |
58
|
|
|
{ |
59
|
1 |
|
return $this->entities; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @return string |
64
|
|
|
*/ |
65
|
1 |
|
public function getJoinTableName() |
66
|
|
|
{ |
67
|
1 |
|
return $this->joinTableName; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @return string |
72
|
|
|
*/ |
73
|
1 |
|
public function getInverseJoinColumnName() |
74
|
|
|
{ |
75
|
1 |
|
return $this->inverseJoinColumnName; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @return string |
80
|
|
|
*/ |
81
|
1 |
|
public function getInverseJoinColumnReferencedColumnName() |
82
|
|
|
{ |
83
|
1 |
|
return $this->inverseJoinColumnReferencedColumnName; |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
|