SettingsController::testAddon PHP Method

testAddon() public method

Test and addon to see if there are any fatal errors during install.
Since: 2.0.0
public testAddon ( string $AddonType = '', string $AddonName = '', string $TransientKey = '' )
$AddonType string
$AddonName string
$TransientKey string Security token.
    public function testAddon($AddonType = '', $AddonName = '', $TransientKey = '')
    {
        $this->permission('Garden.Settings.Manage');
        if (!in_array($AddonType, array('Plugin', 'Application', 'Theme', 'Locale'))) {
            $AddonType = 'Plugin';
        }
        $Session = Gdn::session();
        $AddonName = $Session->validateTransientKey($TransientKey) ? $AddonName : '';
        if ($AddonType == 'Locale') {
            $AddonManager = new LocaleModel();
            $TestMethod = 'TestLocale';
        } else {
            $AddonManagerName = $AddonType . 'Manager';
            $TestMethod = 'Test' . $AddonType;
            $AddonManager = Gdn::Factory($AddonManagerName);
        }
        if ($AddonName != '') {
            $Validation = new Gdn_Validation();
            try {
                $AddonManager->{$TestMethod}($AddonName, $Validation);
            } catch (Exception $Ex) {
                if (Debug()) {
                    throw $Ex;
                } else {
                    echo $Ex->getMessage();
                    return;
                }
            }
        }
        ob_clean();
        echo 'Success';
    }