コード例 #1
0
 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);
     }
 }
コード例 #2
0
 private static function buildBootstrap($event, $bootstrap, $extras, $webDirectory, $ciBasePath)
 {
     $io = $event->getIO();
     if (file_exists($bootstrap)) {
         $writeMode = "Updating";
         $confirmMsg = Colors::confirm("Re-Write Bootstrap File(yes,no)?[no]") . " :";
         $writeBootstrap = $io->askConfirmation($confirmMsg, FALSE);
         if ($writeBootstrap) {
             $data = file_get_contents($bootstrap);
             preg_match("/define\\('ENVIRONMENT',(\\s)*'([a-z]+)'\\);/", $data, $matches);
             if (isset($matches[2])) {
                 self::$environment = $matches[2];
             }
         }
     } else {
         $writeMode = "Writing";
         $writeBootstrap = TRUE;
     }
     if ($writeBootstrap) {
         $confirmMsg = sprintf("Set application environment to(production,development,testing)?[%s] :", Colors::info(self::$environment));
         $env = $io->ask($confirmMsg, self::$environment);
         if (in_array($env, self::$validEnvironments)) {
             self::$environment = $env;
         } else {
             $msg = Colors::error("Invalid selection!") . PHP_EOL;
             $msg .= Colors::message("Setting the environment to : ") . Colors::highlight(self::$environment);
             $io->write($msg);
         }
         $io->write(Colors::message(sprintf("%s Bootstrap File ", $writeMode)) . PHP_EOL);
         self::writeBootstrap($bootstrap, $extras, $webDirectory, $ciBasePath);
     }
 }