/** * @param Zend_Tool_Framework_Client_Response $response */ public static function setResponse(Zend_Tool_Framework_Client_Response $response) { self::$response = $response; }
public function setRegistry(Zend_Tool_Framework_Registry_Interface $registry) { $response = $registry->getResponse(); ZFscaffold_ZfTool_Helpers_Messages::setResponse($response); return parent::setRegistry($registry); }
private function _deploy($schemaDir, $configs, $currentWorkingDirectory) { if (false !== strpos($currentWorkingDirectory, 'tools')) { $pos = strpos($currentWorkingDirectory, 'tools'); $currentWorkingDirectory = substr($currentWorkingDirectory, 0, $pos - 1); chdir($currentWorkingDirectory); } $_targetDir = Dfi_App_Config::getString('generator.targetDir', $currentWorkingDirectory . '/application/models'); $question = "Target DirProject name ({$_targetDir}): "; $targetDir = $this->_readInput($question); if ('' === $targetDir) { $targetDir = $_targetDir; } unset($_targetDir, $question); Dfi_App_Config::set('generator.targetDir', $targetDir); $propelCnf = array(); $classmap = array(); $sourceDir = ''; foreach ($configs as $key => $config) { $package = Dfi_App_Config::getString('generator.targetPackage.' . $key); $sourceDir = $schemaDir . '/' . $config . '/build'; $map = $targetDir . '/' . $config . '/map'; if (!file_exists($map)) { mkdir($map, 0777, true); } $om = $targetDir . '/' . $config . '/om'; if (!file_exists($om)) { mkdir($om, 0777, true); } $copy = array(); $copy[] = 'cp -n ' . $sourceDir . '/classes/' . $package . '/*.php ' . $targetDir . '/' . $config; $copy[] = 'cp -f ' . $sourceDir . '/classes/' . $package . '/map/*.php ' . $targetDir . '/' . $config . '/map'; $copy[] = 'cp -f ' . $sourceDir . '/classes/' . $package . '/om/*.php ' . $targetDir . '/' . $config . '/om'; $file = $sourceDir . '/conf/classmap-' . $config . '-conf.php'; $arr = (include $file); $classmap = array_merge($classmap, $arr); $propelCnf[$config] = $sourceDir . '/conf/' . $config . '-conf.php'; foreach ($copy as $command) { $out = array(); $val = 0; exec($command, $out, $val); if ($val) { foreach ($out as $line) { ZFscaffold_ZfTool_Helpers_Messages::printOut($line, ZFscaffold_ZfTool_Helpers_Messages::MSG_ERROR); } } } } $default = Dfi_App_Config::getString('generator.default'); $dst = realpath($targetDir . '/..') . '/configs/' . $default . '-conf.php'; $src = $propelCnf[$default]; rename($src, $dst); $dst = realpath($targetDir . '/..') . '/configs/classmap-' . $default . '-conf.php'; $map = '<? return ' . var_export($classmap, true) . ';'; $res = file_put_contents($dst, $map); if (!$res) { ZFscaffold_ZfTool_Helpers_Messages::printOut('error writing classmap:' . $dst, ZFscaffold_ZfTool_Helpers_Messages::MSG_ERROR); } //$currentWorkingDirectory = getcwd(); $configDir = str_replace('/', DIRECTORY_SEPARATOR, $currentWorkingDirectory . '/application/configs/'); $configFilePath = $configDir . 'application.ini'; $rawConfig = parse_ini_file($configFilePath, true, INI_SCANNER_RAW); $rawConfig['production']['db.config'] = 'APPLICATION_PATH' . ' "/configs/' . $default . '-conf.php"'; $res = array(); foreach ($rawConfig as $key => $val) { if (is_array($val)) { $res[] = '[' . $key . ']'; foreach ($val as $skey => $sval) { $res[] = $skey . ' = ' . $this->_parseIniValue($sval); } } else { $res[] = $key . ' = ' . $this->_parseIniValue($val); } } $res = file_put_contents($configFilePath, implode("\r\n", $res)); if (!$res) { ZFscaffold_ZfTool_Helpers_Messages::printOut('error writing app config :' . $configFilePath, ZFscaffold_ZfTool_Helpers_Messages::MSG_ERROR); } foreach ($configs as $config) { $sourceDir = $schemaDir . '/' . $config . '/build'; $command = 'rm -rf ' . $sourceDir; $out = array(); $val = 0; exec($command, $out, $val); if ($val) { foreach ($out as $line) { ZFscaffold_ZfTool_Helpers_Messages::printOut($line, ZFscaffold_ZfTool_Helpers_Messages::MSG_ERROR); } } } }