| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <?php
- Lib::loadClass('Core_Config_INI');
- Lib::loadClass('SchemaReaderProcess');
- class SchemaReader {
- private $_schemaPathProcess;
- private $_configIniSuffix;
- private $_configs = null;
- public function __construct() {
- $this->_schemaPathProcess = APP_PATH_SCHEMA . DS . 'process';
- $this->_configIniSuffix = '.ini.php';
- }
- public function getAll() {
- if (!is_array($this->_configs)) {
- $this->_configs = array();
- $fileGlob = "{$this->_schemaPathProcess}/*{$this->_configIniSuffix}";
- $files = glob($fileGlob);
- foreach ($files as $file) {
- $this->_parseIniFile($file);
- }
- }
- }
- private function _parseIniFile($file) {
- $fileName = basename($file, $this->_configIniSuffix);
- $config = new Core_Config_INI($file);
- $configData = $config->getData();
- $type = $config->get('type', 'CONFIG');
- if (!$type) {
- return;
- }
- $className = "SchemaReader" . ucfirst(strtolower($type));
- if (!class_exists($className)) {
- return;
- }
- $reader = new $className();
- if (!$reader->parseIniConfig($config)) {
- return;
- }
- $this->_configs[$fileName] = $reader;
- }
- public function hasProcessConfigs() {
- return !empty($this->_configs);
- }
- public function getProcessConfigs() {
- return $this->_configs;
- }
- public function findTblInfoByUri($uri) {
-
- }
- public static function buildProcessStepFromIni($stepNr, $configData) {
- $className = "SchemaReaderProcessStep";
- if (!Lib::loadClass($className)) {
- return null;
- }
- $step = new $className($stepNr);
- if (!$step->parseIniConfig($configData)) {
- return null;
- }
- return $step;
- }
- public static function buildFromIni($resourceUri, $configData) {
- $resourceType = V::get('type', '', $configData);
- if (!$resourceType) {
- echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;"> (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r("!resourceType");echo'</pre>';
- return null;
- }
- $className = "SchemaReaderResource{$resourceType}";
- if (!Lib::loadClass($className)) {
- return null;
- }
- $resource = new $className($resourceUri);
- if (!$resource->parseIniConfig($configData)) {
- return null;
- }
- return $resource;
- }
- }
|