Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
relation.php
1<?php
10
18
25abstract class Relation extends Field implements ITypeHintable
26{
28 protected $refEntityName;
29
31 protected $refEntity;
32
34 protected $joinType = null;
35
38
41
48 {
49 $this->cascadeSavePolicy = $cascadeSavePolicy;
50
51 return $this;
52 }
53
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 {
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 {
134 }
135
139 public function getCascadeDeletePolicy()
140 {
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}
static getInstance($entityName)
Definition entity.php:103
configureCascadeSavePolicy($cascadeSavePolicy)
Definition relation.php:47
configureCascadeDeletePolicy($cascadeDeletePolicy)
Definition relation.php:59