| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- <?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) {
- throw new Exception("Wrong resource type - cannot build from ini file");
- }
- $className = "SchemaReaderResource{$resourceType}";
- if (!Lib::loadClass($className)) {
- return null;
- }
- $resource = new $className($resourceUri);
- if (!$resource->parseIniConfig($configData)) {
- return null;
- }
- return $resource;
- }
- }
|