SchemaReaderProcessStep.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. Lib::loadClass('SchemaReader');
  3. Lib::loadClass('SchemaReaderResourceTableField');
  4. class SchemaReaderProcessStep {
  5. private $_nr;
  6. private $_resourcesRefTable = array();
  7. private $_resources = array();
  8. public function __construct($stepNr) {
  9. $this->_nr = $stepNr;
  10. }
  11. public function parseIniConfig($configData) {
  12. $this->_description = V::get('description', '', $configData);
  13. return true;
  14. }
  15. public function addResource($resource) {
  16. if ($resource instanceof SchemaReaderResourceTableField) {
  17. $this->_resourcesRefTable[$resource->getTableUri()] = true;
  18. }
  19. $resourceUri = $resource->getUri();
  20. if (array_key_exists($resourceUri, $this->_resources)) {
  21. $this->_resources[$resourceUri]->addPerms($resource->getPerms());
  22. } else {
  23. $this->_resources[$resourceUri] = $resource;
  24. }
  25. }
  26. public function hasTables() {
  27. return !empty($this->_resourcesFields);
  28. }
  29. public function getTables() {
  30. $tbls = array();
  31. foreach ($this->_resourcesRefTable as $tblUri => $vBool) {
  32. $configData = array('type'=>'Table');
  33. $tbl = SchemaReader::buildFromIni($tblUri, $configData);
  34. foreach ($this->_resources as $resource) {
  35. if ($resource instanceof SchemaReaderResourceTableField) {
  36. if ($tbl->getUri() == $resource->getTableUri()) {
  37. $tbl->addField($resource);
  38. }
  39. }
  40. }
  41. $tbls[$tblUri] = $tbl;
  42. }
  43. return $tbls;
  44. }
  45. }