Ejemplo n.º 1
0
 /**
  * Get the table manager.
  *
  * @return Table
  */
 public function table()
 {
     static $table;
     if (!$table) {
         $table = TableFactory::create($this->tableName, static::class);
     }
     return $table;
 }
Ejemplo n.º 2
0
    return $routes;
};
$container['session'] = function ($c) {
    return new \pew\libs\Session();
};
$container['url'] = function ($c) {
    $request = $c['request'];
    $routes = $c['routes'];
    return new \pew\libs\Url($request, $routes);
};
$container['view'] = function ($c) {
    $app_path = $c['app_path'];
    $file_cache = $c['file_cache'];
    $views_folder = $app_path . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR;
    return new \pew\View($views_folder, $file_cache);
};
$container['whoops_handler'] = function ($c) {
    $request = $c['request'];
    if (php_sapi_name() === 'cli' || $request->isJson()) {
        return new \Whoops\Handler\PlainTextHandler();
    }
    return new \Whoops\Handler\PrettyPageHandler();
};
# setup the Whoops error handler
$whoops = new \Whoops\Run();
$whoops->pushHandler($container['whoops_handler']);
$whoops->register();
\pew\model\TableFactory::setConnection('default', null, function () use($container) {
    return $container['db'];
});
return $container;