Esempio n. 1
0
    $class = 'Phalcon\\Db\\Adapter\\Pdo\\' . $adapter;
    return new $class($dbConfig);
});
/**
 * If the configuration specify the use of metadata adapter use it or use memory otherwise
 */
$di->setShared('modelsMetadata', function () {
    return new MetaDataAdapter();
});
/**
 * Register the session flash service with the Twitter Bootstrap classes
 */
$di->set('flash', function () {
    return new Flash(array('error' => 'alert alert-danger', 'success' => 'alert alert-success', 'notice' => 'alert alert-info', 'warning' => 'alert alert-warning'));
});
/**
 * Start the session the first time some component request the session service
 */
$di->setShared('session', function () {
    $session = new SessionAdapter();
    $session->start();
    return $session;
});
$di->set("jquery", function () {
    $jquery = new Ajax\JsUtils(array("driver" => "Jquery"));
    $jquery->ui(new Ajax\JqueryUI());
    //optional for JQuery UI
    $jquery->bootstrap(new Ajax\Bootstrap());
    //Optional for Twitter Bootstrap
    return $jquery;
});
/**
 * Database connection is created based in the parameters defined in the configuration file
 */
$di->setShared('db', function () use($config) {
    $dbConfig = $config->database->toArray();
    $adapter = $dbConfig['adapter'];
    unset($dbConfig['adapter']);
    $class = 'Phalcon\\Db\\Adapter\\Pdo\\' . $adapter;
    return new $class($dbConfig);
});
/**
 * If the configuration specify the use of metadata adapter use it or use memory otherwise
 */
$di->setShared('modelsMetadata', function () {
    return new MetaDataAdapter();
});
/**
 * Start the session the first time some component request the session service
 */
$di->setShared('session', function () {
    $session = new SessionAdapter();
    $session->start();
    return $session;
});
$di->set("jquery", function () {
    $jquery = new Ajax\JsUtils(array("driver" => "Jquery"));
    $jquery->setAjaxLoader('&nbsp;<div class="icon-spinner2 loading-spin"></div><div class="icon-github4 loading-logo"></div>');
    $jquery->bootstrap(new Ajax\Bootstrap());
    //Optional for Twitter Bootstrap
    return $jquery;
});