Configuration

Global Jybrid configuration parameters

The configuration uses the factory pattern with which you can store and change configuration parameters centrally.

This enables jybrid to be reconfigured again and again in large web applications.

Getting the Jybrid configuration object

Full-Namespace
$jybConfig = \Jybrid\Factory::getInstance()->getConfig();
"Factory" named Class in this File use the "use"
// or, if you are working with only one "Factory" named Class in this File use the "use"
use Jybrid\Factory;
$jybConfig = Factory::getInstance()->getConfig();
Configure without variable initialisation
// or if you want to configure without the new variable "$jybConfig" initialisation
\Jybrid\Factory::getInstance()->getConfig()->setExitAllowed(false);

setScriptLoadTimeout

Javascript files can be provided with a load-check-var at the end of the file. This allows the browser to check via Javascript whether the desired Javascript file has also been loaded. To use this feature you have to specify the following setting in milliseconds (2000=sec)

Personally, I only use this feature during development. Please keep in mind, that the javascript file object Jybrid\Scripts\Core(['scriptName' => 'myScriptName', 'fileName' => 'myScriptName_0.3.0.js', 'useScriptLoadTimeout' => true]); has to contain the "'useScriptLoadTimeout' => true"

\Jybrid\Factory::getInstance()->getConfig()->setScriptLoadTimeout(int|null);

The following script is then automatically stored in the head tag.

(function () {
    var jybridTO = window.setTimeout(function () {
        var scriptExists = false;
        try {
            if (jybridIsLoaded) scriptExists = true;
            window.clearTimeout(jybridTO);
        } catch (e) {}
        ;
        if (!scriptExists) {
            alert('Error: the Javascript component could not be included. Perhaps the URL is incorrect?\nURL:/jybrid/php/src/assets/js/jybrid_core.js');
        }
    }, 2000);
}());

setExitAllowed

default is true

/*
        Boolean: bExitAllowed

        A configuration option that is tracked by the main <jybrid>object.  Setting this
        to true allows <jybrid> to exit immediatly after processing a jybrid request.  If
        this is set to false, jybrid will allow the remaining code and HTML to be sent
        as part of the response.  Typically this would result in an error, however, 
        a response processor on the client side could be designed to handle this condition.
    */

Response Character Encoding (todo)

/**
    Function: getCharacterEncoding

    Called automatically by new response objects as they are constructed to obtain the
    current character encoding setting.  As the character encoding is changed, the <jybridResponseManager>
    will automatically notify the current response object since it would have been constructed
    prior to the setting change, see <jybridResponseManager::configure>.
*/

Further reading

Per Request Configuration

The per request configuration is located at

ajax-request php-ajax-request-configuration