public function generateConfigInternal() { $indentation = ' '; $indent = function ($content) use($indentation) { return preg_replace('/(:?^|[\\n])/', '$1' . $indentation, $content); }; $generator = new CM_Config_Generator(); $classTypesConfig = $generator->getConfigClassTypes()->exportAsString('$config'); $actionVerbsConfig = $generator->getConfigActionVerbs()->exportAsString('$config'); foreach ($generator->getClassTypesRemoved() as $classRemoved) { $this->_getStreamOutput()->writeln('Removed `' . $classRemoved . '`'); } foreach ($generator->getClassTypesAdded() as $type => $classAdded) { $this->_getStreamOutput()->writeln('Added `' . $classAdded . '` with type `' . $type . '`'); } // Create model class types and action verbs config PHP $configPhp = new CM_File(DIR_ROOT . 'resources/config/internal.php'); $configPhp->ensureParentDirectory(); $configPhp->truncate(); $configPhp->appendLine('<?php'); $configPhp->appendLine('// This is autogenerated config file. You should not change it manually.'); $configPhp->appendLine(); $configPhp->appendLine('return function (CM_Config_Node $config) {'); $configPhp->appendLine($indent($classTypesConfig)); $configPhp->appendLine($indent($actionVerbsConfig)); $configPhp->appendLine('};'); $this->_getStreamOutput()->writeln('Created `' . $configPhp->getPath() . '`'); // Create model class types and action verbs config JS $configJs = new CM_File(DIR_ROOT . 'resources/config/js/internal.js'); $configJs->ensureParentDirectory(); $configJs->truncate(); $classTypes = $generator->getNamespaceTypes(); $configJs->appendLine('cm.model.types = ' . CM_Util::jsonEncode(array_flip($classTypes['CM_Model_Abstract']), true) . ';'); $configJs->appendLine('cm.action.types = ' . CM_Util::jsonEncode(array_flip($classTypes['CM_Action_Abstract']), true) . ';'); $this->_getStreamOutput()->writeln('Created `' . $configJs->getPath() . '`'); }