• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Addon Prerequisites?

Jaxel

Well-known member
#1
I am making a "Base Framework" addon for all my mods. If you want to install any of my mods, you will be required to have this addon installed.

How would I set up an addon so that it checks to see if addon_id "EWRbase", version_id "1" is installed?
 

bambua

Well-known member
#2
I am making a "Base Framework" addon for all my mods. If you want to install any of my mods, you will be required to have this addon installed.

How would I set up an addon so that it checks to see if addon_id "EWRbase", version_id "1" is installed?
It's not from the core of Zend/XF but couldn't you check to see if the class exists that is from your addon? before it tries to execute anything.
 
R

ragtek

Guest
#3
1. way => check in the installer, if a class of your framework exists & is loadable
2. way (cleaner)
PHP:
$addOnModel = XenForo_Model::create('XenForo_Model_AddOn');
 
$fwVersion = $addOnModel->getAddOnVersion('yourframework');

        if (!$fwVersion) {
            self::printFwRequired();
        }
        else {
            if ($fwVersion['version_id'] < self::FW_REQUIRED_VERSION) {
                throw new XenForo_Exception('new framework version > ' . self::FW_REQUIRED_VERSION . ' required', true);
            }
        }