Baikal\Core\Tools::assertBaikalIsOk PHP Method

assertBaikalIsOk() static public method

static public assertBaikalIsOk ( )
    static function assertBaikalIsOk()
    {
        # DB connexion has not been asserted earlier by Flake, to give us a chance to trigger the install tool
        # We assert it right now
        if (!\Flake\Framework::isDBInitialized() && (!defined("BAIKAL_CONTEXT_INSTALL") || BAIKAL_CONTEXT_INSTALL === false)) {
            throw new \Exception("<strong>Fatal error</strong>: no connection to a database is available.");
        }
        # Asserting that the database is structurally complete
        #if(($aMissingTables = self::isDBStructurallyComplete($GLOBALS["DB"])) !== TRUE) {
        #	throw new \Exception("<strong>Fatal error</strong>: Database is not structurally complete; missing tables are: <strong>" . implode("</strong>, <strong>", $aMissingTables) . "</strong>");
        #}
        # Asserting config file exists
        if (!file_exists(PROJECT_PATH_SPECIFIC . "config.php")) {
            throw new \Exception("Specific/config.php does not exist. Please use the Install tool to create it.");
        }
        # Asserting config file is readable
        if (!is_readable(PROJECT_PATH_SPECIFIC . "config.php")) {
            throw new \Exception("Specific/config.php is not readable. Please give read permissions to httpd user on file 'Specific/config.php'.");
        }
        # Asserting config file is writable
        if (!is_writable(PROJECT_PATH_SPECIFIC . "config.php")) {
            throw new \Exception("Specific/config.php is not writable. Please give write permissions to httpd user on file 'Specific/config.php'.");
        }
        # Asserting system config file exists
        if (!file_exists(PROJECT_PATH_SPECIFIC . "config.system.php")) {
            throw new \Exception("Specific/config.system.php does not exist. Please use the Install tool to create it.");
        }
        # Asserting system config file is readable
        if (!is_readable(PROJECT_PATH_SPECIFIC . "config.system.php")) {
            throw new \Exception("Specific/config.system.php is not readable. Please give read permissions to httpd user on file 'Specific/config.system.php'.");
        }
        # Asserting system config file is writable
        if (!is_writable(PROJECT_PATH_SPECIFIC . "config.system.php")) {
            throw new \Exception("Specific/config.system.php is not writable. Please give write permissions to httpd user on file 'Specific/config.system.php'.");
        }
    }

Usage Example

Ejemplo n.º 1
0
 public static function bootstrap()
 {
     # Registering Baikal classloader
     define("BAIKAL_PATH_FRAMEWORKROOT", dirname(__FILE__) . "/");
     \Baikal\Core\Tools::assertEnvironmentIsOk();
     \Baikal\Core\Tools::configureEnvironment();
     # Check that a config file exists
     if (!file_exists(PROJECT_PATH_SPECIFIC . "config.php") || !file_exists(PROJECT_PATH_SPECIFIC . "config.system.php")) {
         self::installTool();
     } else {
         require_once PROJECT_PATH_SPECIFIC . "config.php";
         require_once PROJECT_PATH_SPECIFIC . "config.system.php";
         date_default_timezone_set(PROJECT_TIMEZONE);
         # Check that Baïkal is already configured
         if (!defined("BAIKAL_CONFIGURED_VERSION")) {
             self::installTool();
         } else {
             # Check that running version matches configured version
             if (version_compare(BAIKAL_VERSION, BAIKAL_CONFIGURED_VERSION) > 0) {
                 self::installTool();
             } else {
                 # Check that admin password is set
                 if (!defined("BAIKAL_ADMIN_PASSWORDHASH")) {
                     self::installTool();
                 }
                 \Baikal\Core\Tools::assertBaikalIsOk();
                 set_error_handler("\\Baikal\\Framework::exception_error_handler");
             }
         }
     }
 }