public static function getStore() { if (!static::$store) { $manager = new CacheManager(new ConfigContainer(array('db' => \DLModel::getConnectionResolver(), 'encrypter' => Encrypter::getInstance(), 'config' => array('cache.driver' => 'database', 'cache.prefix' => 'schema_', 'cache.stores.database' => array('driver' => 'database', 'connection' => 'default', 'table' => 'cache'))))); static::$store = $manager->driver('database')->getStore(); } return static::$store; }
/** * Specify a unique index for the table. * * @param string|array $columns * @param string $name * @return \Illuminate\Support\Fluent */ public function spatialIndex($columns, $name = null) { $connection_klass = get_class(\DLModel::getConnectionResolver()->connection()); if ($connection_klass == 'Illuminate\\Database\\MySqlConnection') { // MySQL: Only MyISAM engine have spatial indexing $this->engine = 'MyISAM'; } return $this->indexCommand('spatial', $columns, $name); }
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); } return static::$instance; }
public static function getManager($driver = null) { if (!static::$manager) { if (!$driver) { $driver = \Slim\Slim::getInstance()->config('cache'); } if ($driver == "filesystem") { $config = array('files' => new Filesystem(), 'config' => array('cache.driver' => 'file', 'cache.path' => storage_dir() . '/cache')); } else { if ($driver == "database") { $config = array('db' => \DLModel::getConnectionResolver(), 'encrypter' => Encrypter::getInstance(), 'config' => array('cache.default' => 'database', 'cache.prefix' => '', 'cache.stores.database' => array('driver' => 'database', 'connection' => 'default', 'table' => 'cache'))); } } $container = new ConfigContainer($config); static::$manager = new CacheManager($container); } return static::$manager; }
/** * isSupported * * @return bool */ public function isSupported() { $connection = \DLModel::getConnectionResolver()->connection(); return !is_null($connection->getPdo()); }
/** * migrate * * Migrate core application schema. */ public static function migrate() { $connection = \DLModel::getConnectionResolver()->connection(); if ($connection->getPdo()) { $builder = $connection->getSchemaBuilder(); if (!$builder->hasTable('modules')) { foreach (glob(__DIR__ . '/../../migrations/app/*.php') as $file) { $migration = (require $file); if (is_array($migration)) { $builder->create($connection->getTablePrefix() . key($migration), current($migration)); } } } } }
protected function registerEnumDoctrineType($table, $field_name, $allowed = array()) { // // WORKAROUND: // register unsupported ENUM as a doctrine supported type // related issue: https://github.com/laravel/framework/issues/1186 // $enum_klass_name = 'Enum' . ucfirst($table) . ucfirst($field_name); if (!$allowed || empty($allowed)) { throw new MethodFailureException('Missing "allowed" values for ENUM type: ' . $table . '#' . $field_name . '.'); } $allowed_json = json_encode($allowed); $enum_name = 'enum'; // . $field_name; eval('class ' . $enum_klass_name . ' extends Hook\\Database\\Types\\EnumType { protected $name = \'' . $enum_name . '\'; protected $values = array(' . substr($allowed_json, 1, strlen($allowed_json) - 2) . '); }'); $type_method = 'addType'; if (\Doctrine\DBAL\Types\Type::hasType('enum')) { $type_method = 'overrideType'; } call_user_func_array(array('\\Doctrine\\DBAL\\Types\\Type', $type_method), array('enum', $enum_klass_name)); // // WORKAROUND: // Need to register 'enum' on AbstractPlatform with anything different // than the real type, in order find diffs via: // `Illuminate\Database\Schema\Grammars\Grammar#compileChange` // $connection = \DLModel::getConnectionResolver()->connection(); $connection->getDoctrineSchemaManager()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'blob'); return $enum_klass_name; }
public function __construct() { $this->connection = \DLModel::getConnectionResolver()->connection(); }
$config = (require ROOT_DIR . '/config/preferences.php'); date_default_timezone_set($config['timezone']); if ($config['debug']) { ini_set('display_errors', 1); error_reporting(E_ALL); } $config['log.enabled'] = $config['debug']; // Merge settings with security config $config = array_merge($config, require ROOT_DIR . '/config/security.php'); $app = new \Slim\Slim($config); $app->config('database', require ROOT_DIR . '/config/database.php'); $app->config('paths', require ROOT_DIR . '/config/paths.php'); Hook\Http\Router::setInstance($app); require ROOT_DIR . '/vendor/doubleleft/hook/src/bootstrap/connection.php'; // setup custom pagination environment $connection = \DLModel::getConnectionResolver()->connection(); $connection->setPaginator(new Hook\Framework\Environment()); // Set application key $app_key = null; $config_keys = ROOT_DIR . '/config/keys.php'; // auto-set app_id/key if (!$app->request->headers->get('X-App-Id')) { // Create default application if it doesn't exists if (Hook\Model\AppKey::count() == 0) { $application = Hook\Model\App::create(array('name' => "Application")); $hook_config = $application->keys[0]->toArray(); $hook_config['endpoint'] = 'http://' . $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT']; file_put_contents($app->config('paths')['root'] . '.hook-config', json_encode($hook_config)); // Migrate application tables Hook\Application\Context::setKey($application->keys[0]); Hook\Application\Context::migrate();
// Use a string representing an RFC2822 or ISO 8601 date // http://tools.ietf.org/html/rfc2822#page-14 // \Carbon\Carbon::setToStringFormat('Y-m-d\\TH:i:sP'); // Setup paginator $connection->setPaginator(new Hook\Pagination\Environment()); // Setup Schema Grammar // $connection->setSchemaGrammar(); // Setup cache manager $connection->setCacheManager(function () { $cache_driver = Router::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\Security\Encryption\Encrypter::getInstance(), 'config' => array('cache.driver' => 'database', 'cache.connection' => 'default', 'cache.table' => 'cache', 'cache.prefix' => '')); } } return new Illuminate\Cache\CacheManager($config); }); // // TODO: Create `hook migrate` command. // -------------------------------------- // // // Try to create schema. // Ignore NoSQL databases. // if ($connection->getPdo()) { $builder = $connection->getSchemaBuilder(); if (!$builder->hasTable('apps')) {