src/ItePHP/Root.php
private function initConfig(){
		//config structure
		$structureConfig=new ConfigBuilder();

		$xmlReader=new XMLReader($this->environment->getConfigPath().'/structure.xml');
		$structureConfig->addReader($xmlReader);

        $structureConfig->addArray('structure',new ConfigBuilderValue("string"));

		$structureContainer=$structureConfig->parse();

		$xmlReader=new XMLReader($this->environment->getConfigPath().'/'.$this->environment->getName().'.xml');
		$mainConfig=new ConfigBuilder();
        $mainConfig->addReader($xmlReader);
        $mainConfig->addFilter(function (ParserProcess $process){//import
            if($process->getType()!=='string' || $process->getPath()!=='root->import'){
                return;
            }

            $xmlReader=new XMLReader($this->environment->getConfigPath().'/'.$process->getValue());
            $process->addReader($xmlReader);

        });

        $variables=[];
        $mainConfig->addFilter(function (ParserProcess $process) use (&$variables){

            if($process->getType()!=='array' || $process->getPath()!=='root->variable') {
                return;
            }
            /**
             * @var ConfigBuilderObject $value
             */
            foreach($process->getValue() as $value){
                $variables[$value->getValue('name')]=$value->getValue('value');
            }

        });

        $mainConfig->addFilter(function (ParserProcess $process) use(&$variables){
            if(in_array($process->getType(),['string','boolean','mixed','number']) && is_string($process->getValue())){

                $value=$process->getValue();
                preg_match_all('/@\{(.+?)\}/',$process->getValue(),$matches);
                for($i=0; $i<count($matches[0]); $i++){
                    if(is_string($variables[$matches[1][$i]]) && $value!==$matches[0][$i]){
                        $value=str_replace($matches[0][$i],$variables[$matches[1][$i]],$value);
                        continue;
                    }
                    $value=$variables[$matches[1][$i]];

                }
                $process->setValue($value);

            }
        });

        //config structure
        $importStructure=new ImportStructure();
        $importStructure->doConfig($mainConfig);

        $variableStructure=new VariableStructure();
        $variableStructure->doConfig($mainConfig);

        //$xmlReader=new XMLReader($this->environment->getConfigPath().'/'.$importValue);

        foreach($structureContainer->getArray('structure') as $structureValue){
            /**
             * @var Structure $structureObj
             */
			$structureObj=new $structureValue();
			$structureObj->doConfig($mainConfig);
		}
		$this->config=$mainConfig->parse();
	}
private function initConfig(){
		//config structure
		$structureConfig=new ConfigBuilder();

		$xmlReader=new XMLReader($this->environment->getConfigPath().'/structure.xml');
		$structureConfig->addReader($xmlReader);

        $structureConfig->addArray('structure',new ConfigBuilderValue("string"));

		$structureContainer=$structureConfig->parse();

		$xmlReader=new XMLReader($this->environment->getConfigPath().'/'.$this->environment->getName().'.xml');
		$mainConfig=new ConfigBuilder();
        $mainConfig->addReader($xmlReader);
        $mainConfig->addFilter(function (ParserProcess $process){//import
            if($process->getType()!=='string' || $process->getPath()!=='root->import'){
                return;
            }

            $xmlReader=new XMLReader($this->environment->getConfigPath().'/'.$process->getValue());
            $process->addReader($xmlReader);

        });

        $variables=[];
        $mainConfig->addFilter(function (ParserProcess $process) use (&$variables){

            if($process->getType()!=='array' || $process->getPath()!=='root->variable') {
                return;
            }
            /**
             * @var ConfigBuilderObject $value
             */
            foreach($process->getValue() as $value){
                $variables[$value->getValue('name')]=$value->getValue('value');
            }

        });

        $mainConfig->addFilter(function (ParserProcess $process) use(&$variables){
            if(in_array($process->getType(),['string','boolean','mixed','number']) && is_string($process->getValue())){

                $value=$process->getValue();
                preg_match_all('/@\{(.+?)\}/',$process->getValue(),$matches);
                for($i=0; $i<count($matches[0]); $i++){
                    if(is_string($variables[$matches[1][$i]]) && $value!==$matches[0][$i]){
                        $value=str_replace($matches[0][$i],$variables[$matches[1][$i]],$value);
                        continue;
                    }
                    $value=$variables[$matches[1][$i]];

                }
                $process->setValue($value);

            }
        });

        //config structure
        $importStructure=new ImportStructure();
        $importStructure->doConfig($mainConfig);

        $variableStructure=new VariableStructure();
        $variableStructure->doConfig($mainConfig);

        //$xmlReader=new XMLReader($this->environment->getConfigPath().'/'.$importValue);

        foreach($structureContainer->getArray('structure') as $structureValue){
            /**
             * @var Structure $structureObj
             */
			$structureObj=new $structureValue();
			$structureObj->doConfig($mainConfig);
		}
		$this->config=$mainConfig->parse();
	}
private function initConfig ( ) { //config structure $ structureConfig = new ConfigBuilder ( ) ; $ xmlReader = new XMLReader ( $ this -> environment -> getConfigPath ( ) . '/structure.xml' ) ; $ structureConfig -> addReader ( $ xmlReader ) ; $ structureConfig -> addArray ( 'structure' , new ConfigBuilderValue ( "string" ) ) ; $ structureContainer = $ structureConfig -> parse ( ) ; $ xmlReader = new XMLReader ( $ this -> environment -> getConfigPath ( ) . '/' . $ this -> environment -> getName ( ) . '.xml' ) ; $ mainConfig = new ConfigBuilder ( ) ; $ mainConfig -> addReader ( $ xmlReader ) ; $ mainConfig -> addFilter ( function ( ParserProcess $ process ) { //import if ( $ process -> getType ( ) !== 'string' || $ process -> getPath ( ) !== 'root->import' ) { return ; } $ xmlReader = new XMLReader ( $ this -> environment -> getConfigPath ( ) . '/' . $ process -> getValue ( ) ) ; $ process -> addReader ( $ xmlReader ) ; } ) ; $ variables = [ ] ; $ mainConfig -> addFilter ( function ( ParserProcess $ process ) use ( & $ variables ) { if ( $ process -> getType ( ) !== 'array' || $ process -> getPath ( ) !== 'root->variable' ) { return ; } /**
             * @var ConfigBuilderObject $value
             */ foreach ( $ process -> getValue ( ) as $ value ) { $ variables [ $ value -> getValue ( 'name' ) ] = $ value -> getValue ( 'value' ) ; } } ) ; $ mainConfig -> addFilter ( function ( ParserProcess $ process ) use ( & $ variables ) { if ( in_array ( $ process -> getType ( ) , [ 'string' , 'boolean' , 'mixed' , 'number' ] ) && is_string ( $ process -> getValue ( ) ) ) { $ value = $ process -> getValue ( ) ; preg_match_all ( '/@\{(.+?)\}/' , $ process -> getValue ( ) , $ matches ) ; for ( $ i = 0 ; $ i < count ( $ matches [ 0 ] ) ; $ i ++ ) { if ( is_string ( $ variables [ $ matches [ 1 ] [ $ i ] ] ) && $ value !== $ matches [ 0 ] [ $ i ] ) { $ value = str_replace ( $ matches [ 0 ] [ $ i ] , $ variables [ $ matches [ 1 ] [ $ i ] ] , $ value ) ; continue ; } $ value = $ variables [ $ matches [ 1 ] [ $ i ] ] ; } $ process -> setValue ( $ value ) ; } } ) ; //config structure $ importStructure = new ImportStructure ( ) ; $ importStructure -> doConfig ( $ mainConfig ) ; $ variableStructure = new VariableStructure ( ) ; $ variableStructure -> doConfig ( $ mainConfig ) ; //$xmlReader=new XMLReader($this->environment->getConfigPath().'/'.$importValue); foreach ( $ structureContainer -> getArray ( 'structure' ) as $ structureValue ) { /**
             * @var Structure $structureObj
             */ $ structureObj = new $ structureValue ( ) ; $ structureObj -> doConfig ( $ mainConfig ) ; } $ this -> config = $ mainConfig -> parse ( ) ; }
Init framework config
Init framework config