Commit | Line | Data |
---|---|---|
71e5aa5c ARW |
1 | <?php |
2 | ||
3 | /** | |
4 | * Description of a one-way link between two entities | |
5 | * | |
6 | * This could be a foreign key or a generic (entity_id, entity_table) pointer | |
7 | */ | |
8 | class CRM_Core_EntityReference { | |
9 | protected $refTable; | |
10 | protected $refKey; | |
11 | protected $refTypeColumn; | |
12 | protected $targetTable; | |
13 | protected $targetKey; | |
14 | ||
15 | function __construct($refTable, $refKey, $targetTable = NULL, $targetKey = 'id', $refTypeColumn = NULL) { | |
16 | $this->refTable = $refTable; | |
17 | $this->refKey = $refKey; | |
18 | $this->targetTable = $targetTable; | |
19 | $this->targetKey = $targetKey; | |
20 | $this->refTypeColumn = $refTypeColumn; | |
21 | } | |
22 | ||
23 | function getReferenceTable() { | |
24 | return $this->refTable; | |
25 | } | |
26 | ||
27 | function getReferenceKey() { | |
28 | return $this->refKey; | |
29 | } | |
30 | ||
31 | function getTypeColumn() { | |
32 | return $this->refTypeColumn; | |
33 | } | |
34 | ||
35 | function getTargetTable() { | |
36 | return $this->targetTable; | |
37 | } | |
38 | ||
39 | function getTargetKey() { | |
40 | return $this->targetKey; | |
41 | } | |
42 | ||
43 | /** | |
44 | * @return true if the reference can point to more than one type | |
45 | */ | |
46 | function isGeneric() { | |
47 | return ($this->refTypeColumn !== NULL); | |
48 | } | |
49 | } |