Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
relation.php
1
<?php
9
namespace
Bitrix\Main\ORM\Fields\Relations
;
10
11
use
Bitrix\Main\ArgumentException
;
12
use
Bitrix\Main\ORM\Fields\ITypeHintable
;
13
use
Bitrix\Main\SystemException
;
14
use
Bitrix\Main\ORM\Entity
;
15
use
Bitrix\Main\ORM\Fields\Field
;
16
use
Bitrix\Main\ORM\Objectify\EntityObject
;
17
use
Bitrix\Main\ORM\Query\Join
;
18
25
abstract
class
Relation
extends
Field
implements
ITypeHintable
26
{
28
protected
$refEntityName
;
29
31
protected
$refEntity
;
32
34
protected
$joinType
=
null
;
35
37
protected
$cascadeSavePolicy
;
38
40
protected
$cascadeDeletePolicy
;
41
47
public
function
configureCascadeSavePolicy
(
$cascadeSavePolicy
)
48
{
49
$this->cascadeSavePolicy =
$cascadeSavePolicy
;
50
51
return
$this;
52
}
53
59
public
function
configureCascadeDeletePolicy
(
$cascadeDeletePolicy
)
60
{
61
$this->cascadeDeletePolicy =
$cascadeDeletePolicy
;
62
63
return
$this;
64
}
65
71
public
function
getRefEntity()
72
{
73
if
($this->refEntity ===
null
)
74
{
75
// refEntityName could be an object or a data class
76
if
(class_exists($this->refEntityName) && is_subclass_of($this->refEntityName, EntityObject::class))
77
{
79
$refObjectClass =
$this->refEntityName
;
80
$this->refEntityName = $refObjectClass::$dataClass;
81
}
82
83
$this->refEntity =
Entity::getInstance
($this->refEntityName);
84
}
85
86
return
$this->refEntity
;
87
}
88
92
public
function
getRefEntityName
()
93
{
94
return
$this->refEntityName
;
95
}
96
103
public
function
configureJoinType
($type)
104
{
105
$type = strtoupper($type);
106
107
if
(!in_array($type, Join::getTypes(),
true
))
108
{
109
throw
new
ArgumentException
(sprintf(
110
'Unknown join type `%s` in reference `%s` of `%s` entity'
,
111
$type, $this->name, $this->entity->getDataClass()
112
));
113
}
114
115
$this->joinType = $type;
116
117
return
$this;
118
}
119
123
public
function
getJoinType
()
124
{
125
return
$this->joinType
;
126
}
127
131
public
function
getCascadeSavePolicy
()
132
{
133
return
$this->cascadeSavePolicy
;
134
}
135
139
public
function
getCascadeDeletePolicy
()
140
{
141
return
$this->cascadeDeletePolicy
;
142
}
143
149
public
function
getGetterTypeHint
()
150
{
151
return
$this->getRefEntity()->getObjectClass();
152
}
153
159
public
function
getSetterTypeHint
()
160
{
161
return
$this->getRefEntity()->getObjectClass();
162
}
163
}
Bitrix\Main\ArgumentException
Definition
exception.php:34
Bitrix\Main\ORM\Entity
Definition
entity.php:26
Bitrix\Main\ORM\Entity\getInstance
static getInstance($entityName)
Definition
entity.php:103
Bitrix\Main\ORM\Fields\Field
Definition
field.php:25
Bitrix\Main\ORM\Fields\Relations\Relation
Definition
relation.php:26
Bitrix\Main\ORM\Fields\Relations\Relation\$cascadeDeletePolicy
$cascadeDeletePolicy
Definition
relation.php:40
Bitrix\Main\ORM\Fields\Relations\Relation\$joinType
$joinType
Definition
relation.php:34
Bitrix\Main\ORM\Fields\Relations\Relation\getSetterTypeHint
getSetterTypeHint()
Definition
relation.php:159
Bitrix\Main\ORM\Fields\Relations\Relation\$cascadeSavePolicy
$cascadeSavePolicy
Definition
relation.php:37
Bitrix\Main\ORM\Fields\Relations\Relation\getJoinType
getJoinType()
Definition
relation.php:123
Bitrix\Main\ORM\Fields\Relations\Relation\configureCascadeSavePolicy
configureCascadeSavePolicy($cascadeSavePolicy)
Definition
relation.php:47
Bitrix\Main\ORM\Fields\Relations\Relation\configureCascadeDeletePolicy
configureCascadeDeletePolicy($cascadeDeletePolicy)
Definition
relation.php:59
Bitrix\Main\ORM\Fields\Relations\Relation\getRefEntityName
getRefEntityName()
Definition
relation.php:92
Bitrix\Main\ORM\Fields\Relations\Relation\getGetterTypeHint
getGetterTypeHint()
Definition
relation.php:149
Bitrix\Main\ORM\Fields\Relations\Relation\getCascadeDeletePolicy
getCascadeDeletePolicy()
Definition
relation.php:139
Bitrix\Main\ORM\Fields\Relations\Relation\$refEntityName
$refEntityName
Definition
relation.php:28
Bitrix\Main\ORM\Fields\Relations\Relation\$refEntity
$refEntity
Definition
relation.php:31
Bitrix\Main\ORM\Fields\Relations\Relation\configureJoinType
configureJoinType($type)
Definition
relation.php:103
Bitrix\Main\ORM\Fields\Relations\Relation\getCascadeSavePolicy
getCascadeSavePolicy()
Definition
relation.php:131
Bitrix\Main\ORM\Objectify\EntityObject
Definition
entityobject.php:51
Bitrix\Main\ORM\Query\Join
Definition
join.php:19
Bitrix\Main\SystemException
Definition
exception.php:8
Bitrix\Main\ORM\Fields\ITypeHintable
Definition
itypehintable.php:14
Bitrix\Main\ORM\Fields\Relations
Definition
cascadepolicy.php:9
modules
main
lib
orm
fields
relations
relation.php
Создано системой
1.10.0