1: <?php
2:
3: namespace Saklient\Cloud\Resources;
4:
5: require_once __DIR__ . "/../../../Saklient/Errors/SaklientException.php";
6: use \Saklient\Errors\SaklientException;
7: require_once __DIR__ . "/../../../Saklient/Cloud/Client.php";
8: use \Saklient\Cloud\Client;
9: require_once __DIR__ . "/../../../Saklient/Cloud/Resources/Resource.php";
10: use \Saklient\Cloud\Resources\Resource;
11: require_once __DIR__ . "/../../../Saklient/Cloud/Resources/Icon.php";
12: use \Saklient\Cloud\Resources\Icon;
13: require_once __DIR__ . "/../../../Saklient/Cloud/Enums/EScope.php";
14: use \Saklient\Cloud\Enums\EScope;
15: require_once __DIR__ . "/../../../Saklient/Cloud/Enums/EScriptClass.php";
16: use \Saklient\Cloud\Enums\EScriptClass;
17: require_once __DIR__ . "/../../../Saklient/Util.php";
18: use \Saklient\Util;
19:
20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32:
33: class Script extends Resource {
34:
35: 36: 37: 38: 39: 40: 41:
42: protected $m_id;
43:
44: 45: 46: 47: 48: 49: 50:
51: protected $m_scope;
52:
53: 54: 55: 56: 57: 58: 59:
60: protected $m_clazz;
61:
62: 63: 64: 65: 66: 67: 68:
69: protected $m_name;
70:
71: 72: 73: 74: 75: 76: 77:
78: protected $m_description;
79:
80: 81: 82: 83: 84: 85: 86:
87: protected $m_tags;
88:
89: 90: 91: 92: 93: 94: 95:
96: protected $m_icon;
97:
98: 99: 100: 101: 102: 103: 104:
105: protected $m_content;
106:
107: 108: 109: 110: 111: 112: 113:
114: protected $m_annotation;
115:
116: 117: 118: 119: 120: 121:
122: protected function _apiPath()
123: {
124: return "/note";
125: }
126:
127: 128: 129: 130: 131: 132:
133: protected function _rootKey()
134: {
135: return "Note";
136: }
137:
138: 139: 140: 141: 142: 143:
144: protected function _rootKeyM()
145: {
146: return "Notes";
147: }
148:
149: 150: 151: 152: 153: 154:
155: public function _className()
156: {
157: return "Script";
158: }
159:
160: 161: 162: 163: 164: 165:
166: public function _id()
167: {
168: return $this->get_id();
169: }
170:
171: 172: 173: 174: 175: 176:
177: public function save()
178: {
179: return $this->_save();
180: }
181:
182: 183: 184: 185: 186: 187:
188: public function reload()
189: {
190: return $this->_reload();
191: }
192:
193: 194: 195: 196: 197: 198: 199:
200: public function __construct(\Saklient\Cloud\Client $client, $obj, $wrapped=false)
201: {
202: parent::__construct($client);
203: Util::validateArgCount(func_num_args(), 2);
204: Util::validateType($client, "\\Saklient\\Cloud\\Client");
205: Util::validateType($wrapped, "boolean");
206: $this->apiDeserialize($obj, $wrapped);
207: }
208:
209: 210: 211: 212: 213:
214: private $n_id = false;
215:
216: 217: 218: 219: 220: 221: 222:
223: private function get_id()
224: {
225: return $this->m_id;
226: }
227:
228:
229:
230: 231: 232: 233: 234:
235: private $n_scope = false;
236:
237: 238: 239: 240: 241: 242: 243:
244: private function get_scope()
245: {
246: return $this->m_scope;
247: }
248:
249:
250:
251: 252: 253: 254: 255:
256: private $n_clazz = false;
257:
258: 259: 260: 261: 262: 263: 264:
265: private function get_clazz()
266: {
267: return $this->m_clazz;
268: }
269:
270: 271: 272: 273: 274: 275: 276: 277:
278: private function set_clazz($v)
279: {
280: Util::validateArgCount(func_num_args(), 1);
281: Util::validateType($v, "string");
282: $this->m_clazz = $v;
283: $this->n_clazz = true;
284: return $this->m_clazz;
285: }
286:
287:
288:
289: 290: 291: 292: 293:
294: private $n_name = false;
295:
296: 297: 298: 299: 300: 301: 302:
303: private function get_name()
304: {
305: return $this->m_name;
306: }
307:
308:
309:
310: 311: 312: 313: 314:
315: private $n_description = false;
316:
317: 318: 319: 320: 321: 322: 323:
324: private function get_description()
325: {
326: return $this->m_description;
327: }
328:
329: 330: 331: 332: 333: 334: 335: 336:
337: private function set_description($v)
338: {
339: Util::validateArgCount(func_num_args(), 1);
340: Util::validateType($v, "string");
341: $this->m_description = $v;
342: $this->n_description = true;
343: return $this->m_description;
344: }
345:
346:
347:
348: 349: 350: 351: 352:
353: private $n_tags = false;
354:
355: 356: 357: 358: 359: 360: 361:
362: private function get_tags()
363: {
364: $this->n_tags = true;
365: return $this->m_tags;
366: }
367:
368: 369: 370: 371: 372: 373: 374: 375:
376: private function set_tags($v)
377: {
378: Util::validateArgCount(func_num_args(), 1);
379: Util::validateType($v, "\\ArrayObject");
380: if (is_array($v)) $v = Client::array2ArrayObject($v);
381: $this->m_tags = $v;
382: $this->n_tags = true;
383: return $this->m_tags;
384: }
385:
386:
387:
388: 389: 390: 391: 392:
393: private $n_icon = false;
394:
395: 396: 397: 398: 399: 400: 401:
402: private function get_icon()
403: {
404: return $this->m_icon;
405: }
406:
407: 408: 409: 410: 411: 412: 413: 414:
415: private function set_icon(\Saklient\Cloud\Resources\Icon $v=null)
416: {
417: Util::validateArgCount(func_num_args(), 1);
418: Util::validateType($v, "\\Saklient\\Cloud\\Resources\\Icon");
419: $this->m_icon = $v;
420: $this->n_icon = true;
421: return $this->m_icon;
422: }
423:
424:
425:
426: 427: 428: 429: 430:
431: private $n_content = false;
432:
433: 434: 435: 436: 437: 438: 439:
440: private function get_content()
441: {
442: return $this->m_content;
443: }
444:
445: 446: 447: 448: 449: 450: 451: 452:
453: private function set_content($v)
454: {
455: Util::validateArgCount(func_num_args(), 1);
456: Util::validateType($v, "string");
457: $this->m_content = $v;
458: $this->n_content = true;
459: return $this->m_content;
460: }
461:
462:
463:
464: 465: 466: 467: 468:
469: private $n_annotation = false;
470:
471: 472: 473: 474: 475: 476: 477:
478: private function get_annotation()
479: {
480: return $this->m_annotation;
481: }
482:
483:
484:
485: 486: 487: 488: 489: 490: 491:
492: protected function apiDeserializeImpl($r)
493: {
494: Util::validateArgCount(func_num_args(), 1);
495: $this->isNew = $r == null;
496: if ($this->isNew) {
497: $r = (object)[];
498: }
499: $this->isIncomplete = false;
500: if (Util::existsPath($r, "ID")) {
501: $this->m_id = Util::getByPath($r, "ID") == null ? null : "" . Util::getByPath($r, "ID");
502: }
503: else {
504: $this->m_id = null;
505: $this->isIncomplete = true;
506: }
507: $this->n_id = false;
508: if (Util::existsPath($r, "Scope")) {
509: $this->m_scope = Util::getByPath($r, "Scope") == null ? null : "" . Util::getByPath($r, "Scope");
510: }
511: else {
512: $this->m_scope = null;
513: $this->isIncomplete = true;
514: }
515: $this->n_scope = false;
516: if (Util::existsPath($r, "Class")) {
517: $this->m_clazz = Util::getByPath($r, "Class") == null ? null : "" . Util::getByPath($r, "Class");
518: }
519: else {
520: $this->m_clazz = null;
521: $this->isIncomplete = true;
522: }
523: $this->n_clazz = false;
524: if (Util::existsPath($r, "Name")) {
525: $this->m_name = Util::getByPath($r, "Name") == null ? null : "" . Util::getByPath($r, "Name");
526: }
527: else {
528: $this->m_name = null;
529: $this->isIncomplete = true;
530: }
531: $this->n_name = false;
532: if (Util::existsPath($r, "Description")) {
533: $this->m_description = Util::getByPath($r, "Description") == null ? null : "" . Util::getByPath($r, "Description");
534: }
535: else {
536: $this->m_description = null;
537: $this->isIncomplete = true;
538: }
539: $this->n_description = false;
540: if (Util::existsPath($r, "Tags")) {
541: if (Util::getByPath($r, "Tags") == null) {
542: $this->m_tags = new \ArrayObject([]);
543: }
544: else {
545: $this->m_tags = new \ArrayObject([]);
546: foreach (Util::getByPath($r, "Tags") as $t) {
547: $v1 = null;
548: $v1 = $t == null ? null : "" . $t;
549: $this->m_tags->append($v1);
550: }
551: }
552: }
553: else {
554: $this->m_tags = null;
555: $this->isIncomplete = true;
556: }
557: $this->n_tags = false;
558: if (Util::existsPath($r, "Icon")) {
559: $this->m_icon = Util::getByPath($r, "Icon") == null ? null : new Icon($this->_client, Util::getByPath($r, "Icon"));
560: }
561: else {
562: $this->m_icon = null;
563: $this->isIncomplete = true;
564: }
565: $this->n_icon = false;
566: if (Util::existsPath($r, "Content")) {
567: $this->m_content = Util::getByPath($r, "Content") == null ? null : "" . Util::getByPath($r, "Content");
568: }
569: else {
570: $this->m_content = null;
571: $this->isIncomplete = true;
572: }
573: $this->n_content = false;
574: if (Util::existsPath($r, "Remark")) {
575: $this->m_annotation = Util::getByPath($r, "Remark");
576: }
577: else {
578: $this->m_annotation = null;
579: $this->isIncomplete = true;
580: }
581: $this->n_annotation = false;
582: }
583:
584: 585: 586: 587: 588: 589:
590: protected function apiSerializeImpl($withClean=false)
591: {
592: Util::validateType($withClean, "boolean");
593: $missing = new \ArrayObject([]);
594: $ret = (object)[];
595: if ($withClean || $this->n_id) {
596: Util::setByPath($ret, "ID", $this->m_id);
597: }
598: if ($withClean || $this->n_scope) {
599: Util::setByPath($ret, "Scope", $this->m_scope);
600: }
601: if ($withClean || $this->n_clazz) {
602: Util::setByPath($ret, "Class", $this->m_clazz);
603: }
604: if ($withClean || $this->n_name) {
605: Util::setByPath($ret, "Name", $this->m_name);
606: }
607: else {
608: if ($this->isNew) {
609: $missing->append("name");
610: }
611: }
612: if ($withClean || $this->n_description) {
613: Util::setByPath($ret, "Description", $this->m_description);
614: }
615: if ($withClean || $this->n_tags) {
616: Util::setByPath($ret, "Tags", new \ArrayObject([]));
617: foreach ($this->m_tags as $r1) {
618: $v = null;
619: $v = $r1;
620: $ret->{"Tags"}->append($v);
621: }
622: }
623: if ($withClean || $this->n_icon) {
624: Util::setByPath($ret, "Icon", $withClean ? ($this->m_icon == null ? null : $this->m_icon->apiSerialize($withClean)) : ($this->m_icon == null ? (object)['ID' => "0"] : $this->m_icon->apiSerializeID()));
625: }
626: if ($withClean || $this->n_content) {
627: Util::setByPath($ret, "Content", $this->m_content);
628: }
629: else {
630: if ($this->isNew) {
631: $missing->append("content");
632: }
633: }
634: if ($withClean || $this->n_annotation) {
635: Util::setByPath($ret, "Remark", $this->m_annotation);
636: }
637: if ($missing->count() > 0) {
638: throw new SaklientException("required_field", "Required fields must be set before the Script creation: " . implode(", ", (array)($missing)));
639: }
640: return $ret;
641: }
642:
643: 644: 645:
646: public function __get($key) {
647: switch ($key) {
648: case "id": return $this->get_id();
649: case "scope": return $this->get_scope();
650: case "clazz": return $this->get_clazz();
651: case "name": return $this->get_name();
652: case "description": return $this->get_description();
653: case "tags": return $this->get_tags();
654: case "icon": return $this->get_icon();
655: case "content": return $this->get_content();
656: case "annotation": return $this->get_annotation();
657: default: return parent::__get($key);
658: }
659: }
660:
661: 662: 663:
664: public function __set($key, $v) {
665: switch ($key) {
666: case "clazz": return $this->set_clazz($v);
667: case "description": return $this->set_description($v);
668: case "tags": return $this->set_tags($v);
669: case "icon": return $this->set_icon($v);
670: case "content": return $this->set_content($v);
671: default: return parent::__set($key, $v);
672: }
673: }
674:
675: }
676:
677: