Backend\Modules\Extensions\Engine\Model::checkSettings PHP Method

checkSettings() public static method

Checks the settings and optionally returns an array with warnings
public static checkSettings ( ) : array
return array
    public static function checkSettings()
    {
        $warnings = array();
        $akismetModules = self::getModulesThatRequireAkismet();
        $googleMapsModules = self::getModulesThatRequireGoogleMaps();
        // check if this action is allowed
        if (BackendAuthentication::isAllowedAction('Index', 'Settings')) {
            // check if the akismet key is available if there are modules that require it
            if (!empty($akismetModules) && BackendModel::get('fork.settings')->get('Core', 'akismet_key', null) == '') {
                // add warning
                $warnings[] = array('message' => sprintf(BL::err('AkismetKey'), BackendModel::createURLForAction('Index', 'Settings')));
            }
            // check if the google maps key is available if there are modules that require it
            if (!empty($googleMapsModules) && BackendModel::get('fork.settings')->get('Core', 'google_maps_key', null) == '') {
                // add warning
                $warnings[] = array('message' => sprintf(BL::err('GoogleMapsKey'), BackendModel::createURLForAction('Index', 'Settings')));
            }
        }
        // check if this action is allowed
        if (BackendAuthentication::isAllowedAction('Modules', 'Extensions')) {
            // check if there are cronjobs that are not yet set
            $modules = self::getModules();
            foreach ($modules as $module) {
                if (isset($module['cronjobs_active']) && !$module['cronjobs_active']) {
                    // add warning
                    $warnings[] = array('message' => sprintf(BL::err('CronjobsNotSet', 'Extensions'), BackendModel::createURLForAction('Modules', 'Extensions')));
                    break;
                }
            }
        }
        return $warnings;
    }

Usage Example

Example #1
0
 /**
  * Checks the settings and optionally returns an array with warnings
  *
  * @return array
  */
 public static function checkSettings()
 {
     $warnings = array();
     // check if debug-mode is active
     if (BackendModel::getContainer()->getParameter('kernel.debug')) {
         $warnings[] = array('message' => Language::err('DebugModeIsActive'));
     }
     // check if this action is allowed
     if (Authentication::isAllowedAction('Index', 'Settings')) {
         // check if the fork API keys are available
         if (self::get('fork.settings')->get('Core', 'fork_api_private_key') == '' || self::get('fork.settings')->get('Core', 'fork_api_public_key') == '') {
             $warnings[] = array('message' => sprintf(Language::err('ForkAPIKeys'), self::createURLForAction('Index', 'Settings')));
         }
     }
     // check for extensions warnings
     $warnings = array_merge($warnings, BackendExtensionsModel::checkSettings());
     return $warnings;
 }