Exemplo n.º 1
0
 /**
  * Cycle through a list of modules, instantiate them, then install or upgrade them.
  *
  * NOTE: Having one method for install and/or upgrade allows us to recover from crashes during installation,
  * and provides a safety net from accidentally running damaging install commands when we should have done an upgrade
  * to preserve existing data.
  */
 public function processActions($packages = NULL, $install = NULL)
 {
     // Reset the error and warning vars, also create a instance if it doesnt exist
     self::init();
     // Make sure we are ready to install
     self::$packages = self::checkDependencies($packages, $install);
     // If we still dont have a valid packages list then get out of here!
     if (empty($packages) || !is_array($packages)) {
         self::$errors[] = 'Unable to find packages!';
         return false;
     }
     // If we found an error stop the install
     if (!empty(self::$errors)) {
         return false;
     }
     // It is possible that checkDependencies added warnings, so clear those
     self::$warnings = array();
     // This ensures that any modules that depend on another
     // are loaded after their dependencies!
     self::_dependencySort(self::$packages);
     // Instantiate the package configurations with actions to preform
     foreach (self::$packages as $name => $package) {
         if ($package['action']) {
             self::$packages[$name]['instance'] = new $package['configureClass']();
         }
     }
     // Verify all modules are intact
     self::verify();
     // Execute all the pre-action methods
     self::preActions();
     // Execute all the action methods
     self::actions();
     // Execute all the post-action methods
     self::postActions();
     // Execute all the sanityCheck methods
     self::sanityCheck();
     // This internal function lets us keep default finilize behavor
     // Such as determining if a modules dependencies installed sucessfully....
     self::finalize();
     // If we were successful, execute all the global onSuccessInstall/onSuccessUpgrade/onSuccessXXXX methods
     if (empty(self::$errors)) {
         self::completed();
     }
     self::$packages = array();
     return empty(self::$errors);
 }