Example #1
0
 public function finalize($identifier)
 {
     $package =& Package_Catalog::getPackageByIdentifier($identifier);
     $package['status'] = Package_Manager::STATUS_INSTALLED;
     Package_Catalog_Datastore::export($package);
     Package_Catalog::buildCatalog();
     $configureInstance = Package_Catalog::getPackageConfigureInstance($identifier);
     $configureInstance->finalizeInstall($identifier);
 }
Example #2
0
 protected static function runCheckMethods($identifier)
 {
     $configureInstance = Package_Catalog::getPackageConfigureInstance($identifier);
     $checkMethods = get_class_methods(get_class($configureInstance));
     $checkMethods = array_filter($checkMethods, array(__CLASS__, '_filterCheckMethods'));
     if (empty($checkMethods) || !is_array($checkMethods)) {
         return;
     }
     foreach ($checkMethods as $checkMethod) {
         try {
             Package_Message::log('debug', 'Running check method ' . get_class($configureInstance) . '::' . $checkMethod . '();');
             $return = call_user_func(array($configureInstance, $checkMethod));
         } catch (Exception $e) {
             //TODO: Still have not figure out how to handle errors...
         }
     }
 }
Example #3
0
 /**
  * Use this function to create a new account, location and user all in one shot. You will get an associative array back containing
  * the new account, location and user IDs, respectively
  * @param string $username
  * @param string $password
  * @param string $accountName
  * @param string $locationName
  * @return array
  *
  * TODO: Should we just pass in a list of options, and then pass it around accordingly?
  */
 public static function initializeTenant($options, $users = array())
 {
     // Add the core admin user to the system
     // TODO: Should check for errors here...
     Kohana::log('debug', 'Initializing account...');
     try {
         $accountId = self::initializeAccount($options['account']);
         self::$accountName = $options['account']['name'];
     } catch (Exception $e) {
         Kohana::log('error', 'Creating account failed: ' . $e->getMessage());
         // Bubble up
         throw $e;
     }
     Kohana::log('debug', 'Initializing location...');
     try {
         $locationId = self::initializeLocation($accountId, $options['location']);
     } catch (Exception $e) {
         Kohana::log('error', 'Creating location failed (rolling back tenant): ' . $e->getMessage());
         $account = Doctrine::getTable('Account')->find($accountId);
         $account->delete();
         self::$accountName = NULL;
         // Bubble up
         throw $e;
     }
     Kohana::log('debug', 'Initializing user...');
     try {
         $userId = self::initializeUser($accountId, $locationId, $options['user']);
     } catch (Exception $e) {
         Kohana::log('error', 'Creating user failed (rolling back tenant: ' . $e->getMessage());
         $location = Doctrine::getTable('Location')->find($locationId);
         $location->delete();
         $account = Doctrine::getTable('Account')->find($accountId);
         $account->delete();
         self::$accountName = NULL;
         // Bubble up
         throw $e;
     }
     Kohana::log('debug', 'Initializing contexts...');
     self::initializeContext($accountId);
     Kohana::log('debug', 'Scanning packages for tenant-setup routines.');
     Package_Catalog::buildCatalog();
     $packagelist = Package_Catalog::getPackageList();
     foreach ($packagelist as $name => $packages) {
         if (empty($packages[Package_Manager::STATUS_INSTALLED])) {
             continue;
         }
         $installed = reset($packages[Package_Manager::STATUS_INSTALLED]);
         try {
             $configureInstance = Package_Catalog::getPackageConfigureInstance($installed['identifier']);
             if (method_exists($configureInstance, 'createTenant')) {
                 $configureInstance->createTenant($package);
                 Kohana::log('debug', 'Multi-tenant initialization routine for ' . $package['packageName'] . ' complete');
             }
         } catch (Exception $e) {
             Kohana::log('error', 'Multi-tenant initialization routine createTenant failed on ' . $package['packageName'] . ': ' . $e->getMessage());
             message::set('Unable to initialize tenant!' . '<div class="error_details">' . $e->getMessage() . '</div>');
             self::$accountName = NULL;
             return false;
         }
     }
     Kohana::log('debug', 'Done creating tenant.');
     self::$accountName = NULL;
     self::$created = array('userId' => $userId, 'locationId' => $locationId, 'accountId' => $accountId);
     // You can get everything you need from here
     return array('userId' => $userId, 'locationId' => $locationId, 'accountId' => $accountId);
 }
Example #4
0
 public function exec($identifier)
 {
     $configureInstance = Package_Catalog::getPackageConfigureInstance($identifier);
     $configureInstance->repair($identifier);
 }
Example #5
0
 public function postExec($identifier)
 {
     $configureInstance = Package_Catalog::getPackageConfigureInstance($identifier);
     $configureInstance->postMigrate($identifier);
 }