Schema_TableBase.php 894 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. // @docs in Schema_TableFactory
  3. class Schema_TableBase {
  4. public function __construct() {
  5. $this->_types = array();
  6. $this->_restrictions = array();
  7. $this->initTypes();
  8. }
  9. public function initTypes() {// TODO: override
  10. // parent::initTypes();// always call parent method
  11. // example: $this->_types['WWW'] = 'p5:www_link';
  12. // example: $this->_restrictions['WWW'] = ['maxLength' => 255]
  13. // TODO:? $this->_types['WWW'] = new Type_Link($params = ['maxLength' => 255, ...]);
  14. }
  15. public function fixTypes($types) {
  16. if (!is_array($this->_types)) return;
  17. foreach ($types as $fldName => $type) {
  18. if (array_key_exists($fldName, $this->_types)) {
  19. $types[$fldName]['simpleType'] = $this->_types[$fldName];
  20. }
  21. if (array_key_exists($fldName, $this->_restrictions)) {
  22. $types[$fldName]['restrictions'] = $this->_restrictions[$fldName];
  23. }
  24. }
  25. return $types;
  26. }
  27. }