/** * check method * * @return void * @access public */ public function check() { $return = MiInstall::check(); if ($return === true) { return $this->out('No missing dependencies found'); } $this->out('Missing dependencies found:'); foreach ($return as $missing) { $this->out(' - ' . $missing); } $choice = $this->in("Install missing dependencies?", array('y', 'n')); if ($choice != 'y') { return false; } foreach ($return as $missing) { $this->install($missing); } }
/** * checks and installs dependencies * * @return void * @access public */ public function check($checks = array(), $plugins = null, $vendors = null) { if (!$checks) { MiInstall::_settings(); $checks['app'][APP_DIR] = APP; $checks['plugins'] = $plugins = MiInstall::plugins(); $vendorDirs = App::path('vendors'); $checks['vendors'] = $vendors = MiInstall::vendors(); } else { $checks = array('secondary' => (array) $checks); $plugins = MiInstall::plugins(); $vendors = MiInstall::vendors(); } foreach ($checks as $type => $whats) { foreach ($whats as $what => $dir) { if (is_numeric($what)) { $what = $dir; $dir = null; } if (array_key_exists($what, MiInstall::$_return)) { continue; } if ($what !== APP_DIR) { if (in_array($what, $plugins)) { MiInstall::$_return[$what] = false; } elseif (in_array($what, $vendors)) { MiInstall::$_return[$what] = false; } else { MiInstall::$_return[$what] = 'missing'; } } $details = MiInstall::details($what); if (!$details || empty($details['Depends'])) { continue; } MiInstall::check(array_map('trim', explode(',', $details['Depends'])), $plugins, $vendors); } } $missing = 0; $return = array(); foreach (MiInstall::$_return as $val) { if ($val == 'missing') { $missing++; } } if (!$missing) { return true; } return MiInstall::$_return; }