Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:doubleleft/hook into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
endel committed Aug 4, 2014
2 parents ab75e98 + 0f505c3 commit f923a80
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 23 deletions.
24 changes: 23 additions & 1 deletion config/preferences.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
<?php

return array(
/**
* Application timezone
* --------------------
*/
'timezone' => 'America/Sao_Paulo',
'debug' => true

/**
* Debug mode
* ----------
* If true, outputs all database queries and
* requests on application's log file.
*/
'debug' => true,

/**
* Cache
* -----
*
* Available options:
*
* - filesystem
* - database
*/
'cache' => 'database'
);
1 change: 0 additions & 1 deletion src/Cache/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ public static function getInstance()
{
if (!static::$instance) {
$connection = \DLModel::getConnectionResolver()->connection();

$cache_manager = $connection->getCacheManager();
$default_driver = $cache_manager->getDefaultDriver();
static::$instance = $cache_manager->driver($default_driver);
Expand Down
10 changes: 4 additions & 6 deletions src/Hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@
// global helpers
require __DIR__ . '/bootstrap/helpers.php';

$config = array();
$preferences = require(__DIR__ . '/../config/preferences.php');
date_default_timezone_set($preferences['timezone']);
$config = require(__DIR__ . '/../config/preferences.php');
date_default_timezone_set($config['timezone']);

if ($preferences['debug']) {
if ($config['debug']) {
ini_set('display_errors', 1);
error_reporting(E_ALL);
}

$config['debug'] = $preferences['debug'];
$config['log.enabled'] = $preferences['debug'];
$config['log.enabled'] = $config['debug'];

// Merge settings with security config
$config = array_merge($config, require(__DIR__ . '/../config/security.php'));
Expand Down
40 changes: 25 additions & 15 deletions src/bootstrap/connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,31 @@ class_alias('\Illuminate\Database\Eloquent\Model', 'DLModel');

// Setup cache manager
$connection->setCacheManager(function () {
return new Illuminate\Cache\CacheManager(array(
'db' => \DLModel::getConnectionResolver(),
'encrypter' => Hook\Encryption\Encrypter::getInstance(),

// 'files' => new \Illuminate\Filesystem\Filesystem(),
'config' => array(
'cache.driver' => 'database',
'cache.connection' => 'default',
'cache.table' => 'cache',
'cache.prefix' => ''

// 'cache.driver' => 'file',
// 'cache.path' => storage_dir() . '/cache'
)
));
$cache_driver = \Slim\Slim::getInstance()->config('cache');

if ($cache_driver == "filesystem") {
$config = array(
'files' => new \Illuminate\Filesystem\Filesystem(),
'config' => array(
'cache.driver' => 'file',
'cache.path' => storage_dir() . '/cache'
)
);

} else if ($cache_driver == "database") {
$config = array(
'db' => \DLModel::getConnectionResolver(),
'encrypter' => Hook\Encryption\Encrypter::getInstance(),
'config' => array(
'cache.driver' => 'database',
'cache.connection' => 'default',
'cache.table' => 'cache',
'cache.prefix' => ''
)
);
}

return new Illuminate\Cache\CacheManager($config);
});

//
Expand Down

0 comments on commit f923a80

Please sign in to comment.