src/Controller/Admin/Setup/Helpers/Install.php
public function superadmin(User $account, Container $application, Database $database){

        //@TODO create master user account
        //1. Load the model

        $config     = $this->config;
        //$database   = \Library\Database::getInstance();

        //2. Prevalidate passwords and other stuff;
        $username   = $application->input->getString("user_first_name",  "","post", FALSE, array());
        $usernameid = $application->input->getString("user_name_id", "","post",FALSE, array());
        $userpass   = $application->input->getString("user_password", "", "post", FALSE, array());
        $userpass2  = $application->input->getString("user_password_2", "", "post", FALSE, array());
        $useremail  = $application->input->getString("user_email", "", "post", FALSE, array());
        //3. Encrypt validated password if new users!
        //4. If not new user, check user has update permission on this user
        //5. MailOut
        
        if(empty($userpass)||empty($username)||empty($usernameid)||empty($useremail)){
            //Display a message telling them what can't be empty
            throw new Exception(t('Please provide at least a Name, Username, E-mail and Password') );
            return false;
        }
        
        //Validate the passwords
        if($userpass <> $userpass2){
            throw new Exception(t('The user passwords do not match') );
            return false;
        }
        
        //6. Store the user
        if(!$account->store( $application->input->data("post") , true)){
            //Display a message telling them what can't be empty
            throw new Exception( t('Could not store the admin user account')  );
            return false;
        }

        //Add this user to the superadministrators group!
        //$adminObject    = $account->getObjectByURI( $usernameid );
        $adminAuthority = $this->config->get( "setup.site.superadmin-authority", NULL);
        //Default Permission Group?
        if(!empty($adminAuthority)){
            $query = "INSERT INTO ?objects_authority( authority_id, object_id ) SELECT {$database->quote((int)$adminAuthority)}, object_id FROM ?objects WHERE object_uri={$database->quote($usernameid)}";
            $database->exec($query);
        }
        
        //@TODO Empty the setup/sessions folder
       // \Library\Folder::deleteContents( APPPATH."setup".DS."sessions" ); //No need to through an error
        
        //Completes installation

        //set session handler to database if database is connectable
        $config->set("setup.session.store", "database");
        $config->set("setup.database.installed", TRUE  );


        if(!$config->saveParams() ){

            throw new Exception("could not save config");

            return false;
        }
        return true;
    }
public function superadmin(User $account, Container $application, Database $database){

        //@TODO create master user account
        //1. Load the model

        $config     = $this->config;
        //$database   = \Library\Database::getInstance();

        //2. Prevalidate passwords and other stuff;
        $username   = $application->input->getString("user_first_name",  "","post", FALSE, array());
        $usernameid = $application->input->getString("user_name_id", "","post",FALSE, array());
        $userpass   = $application->input->getString("user_password", "", "post", FALSE, array());
        $userpass2  = $application->input->getString("user_password_2", "", "post", FALSE, array());
        $useremail  = $application->input->getString("user_email", "", "post", FALSE, array());
        //3. Encrypt validated password if new users!
        //4. If not new user, check user has update permission on this user
        //5. MailOut
        
        if(empty($userpass)||empty($username)||empty($usernameid)||empty($useremail)){
            //Display a message telling them what can't be empty
            throw new Exception(t('Please provide at least a Name, Username, E-mail and Password') );
            return false;
        }
        
        //Validate the passwords
        if($userpass <> $userpass2){
            throw new Exception(t('The user passwords do not match') );
            return false;
        }
        
        //6. Store the user
        if(!$account->store( $application->input->data("post") , true)){
            //Display a message telling them what can't be empty
            throw new Exception( t('Could not store the admin user account')  );
            return false;
        }

        //Add this user to the superadministrators group!
        //$adminObject    = $account->getObjectByURI( $usernameid );
        $adminAuthority = $this->config->get( "setup.site.superadmin-authority", NULL);
        //Default Permission Group?
        if(!empty($adminAuthority)){
            $query = "INSERT INTO ?objects_authority( authority_id, object_id ) SELECT {$database->quote((int)$adminAuthority)}, object_id FROM ?objects WHERE object_uri={$database->quote($usernameid)}";
            $database->exec($query);
        }
        
        //@TODO Empty the setup/sessions folder
       // \Library\Folder::deleteContents( APPPATH."setup".DS."sessions" ); //No need to through an error
        
        //Completes installation

        //set session handler to database if database is connectable
        $config->set("setup.session.store", "database");
        $config->set("setup.database.installed", TRUE  );


        if(!$config->saveParams() ){

            throw new Exception("could not save config");

            return false;
        }
        return true;
    }
Registers a superadministrator at installation
@return boolean