RefConfig.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /* TODO: ACL::getChildRefFullList($namespace); returns array with:
  3. // [0] => Array:
  4. // [namespace] => default_db__x3A__BI_audit_ENERGA_PRACOWNICY_adresy:BI_audit_ENERGA_PRACOWNICY_adresy // TODO: childName
  5. // [A_STATUS] => NORMAL
  6. // [ID] => 27
  7. // [SOURCE] => backRef
  8. */
  9. class Type_RefConfig {
  10. var $_data = [];
  11. static function build($refConfig = []) {
  12. if (!$refConfig) throw new Exception("Missing data in build Type RefConfig");
  13. // if (!$refConfig['ID']) throw new Exception("Missing ID in Type RefConfig build"); // TODO: allow missing ID?
  14. $instance = new Type_RefConfig();
  15. if (!empty($refConfig['ID'])) $instance->id = (int)$refConfig['ID'];
  16. if (!empty($refConfig['ROOT_OBJECT_NS'])) $instance->objectNamespace = $refConfig['ROOT_OBJECT_NS']; // namespace
  17. if (!empty($refConfig['CHILD_NAME'])) $instance->childName = $refConfig['CHILD_NAME']; // typeName
  18. if (!empty($refConfig['CHILD_NS'])) $instance->childNamespace = $refConfig['CHILD_NS']; // namespace
  19. $instance->source = $refConfig['SOURCE'];
  20. $instance->status = $refConfig['A_STATUS'];
  21. $instance->version = $refConfig['VERSION'];
  22. return $instance;
  23. }
  24. function __isset($name) {
  25. return (array_key_exists($name, $this->_data));
  26. }
  27. function __get($name) {
  28. if (array_key_exists($name, $this->_data)) {
  29. return $this->_data[$name];
  30. }
  31. return null;
  32. }
  33. function __set($name, $value) {
  34. $this->_data[$name] = $value;
  35. }
  36. function toArray() {
  37. return $this->_data;
  38. }
  39. function __toString() {
  40. return str_replace('"', '',
  41. str_replace([ '{', '}', '":', ',"' ], [ '{ ', ' }', ': ', ', ' ], json_encode($this->_data))
  42. );
  43. }
  44. }