/** * install method * * @return void * @access public */ public function install($id = null) { if (!$id) { if (!$this->args) { $id = $this->_choosePackage(); } else { $id = $this->args[0]; } } $details = MiInstall::details($id); if (!empty($details['Depends'])) { $result = MiInstall::check($details['Depends']); if ($result !== true) { $dependsString = "\n" . implode($result, ",\n"); $this->out("{$id} depends upon the following pacakges: {$dependsString}"); if (!$missing) { $choice = $this->in('Missing dependencies will be installed automatically. Continue?', array('y', 'n')); if ($choice == 'n') { return false; } } } } $this->_chooseBase($details, $this->settings); $result = MiInstall::install($id, $this->settings); $this->_neatOut($result); /* if (empty($cmd)) { return false; } $return = Mi::exec($cmd); if ($return[0]) { return false; } if (file_exists($this->params['working'] . DS . 'config' . DS . 'database.php')) { $schema = $target . DS . 'config' . DS . 'schema' . DS . $id . '.php'; if (file_exists($schema)) { $this->dbUpdate($id, $schema); } } */ }
/** * install method * * @param mixed $id null * @param array $params array() * @return void * @access public */ public function install($id = null, $params = array()) { $defaultParams = array('base' => dirname(array_pop(App::path('vendors')))); $params = array_merge($defaultParams, $params); if (!$id) { return false; } if (is_array($id)) { $id = $id['Package']; $details = $id; } else { $details = MiInstall::details($id); } $return = true; $out = array(); if ($details['Type'] !== 'virtual') { $target = $params['base'] . DS . Inflector::pluralize($details['Type']) . DS . $details['Package']; if (strpos($details['Source'], 'svn') !== false) { $cmd = "svn co {$details['Source']} {$target}"; } elseif (strpos($details['Source'], 'git') !== false) { $cmd = "git clone {$details['Source']} {$target}"; } if (empty($cmd)) { return false; } $return = MiInstall::_exec($cmd, $out); if (!$return) { return false; } if (!empty($details['PostInstallScript'])) { MiInstall::_exec('cd ' . $target . ' && ' . $details['PostInstallScript'], $_out); $out = array_merge($out, $_out); } } if (empty($details['Depends'])) { return array($return, $out); } $plugins = MiInstall::plugins(); $vendors = MiInstall::vendors(); $dependencies = array_map('trim', explode(',', $details['Depends'])); foreach ($dependencies as $dep) { if (isset($plugins[$dep]) || isset($vendors[$dep])) { continue; } $details = MiInstall::details($dep); $target = $params['base'] . DS . Inflector::pluralize($details['Type']) . DS . $details['Package']; if (!is_dir($target)) { $_out = MiInstall::install($dep, $params); if ($_out) { $out = array_merge($out, $_out); } } } return array($return, $out); }