Resource icon

Unmaintained Advance AddOn System 1.0.0 Alpha 1

No permission to download
Install this addon like any other addon out there.

The first initial step is to turn off "Listeners" because we are modifying the default addon system that it conflicts when rebuilding the templates, not sure why exactly but turning this off helped.

config.php
PHP:
$config['enableListeners'] = false;

When your ready to create your own addon off the Advance AddOn System, you will simply inherit the class XenAdvAddOn_Installer_Abstract.

An example would be below

PHP:
<?php

class Test_Installer extends XenAdvAddOn_Installer_Abstract
{
    protected function initialize() {
        $this->addUpdateVersion(0);
    }

    protected function install_0() {
        $this->setMessage("Version Alpha");
        return 'a';
    }
 
    protected function install_0a() {
        $this->setMessage("Step 0a");
        return 'b';
    }
 
    protected function install_0b() {
        $this->setMessage("Step 0b");
        return true;
    }
 
    public function uninstall(array $addOn) {
        $this->setMessage("Uninstalling...");
    }
}

The special method that are required are initialize and uninstall.

initialize is where you would add your updated version steps, a good example would be

PHP:
$this->addUpdateVersion(0); // initial release

This would require the function

PHP:
protected function install_0()

Simply install_{VersionId} from the addon edit screen when adding your addon.

I have done something like this...

VersionId: 1000010 (similar to XenForo's Application Id)

therefore then the first initial release would be

PHP:
protected function install_1000010() {
    return true;
}

and

PHP:
protected function initialize() {
        $this->addUpdateVersion(1000010);
    }

To add another version update you would simply do

PHP:
protected function initialize() {
        $this->addUpdateVersion(1000010); // 1.0.0 Alpha
        $this->addUpdateVersion(1000011); // 1.0.0 Alpha 1
    }

protected function install_1000010() {
    return true;
}

protected function install_1000011() {
    return 'a';
}

protected function install_1000011a() {
    return true;
}

Always return "true" when you are done with that initial update, so that it can proceed to the next install method or upgrade method another words.

If you have more steps needed that you wish to break up you would return a string something like

PHP:
return '_stepA';

then your step would be something like
PHP:
protected function install_1000011_stepA() {
    return true;
}

You can also change the "Message" that is outputted on each step by doing

PHP:
$this->setMessage('My output message');


NOTE: You do not need to initialize or grab the database by doing XenForo_Application::getDb(); or XenForo_Application::get('db');

You can also create models from $this->getModelFromCache(modelName);

Please let me know if there are any issues with this, and I'll fix them right away.

Thanks and Enjoy!
Top Bottom