本文整理汇总了PHP中RedBeanPHP\R::ext方法的典型用法代码示例。如果您正苦于以下问题:PHP R::ext方法的具体用法?PHP R::ext怎么用?PHP R::ext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RedBeanPHP\R
的用法示例。
在下文中一共展示了R::ext方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setDb
/**
* @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;
}
示例2: run
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();
}
示例3: Connect
$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();
};
示例4: __construct
/**
* @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);
}
}