/** * @param $name * @return mixed */ public function setDb($name) { $this->options = $this->db[$name]; R::setAutoResolve(TRUE); R::selectDatabase($name); R::ext('xdispense', function ($type) { return R::getRedBean()->dispense($type); }); if ($this->cache) { R::useWriterCache(true); R::freeze(TRUE); } return $name; }
public function run() { global $slim; $view = new \Slim\Views\Smarty(); $view->parserExtensions = ['vendor/slim/views/SmartyPlugins']; $this->slim = $slim = new Slim(['view' => $view, 'templates.path' => 'views']); $this->slim->setName('um'); R::setup('mysql:host=localhost;dbname=lighting_durag', 'root', ''); // R::setup('mysql:host=localhost;dbname=lighting_durag', 'root', 'mysql@umi'); R::ext('xdispense', function ($type) { return R::getRedBean()->dispense($type); }); // add middleware $this->addMiddleware(new AuthMiddleware()); $this->route = new Route($this->slim); $this->route->run(); $this->slim->run(); }
public function setBeanHelper(BeanHelper $beanHelper) { $this->beanHelper = $beanHelper; R::getRedBean()->setBeanHelper($this->beanHelper); return $this; }
$logger = $c->get('logger'); $session = $c->get('session'); $settings = $c->get('settings')['facebook']; $connect = new Connect($settings, $session, $logger); return $connect; }; $container['database'] = function ($c) { $logger = $c->get('logger'); $settings = $c->get('settings')['database']; define('QUESTION', 'quiz_question'); define('ANSWER', 'quiz_answer'); define('QUIZ', 'quiz_quiz'); define('USER', 'quiz_user'); // Create an extension to by-pass security check in R::dispense R::ext('xdispense', function ($type) { return R::getRedBean()->dispense($type); }); R::renameAssociation(['quiz_answer_quiz_question' => 'quiz_answer_question', 'quiz_answer_quiz_quiz' => 'quiz_answer_quiz', 'quiz_question_quiz_quiz' => 'quiz_question_quiz']); define('REDBEAN_MODEL_PREFIX', '\\App\\Model\\'); $connectionString = 'mysql:host=' . $settings['host'] . ';dbname=' . $settings['dbname']; R::setup($connectionString, $settings['username'], $settings['password']); R::useWriterCache(true); //R::debug(true); // // NEVER REMOVE THIS! R::freeze(true); return R::getRedBean(); }; $container['quiz'] = function ($c) { $database = $c->get('database'); return new QuizService(); };
/** * @param string $tableName Table Name * @param string $viewDir User Template directory * @throws Exception * @throws TableNameException * @throws \RedBeanPHP\RedException */ public function __construct($tableName = null, $viewDir = "view") { R::ext('xdispense', function ($type) { return R::getRedBean()->dispense($type); }); if ($tableName != null) { $this->setTable($tableName); } try { $this->template = new Engine($viewDir); } catch (\LogicException $ex) { throw new Exception("The view folder is not existing."); } // Debug Bar $this->debugbar = new StandardDebugBar(); $debugbarRenderer = $this->debugbar->getJavascriptRenderer(Util::res("vendor/maximebf/debugbar/src/DebugBar/Resources")); // Template Default Data $this->template->addData(["crud" => $this, "cacheVersion" => $this->cacheVersion, "debugbar" => $this->debugbar, "debugbarRenderer" => $debugbarRenderer]); $this->addTheme("adminlte", "vendor/{$this->packageName}/view/theme/AdminLTE"); $this->setCurrentTheme("adminlte"); // Enable helper? if (defined("ENABLE_CRUD_HELPER") && ENABLE_CRUD_HELPER) { //setGlobalCRUD($this); } }