public static function manage(Event $event, $extras, $newCopy) { $ciAppDir = realpath($extras['ci-app-dir']) . DIRECTORY_SEPARATOR; $libBaseDir = $ciAppDir . "core" . DIRECTORY_SEPARATOR; if ($extras['localize-ready']) { self::install('Lang', $libBaseDir); self::install('Config', $libBaseDir); $routeSource = Manager::getResourcePath('routes.php.mu', '/config'); } else { self::remove('Config', $libBaseDir); self::remove('Lang', $libBaseDir); $routeSource = Manager::getResourcePath('routes.php', '/config'); } $routeDest = $ciAppDir . "config" . DIRECTORY_SEPARATOR . 'routes.php'; $writeRoute = TRUE; $io = $event->getIO(); if (!$newCopy) { $writeMode = "Updating"; if (file_exists($routeDest)) { $confirmMsg = Colors::confirm("Re-Write Route Configuration File(yes,no)?[no]") . " :"; $writeRoute = $io->askConfirmation($confirmMsg, FALSE); } } else { $writeMode = PHP_EOL . "Writing"; } if ($writeRoute) { $io->write(Colors::message(sprintf("%s Route Configuration File ", $writeMode)) . Colors::info('"config/routes.php"')); copy($routeSource, $routeDest); } }
private static function writeConfig($event, $appDirectory, $extras) { $configFile = $appDirectory . DIRECTORY_SEPARATOR . "config" . DIRECTORY_SEPARATOR . 'config.php'; $configEnableTwig = self::getConfigValue($configFile, 'enable_twig'); if ($extras['use-twig'] == $configEnableTwig) { return; } if (!self::$newCopy) { $io = $event->getIO(); $msg = Colors::message('Updating ') . Colors::info('"config/config.php"') . "...."; $io->write(Colors::message($msg) . PHP_EOL); } $configFileData = file_get_contents($configFile); $searchPattern = '/(enable_twig\\' . "'" . '[\\]\\s=]*)([truefalseTRUEFALSE]{4,5})/'; $replacement = '${1}' . ($extras['use-twig'] ? 'TRUE' : 'FALSE'); $configFileData = preg_replace($searchPattern, $replacement, $configFileData); file_put_contents($configFile, $configFileData); }
private static function getWritableDatabaseConfigurationValues(Event $event, $dist_config, $current_config) { $changed_config = array(); $io = $event->getIO(); $firstEntry = TRUE; foreach ($dist_config as $key => $config) { if (!isset(self::$configurableDatabaseOptions[$key]) && $config !== '~') { continue; } if (!isset($current_config[$key]) || $current_config[$key] == '~') { if ($firstEntry) { $message = Colors::message("%s ") . Colors::info('"%s"') . Colors::message(" File"); if (empty($current_config)) { $typeStr = "Writting"; $message2 = Colors::info("Enter Database Configuration options :"); } else { $typeStr = "Updating"; $message2 = Colors::info("Some parameters are missing. Please provide them :"); } $io->write(PHP_EOL . sprintf($message, $typeStr, 'config/database.php')); $io->write($message2); $firstEntry = FALSE; } $default_value = $config == "~" || $config == "" ? 'null' : $config; $question = sprintf('Enter value for "%s" [%s] :', Colors::highlight($key), Colors::info($default_value)); $data = $io->ask($question, $config); if (!self::validateDatabaseConfiguration($data, $key)) { $data = $config; } $changed_config[$key] = $data; } } if (!empty($changed_config)) { $changed_config = array_merge($dist_config, $current_config, $changed_config); } return $changed_config; }