Function that checks if the plugin has a valid config

@throws RuntimeException
@return boolean return true for success false for error, if you want a message to be included you need to use throw.
503455
function checkConfig()
    {
        //for joomla_int check to see if the source_url does not equal the default
	    try {
		    $db = Factory::getDatabase($this->getJname());
	    } catch (Exception $e) {
		    throw new RuntimeException(Text::_('NO_DATABASE') . ' : ' . $e->getMessage());
	    }

	    try {
		    $jdb = Factory::getDBO();
	    } catch (Exception $e) {
		    throw new RuntimeException($this->getJname() . ' -> joomla_int ' . Text::_('NO_DATABASE') . ' : ' . $e->getMessage());
	    }

	    if (!$db->connected()) {
		    throw new RuntimeException(Text::_('NO_DATABASE'));
	    } elseif (!$jdb->connected()) {
		    throw new RuntimeException($this->getJname() . ' -> joomla_int ' . Text::_('NO_DATABASE'));
	    } else {
		    //added check for missing files of copied plugins after upgrade
		    $admin = Factory::getAdmin($this->getJname());
		    $adminclass = 'JFusion\\Plugins\\' . $this->getJname(). '\\Admin';

		    $user = Factory::getUser($this->getJname());
		    $userclass = 'JFusion\\Plugins\\' . $this->getJname(). '\\User';
		    if (!$admin instanceof $adminclass) {
			    throw new RuntimeException(Text::_('NO_FILES') . ' '. $adminclass);
		    } else if (!$user instanceof $userclass) {
			    throw new RuntimeException(Text::_('NO_FILES') . ' '. $userclass);
		    } else {
			    $cookie_domain = $this->params->get('cookie_domain');
			    $jfc = Factory::getCookies();
			    list($url) = $jfc->getApiUrl($cookie_domain);
			    if ($url) {
				    $api = new Api($url, Factory::getParams('joomla_int')->get('secret'));
				    if (!$api->ping()) {
					    list ($message) = $api->getError();

					    throw new RuntimeException($api->url . ' ' . $message);
				    }
			    }
			    $source_path = $this->params->get('source_path');
			    if ($source_path && (strpos($source_path, 'http://') === 0 || strpos($source_path, 'https://') === 0)) {
				    throw new RuntimeException(Text::_('ERROR_SOURCE_PATH') . ' : ' . $source_path);
			    } else {
				    //get the user table name
				    $tablename = $this->getTablename();
				    // lets check if the table exists, now using the Joomla API
				    $table_list = $db->getTableList();
				    $table_prefix = $db->getPrefix();
				    if (!is_array($table_list)) {
					    throw new RuntimeException($table_prefix . $tablename . ': ' . Text::_('NO_TABLE'));
				    } else {
					    if (array_search($table_prefix . $tablename, $table_list) === false) {
						    //do a final check for case insensitive windows servers
						    if (array_search(strtolower($table_prefix . $tablename), $table_list) === false) {
							    throw new RuntimeException($table_prefix . $tablename . ': ' . Text::_('NO_TABLE'));
						    }
					    }
				    }
			    }
		    }
	    }
        return true;
    }
555019
public function validate($value)
    {
        try {
            $config = $this->getObject('object.config.factory')->fromString('ini', $value);
        } catch(\RuntimeException $e) {
            $config = null;
        }

        return is_string($value) && !is_null($config);
    }
729040
protected function validateQueryDefinition()
    {
        if (empty(static::$requestFieldsDefinition))
        {
            throw new RuntimeException('You must configure requestFieldsDefinition property');
        }

        if (empty(static::$signatureDefinition))
        {
            throw new RuntimeException('You must configure signatureDefinition property');
        }

        if (empty(static::$responseFieldsDefinition))
        {
            throw new RuntimeException('You must configure responseFieldsDefinition property');
        }

        if (empty(static::$successResponseType))
        {
            throw new RuntimeException('You must configure allowedResponseTypes property');
        }
    }
529049
public function loadConfig()
    {
        $result = $this->configStorage->lock();
        if ($result === false) {
            throw new \RuntimeException('Failed to lock the configStorage');
        }
        try {
            $result = $this->configStorage->load();
        } catch (\RuntimeException $e) {
            $this->configStorage->clear();
            throw $e;
        } finally {
            $this->configStorage->unlock();
        }

        $this->config = $result;
        return true;
    }
1290394
public function checkConfig()
    {
        $slugs = [];
        if ($this->passed === null) {
            $this->passed = true;
        } else {
            return $this->passed;
        }

        foreach ($this->data['contenttypes'] as $key => $ct) {
            // Make sure that there are no hyphens in the contenttype name, advise to change to underscores
            if (strpos($key, '-') !== false) {
                $error = Trans::__(
                    'contenttypes.generic.invalid-hyphen',
                    [
                        '%contenttype%' => $key,
                    ]
                );
                $this->app['logger.flash']->error($error);
                unset($this->data['contenttypes'][$key]);

                $this->passed = false;
            }

            /**
             * Make sure any field that has a 'uses' parameter actually points to a field that exists.
             *
             * For example, this will show a notice:
             * entries:
             *   name: Entries
             *     singular_name: Entry
             *     fields:
             *       title:
             *         type: text
             *         class: large
             *       slug:
             *         type: slug
             *         uses: name
             */
            foreach ($ct['fields'] as $fieldname => $field) {
                // Verify that the contenttype doesn't try to add fields that are reserved.
                if ($fieldname != 'slug' && in_array($fieldname, $this->reservedFieldNames)) {
                    $error = Trans::__(
                        'contenttypes.generic.reserved-name',
                        ['%contenttype%' => $key, '%field%' => $fieldname]
                    );
                    $this->app['logger.flash']->danger($error);

                    $this->passed = false;
                }

                // Check 'uses'. If it's an array, split it up, and check the separate parts. We also need to check
                // for the fields that are always present, like 'id'.
                if (!empty($field['uses']) && is_array($field['uses'])) {
                    foreach ((array) $field['uses'] as $useField) {
                        if (!empty($field['uses']) && empty($ct['fields'][$useField]) && !in_array($useField, $this->reservedFieldNames)) {
                            $error = Trans::__(
                                'contenttypes.generic.wrong-use-field',
                                ['%contenttype%' => $key, '%field%' => $fieldname, '%uses%' => $useField]
                            );
                            $this->app['logger.flash']->warning($error);

                            $this->passed = false;
                        }
                    }
                }

                // Check if all the used fields are existing field types.
                // Note: Check is disabled for now, because of the load order. At this point
                // in the execution, field types added by extensions are not yet initialised,
                // giving "false positives". See https://github.com/bolt/bolt/pull/7260
                /*
                if (!isset($field['type']) || !$this->fields->has($field['type'])) {
                    $error = Trans::__(
                        'contenttypes.generic.no-proper-type',
                        [
                            '%contenttype%' => $key,
                            '%field%'       => $fieldname,
                            '%type%'        => $field['type'],
                        ]
                    );
                    $this->app['logger.flash']->warning($error);

                    unset($ct['fields'][$fieldname]);
                    $this->passed = false;
                }
                */

                // Make sure that there are no consecutive underscores in field names
                if (strpos($fieldname, '__') !== false) {
                    $error = Trans::__(
                        'contenttypes.generic.consecutive-underscores',
                        [
                            '%contenttype%' => $key,
                            '%field%'       => $fieldname,
                            '%type%'        => $field['type'],
                        ]
                    );
                    $this->app['logger.flash']->warning($error);

                    unset($ct['fields'][$fieldname]);
                    $this->passed = false;
                }
            }

            /**
             * Make sure any contenttype that has a 'relation' defined points to a contenttype that exists.
             */
            if (isset($ct['relations'])) {
                foreach ($ct['relations'] as $relKey => $relData) {
                    // For BC we check if relation uses hyphen and re-map to underscores
                    if (strpos($relKey, '-') !== false) {
                        $newRelKey = str_replace('-', '_', strtolower(Str::makeSafe($relKey, true)));
                        unset($this->data['contenttypes'][$key]['relations'][$relKey]);
                        $this->data['contenttypes'][$key]['relations'][$newRelKey] = $relData;
                        $relKey = $newRelKey;
                    }
                    if (!isset($this->data['contenttypes'][$relKey])) {
                        $error = Trans::__(
                            'contenttypes.generic.invalid-relation',
                            ['%contenttype%' => $key, '%relation%' => $relKey]
                        );
                        $this->app['logger.flash']->error($error);

                        unset($this->data['contenttypes'][$key]['relations'][$relKey]);
                        $this->passed = false;
                    }
                    if (array_key_exists($relKey, $ct['fields'])) {
                        $error = Trans::__(
                            'general.phrase.clashing-relation',
                            ['%contenttype%' => $key, '%relation%' => $relKey]
                        );
                        $this->app['logger.flash']->error($error);
                    }
                }
            }

            // Keep a running score of used slugs.
            if (!isset($slugs[$ct['slug']])) {
                $slugs[$ct['slug']] = 0;
            }
            ++$slugs[$ct['slug']];
            if (!isset($slugs[$ct['singular_slug']])) {
                $slugs[$ct['singular_slug']] = 0;
            }
            if ($ct['singular_slug'] != $ct['slug']) {
                ++$slugs[$ct['singular_slug']];
            }
        }

        // Sanity checks for taxonomy.yml
        foreach ($this->data['taxonomy'] as $key => $taxo) {
            // Show some helpful warnings if slugs or keys are not set correctly.
            if ($taxo['slug'] != $key) {
                $error = Trans::__(
                    "The identifier and slug for '%taxonomytype%' are the not the same ('%slug%' vs. '%taxonomytype%'). Please edit taxonomy.yml, and make them match to prevent inconsistencies between database storage and your templates.",
                    ['%taxonomytype%' => $key, '%slug%' => $taxo['slug']]
                );
                $this->app['logger.flash']->warning($error);

                $this->passed = false;
            }
        }

        // if there aren't any other errors, check for duplicates across contenttypes.
        if (!$this->app['logger.flash']->has('error')) {
            foreach ($slugs as $slug => $count) {
                if ($count > 1) {
                    $error = Trans::__(
                        "The slug '%slug%' is used in more than one contenttype. Please edit contenttypes.yml, and make them distinct.",
                        ['%slug%' => $slug]
                    );
                    $this->app['logger.flash']->warning($error);

                    $this->passed = false;
                }
            }
        }

        return $this->checkTaxonomy();
    }
953124
function validateConfig(){

    if(!this.config.type){
        throw new Error(resources.errors.missingType);
    }
    if(this.config.type.toLowerCase() !== 'callback'){
        throw new Error(resources.errors.incorrectAdapterType);
    }
    if(!this.config.application){
        throw new Error(resources.errors.missingApplication);
    }
    if(!this.config.machine){
        throw new Error(resources.errors.missingMachine);
    }
    if(!this.config.callback && !_.isFunction(this.config.callback)) {
        throw new Error(resources.errors.missingCallback);
    }
}
1311378
protected function validateFilePath()
    {
        if (file_exists($this->filePath)) {
            if (!is_writable($this->filePath)) {
                throw new RuntimeException(
                    "File '{$this->filePath}' exist but is not writable"
                );
            }
        } else {
            if (!is_writable(dirname($this->filePath))) {
                throw new RuntimeException(
                    "File '{$this->filePath}' is not writable"
                );
            }
        }
    }
922742
protected function validateConfig()
    {
        parent::validateConfig();

        $short = $this->_getConfig('shortDebugResponse');

        if (!is_null($short)) {
            if (!is_int($short) || $short < 0) {
                throw new ModuleConfigException(__CLASS__, 'The value of "shortDebugMessage" should be integer and greater or equal "0".');
            }
        }
    }
1248577
public function parse()
    {
        if (!is_string($this->data)) {
            throw new \RuntimeException('The given data is no valid string');
        }
        libxml_use_internal_errors(true);
        $xml = simplexml_load_string($this->data);
        if ($xml === false) {
            throw new \RuntimeException('Error during the loading of the XML file');
        }
        if (!isset($xml->executables, $xml->excludes)) {
            throw new \RuntimeException('Missing configuration elements');
        }

        foreach ($xml->excludes->children()->file as $file) {
            $this->config->addExcludedFile((string) $file);
        }

        foreach ($xml->excludes->children()->dir as $dir) {
            $this->config->addExcludedDir((string) $dir);
        }

        foreach ($xml->executables->children() as $file) {
            $this->config->addExecutableFile((string) $file);
        }

        return $this->config;
    }
988561
private function _checkConfig() {
        // Check each configuration entry
        if (empty($this->_config) || !is_array($this->_config))
            throw new \InvalidArgumentException("Empty configuration or invalid configuration format");
        else if (empty($this->_config['app']))
            throw new \InvalidArgumentException("Application configuration not specified");
        else if (empty($this->_config['app']['name']))
            throw new \InvalidArgumentException("No application name specified under application configuration");
        else if (empty($this->_config['api']))
            throw new \InvalidArgumentException("Api configuration not specified");
        else if (empty($this->_config['api']['url']))
            throw new \InvalidArgumentException("No url specified under api configuration");
        else if (empty($this->_config['api']['sharedKey']))
            throw new \InvalidArgumentException("No shared key specified under api configuration");
        else if (empty($this->_config['api']['secretKey']))
            throw new \InvalidArgumentException("No secret key specified under api configuration");
    }
93733
public function validatePlugin($plugin)
    {
        if ($plugin instanceof ObjectManagerInterface) {
            return;
        }

        throw new Exception\RuntimeException(sprintf(
            'Plugin of type %s is invalid; must implement %s',
            (is_object($plugin) ? get_class($plugin) : gettype($plugin)),
            DoctrineObjectManager::class
        ));
    }
1233921
public function asConfig()
	{
		// Remove properties that shouldn't be turned into config arrays
		$properties = get_object_vars($this);
		unset($properties['attributeFilters']);
		unset($properties['bundleGenerator']);
		unset($properties['javascript']);
		unset($properties['rendering']);
		unset($properties['rulesGenerator']);
		unset($properties['registeredVars']);
		unset($properties['templateChecker']);
		unset($properties['templateNormalizer']);
		unset($properties['stylesheet']);

		// Create the config array
		$config    = ConfigHelper::toArray($properties);
		$bitfields = RulesHelper::getBitfields($this->tags, $this->rootRules);

		// Save the root context
		$config['rootContext'] = $bitfields['root'];
		$config['rootContext']['flags'] = $config['rootRules']['flags'];

		// Save the registered vars (including the empty ones)
		$config['registeredVars'] = ConfigHelper::toArray($this->registeredVars, true);

		// Make sure those keys exist even if they're empty
		$config += [
			'plugins' => [],
			'tags'    => []
		];

		// Remove unused tags
		$config['tags'] = array_intersect_key($config['tags'], $bitfields['tags']);

		// Add the bitfield information to each tag
		foreach ($bitfields['tags'] as $tagName => $tagBitfields)
		{
			$config['tags'][$tagName] += $tagBitfields;
		}

		// Remove unused entries
		unset($config['rootRules']);

		return $config;
	}
613883
protected function validateRun()
    {
        $status = $this->process->getExitCode();
        $error  = $this->process->getErrorOutput();

        if ($status !== 0 and $error !== '') {
            throw new \RuntimeException(
                sprintf(
                    "The exit status code %s says something went wrong:\n stderr: %s\n stdout: %s\ncommand: %s.",
                    $status,
                    $error,
                    $this->process->getOutput(),
                    $this->command
                )
            );
        }
    }
663731
public function validatePlugin($plugin)
    {
        //bug fix: not all plugin implements the ViewHelperInterface
        //eg: PaginationControl, but it has the setView method so it's ok to inject
        if ($plugin instanceof ViewHelperInterface || method_exists($plugin, 'setView')) {
            // we're okay
            return;
        }

        throw new Exception\RuntimeException(sprintf(
            'Plugin of type %s is invalid; must implement Zend_View_Helper_Interface',
            (is_object($plugin) ? get_class($plugin) : gettype($plugin))
        ));
    }
357682
public static function validateUser($userinfo)
	{
		$plugins = Factory::getPlugins();

		foreach($plugins as $plugin) {
			$user = Factory::getUser($plugin->name);
			if (!$user->validateUser($userinfo)) {
				throw new \RuntimeException('unknown validation: ' . $plugin->name);
			}
		}
		return true;
	}
1201502
public function getModulesConfig()
    {
        $result = [];
        foreach ($this->modules as $moduleName => $moduleConfig) {
            $className = $moduleConfig['className'];
            $module    = new $className;
            if (!$module instanceof AbstractModule) {
                $errMsg = sprintf('Class "%s" must be extended from %s', $className, AbstractModule::class);
                throw new Exception\RuntimeException($errMsg);
            }
            $config = $module->getConfig();
            $result = ArrayUtils::merge($result, $this->filterModuleConfig($config, $moduleName));
        }
        return $result;
    }
1160359
public function validatePlugin($plugin)
    {
        if ($this->isValidModuleOptions($plugin)) {
            return;
        }

        throw new Exception\RuntimeException(sprintf(
            'Plugin of type %s is invalid; must implement %s',
            (is_object($plugin) ? get_class($plugin) : gettype($plugin)),
            ModuleOptionsInterface::class
        ));
    }