Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
base_object.php
1<?php
3
9abstract class BaseObject
10{
12 public $parent = null;
13 public $name = '';
14 public $body = '';
15 protected $ciName = '';
16
20 public function __construct($name = '')
21 {
22 $this->name = (string)$name;
23 $this->ciName = static::getCompareName($this->name);
24 }
25
33 public function setBody($body)
34 {
35 $this->body = trim($body);
36 return $this;
37 }
38
48 public function setParent(BaseObject $parent = null)
49 {
50 $this->parent = $parent;
51 return $this;
52 }
53
61 final public function getUnquotedName($name = null)
62 {
63 if ($name === null && $this->name)
64 {
65 return $this->getUnquotedName($this->name);
66 }
67 elseif (is_array($name))
68 {
69 foreach ($name as $key => $value)
70 {
71 $name[$key] = $this->getUnquotedName($value);
72 }
73 }
74 elseif ($name[0] == '`')
75 {
76 $name = trim($name, '`');
77 }
78 elseif ($name[0] == '"')
79 {
80 $name = trim($name, '"');
81 }
82 elseif ($name[0] == '[')
83 {
84 $name = trim($name, '[]');
85 }
86 return $name;
87 }
88
96 final public function getLowercasedName()
97 {
98 if ($this->name[0] == '`')
99 {
100 return $this->name;
101 }
102 elseif ($this->name[0] == '"')
103 {
104 return $this->name;
105 }
106 elseif ($this->name[0] == '[')
107 {
108 return $this->name;
109 }
110 else
111 {
112 return mb_strtolower($this->name);
113 }
114 }
115
124 final public static function getCompareName($name)
125 {
126 if ($name)
127 {
128 if ($name[0] == '`')
129 {
130 return substr($name, 1, -1);
131 }
132 elseif ($name[0] == '"')
133 {
134 return substr($name, 1, -1);
135 }
136 elseif ($name[0] == '[')
137 {
138 return substr($name, 1, -1);
139 }
140 else
141 {
142 return mb_strtoupper($name);
143 }
144 }
145 else
146 {
147 return $name;
148 }
149 }
150
160 final public function compareName($name)
161 {
162 return strcmp($this->ciName, static::getCompareName($name));
163 }
164
172 public function getCreateDdl($dbType = '')
173 {
174 return '// ' . get_class($this) . ':getCreateDdl not implemented';
175 }
176
184 public function getDropDdl($dbType = '')
185 {
186 return '// ' . get_class($this) . ':getDropDdl not implemented';
187 }
188
197 public function getModifyDdl(BaseObject $target, $dbType = '')
198 {
199 return '// ' . get_class($this) . ':getModifyDdl not implemented';
200 }
201}
getModifyDdl(BaseObject $target, $dbType='')
setParent(BaseObject $parent=null)