本文整理汇总了PHP中Framework\Registry类的典型用法代码示例。如果您正苦于以下问题:PHP Registry类的具体用法?PHP Registry怎么用?PHP Registry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Registry类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: index
public function index()
{
$this->getLayoutView()->set("seo", Framework\Registry::get("seo"));
$view = $this->getActionView();
$alltests = Test::all(array(), array("id", "title"));
$view->set("alltests", $alltests);
}
开发者ID:HLitmus,项目名称:WebApp,代码行数:7,代码来源:home.php
示例2: initialize
public function initialize()
{
Events::fire("framework.database.initialize.before", array($this->type, $this->options));
if (!$this->type) {
$configuration = Registry::get("configuration");
if ($configuration) {
$configuration = $configuration->initialize();
$parsed = $configuration->parse("configuration/database");
if (!empty($parsed->database->default) && !empty($parsed->database->default->type)) {
$this->type = $parsed->database->default->type;
unset($parsed->database->default->type);
$this->options = (array) $parsed->database->default;
}
}
}
if (!$this->type) {
throw new Exception\Argument("Invalid type");
}
Events::fire("framework.database.initialize.after", array($this->type, $this->options));
switch ($this->type) {
case "mysql":
return new Database\Connector\Mysql($this->options);
break;
default:
throw new Exception\Argument("Invalid type");
break;
}
}
开发者ID:SwiftSchool,项目名称:School,代码行数:28,代码来源:database.php
示例3: initialize
public function initialize()
{
$type = $this->getType();
if (empty($type)) {
$configuration = Registry::get('configuration');
if ($configuration) {
$configuration = $configuration->initialize();
$parsed = $configuration->parse('configuration/database');
if (!empty($parsed->database->default) && !empty($parsed->database->default->type)) {
$type = $parsed->database->default->type;
unset($parsed->database->default->type);
$this->__construct(array('type' => $type, 'options' => $parsed->database->default));
}
}
}
if (empty($type)) {
throw new Exception\Argument('Invalid type');
}
switch ($type) {
case 'mysql':
return new Database\Connector\MySql($this->getOptions());
break;
default:
throw new Exception\Argument('Invalid type');
break;
}
}
开发者ID:soanni,项目名称:mvc,代码行数:27,代码来源:database.php
示例4: performance
public function performance($course)
{
$session = Registry::get("session");
$perf = Registry::get("MongoDB")->performance;
$week = (new \DateTime(date('Y-m-d')))->format("W");
$performance = array();
$classroom = self::$_classroom;
$record = $perf->findOne(array('user_id' => (int) self::$_student->user_id, 'course_id' => (int) $course->id, 'year' => date('Y'), 'classroom_id' => (int) $classroom->id));
$d = StringMethods::month_se();
$start = (int) (new \DateTime($d['start']))->format("W");
if ($start == 53) {
$start = 1;
}
$end = (int) (new \DateTime($d['end']))->format("W");
$monthly = array();
if (isset($record)) {
$performance['course'] = $course->title;
$performance['teacher'] = \User::first(array("id = ?" => $record['teacher_id']), array("name"))->name;
foreach ($record['track'] as $track) {
$week = $track['week'];
if ($week <= $end && $week >= $start) {
$monthly[] = $track['grade'];
}
$performance['tracking'][] = $track;
}
}
return array('performance' => $performance, 'monthly' => $monthly);
}
开发者ID:SwiftSchool,项目名称:School,代码行数:28,代码来源:student.php
示例5: fbLogin
public function fbLogin()
{
$this->JSONview();
$view = $this->getActionView();
$session = Registry::get("session");
if (RequestMethods::post("action") == "fbLogin" && isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {
// process the registration
$fbid = RequestMethods::post("fbid");
$access_token = RequestMethods::post("access_token");
$user = !$this->user ? User::first(["fbid = ?" => $fbid]) : $this->user;
if (!$user) {
try {
$user = $this->_register();
} catch (\Exception $e) {
$view->set("success", false);
return;
}
}
$this->setUser($user);
$redirect = RequestMethods::post("loc", "");
if ($redirect != '') {
$token = Shared\Markup::uniqueString();
$session->set('CampaignAccessToken', $token);
$view->set("redirect", "/" . $redirect . "/{$token}");
}
$view->set("success", true);
} else {
$view->set("success", false);
}
}
开发者ID:SwiftDeal,项目名称:fbfunapp,代码行数:30,代码来源:auth.php
示例6: __construct
public function __construct($options = array())
{
parent::__construct($options);
// connect to database
$database = Registry::get("database");
$database->connect();
// schedule: load user from session
Events::add("framework.router.beforehooks.before", function ($name, $parameters) {
$session = Registry::get("session");
$controller = Registry::get("controller");
$user = $session->get("user");
if ($user) {
$controller->user = \User::first(array("id = ?" => $user));
}
});
// schedule: save user to session
Events::add("framework.router.afterhooks.after", function ($name, $parameters) {
$session = Registry::get("session");
$controller = Registry::get("controller");
if ($controller->user) {
$session->set("user", $controller->user->id);
}
});
// schedule: disconnect from database
Events::add("framework.controller.destruct.after", function ($name) {
$database = Registry::get("database");
$database->disconnect();
});
}
开发者ID:royalwang,项目名称:SwiftMVC,代码行数:29,代码来源:controller.php
示例7: initialize
public function initialize()
{
$type = $this->getType();
if (empty($type)) {
$configuration = Registry::get('configuration');
if ($configuration) {
$configuration = $configuration->initialize();
$parsed = $configuration->parse('configuration/session');
if (!empty($parsed->session->default) && !empty($parsed->session->default->type)) {
$type = $parsed->session->default->type;
unset($parsed->session->default->type);
$this->__construct(array('type' => $type, 'options' => (array) $parsed->session->default));
}
}
}
if (empty($type)) {
throw new Exception\Argument('Invalid type');
}
switch ($type) {
case 'server':
return new Session\Driver\Server($this->getOptions());
break;
default:
throw new Exception\Argument('Invalid type');
break;
}
}
开发者ID:soanni,项目名称:mvc,代码行数:27,代码来源:session.php
示例8: initialize
public function initialize()
{
Events::fire("framework.session.initialize.before", array($this->type, $this->options));
if (!$this->type) {
$configuration = Registry::get("configuration");
if ($configuration) {
$configuration = $configuration->initialize();
$parsed = $configuration->parse("configuration/session");
if (!empty($parsed->session->default) && !empty($parsed->session->default->type)) {
$this->type = $parsed->session->default->type;
unset($parsed->session->default->type);
$this->options = (array) $parsed->session->default;
}
}
}
if (!$this->type) {
throw new Exception\Argument("Invalid type");
}
Events::fire("framework.session.initialize.after", array($this->type, $this->options));
switch ($this->type) {
case "server":
return new Session\Driver\Server($this->options);
break;
default:
throw new Exception\Argument("Invalid type");
break;
}
}
开发者ID:vjroby,项目名称:library,代码行数:28,代码来源:session.php
示例9: stats
/**
* See stats of a keyword
* @before _secure, memberLayout
*/
public function stats($keyword_id)
{
$keyword = \Keyword::first(array("id = ?" => $keyword_id, "serp = ?" => true));
$this->_authority($keyword);
$rank = Registry::get("MongoDB")->rank;
$r = $rank->findOne(['keyword_id' => (int) $keyword->id, 'created' => date('Y-m-d')]);
if ($keyword->live && !$r) {
try {
Shared\Service\Serp::record(array($keyword));
} catch (\Exception $e) {
}
}
$end_date = RequestMethods::get("enddate", date("Y-m-d"));
$start_date = RequestMethods::get("startdate", date("Y-m-d", strtotime($end_date . "-7 day")));
$this->seo(array("title" => "Serp | Stats", "view" => $this->getLayoutView()));
$view = $this->getActionView();
$start_time = strtotime($start_date);
$end_time = strtotime($end_date);
$i = 0;
$obj = array();
while ($start_time < $end_time) {
$start_time = strtotime($start_date . " +{$i} day");
$date = date('Y-m-d', $start_time);
$record = $rank->findOne(array('created' => $date, 'keyword_id' => (int) $keyword->id));
if (isset($record)) {
$position = $record['position'];
} else {
$position = 0;
}
$obj[] = array('y' => $date, 'a' => $position);
++$i;
}
$view->set("keyword", $keyword)->set("label", "Rank")->set("data", ArrayMethods::toObject($obj));
}
开发者ID:SwiftDeal,项目名称:detectr,代码行数:38,代码来源:serp.php
示例10: __construct
public function __construct()
{
parent::__construct();
$this->_rules = array();
$this->_errors = array();
$this->input = Registry::get('input');
}
开发者ID:khiemdoancrazy,项目名称:dk_framework,代码行数:7,代码来源:validator.php
示例11: index
/**
* @before _secure, _admin
*/
public function index()
{
$this->seo(array("title" => "Dashboard", "view" => $this->getLayoutView()));
$view = $this->getActionView();
$database = Registry::get("database");
$total = $database->query()->from("transactions", array("SUM(amount)" => "earn"))->all();
$view->set("earn", round($payments[0]["earn"], 2));
}
开发者ID:SwiftDeal,项目名称:detectr,代码行数:11,代码来源:admin.php
示例12: getTest
public function getTest()
{
$cache = Registry::get('cache');
if ($this->_ajax()) {
$test = array("Chapman");
echo json_encode($test);
}
}
开发者ID:chapmang,项目名称:phpframework,代码行数:8,代码来源:home.php
示例13: __construct
public function __construct()
{
parent::__construct();
$this->session = Registry::get('session');
$this->cookie = Registry::get('cookie');
$this->input = Registry::get('input');
$this->validator = Registry::get('validator');
}
开发者ID:khiemdoancrazy,项目名称:dk_framework,代码行数:8,代码来源:controller.php
示例14: __construct
public function __construct($options = array())
{
parent::__construct($options);
$database = \Framework\Registry::get('database');
$database->_connect();
$session = \Framework\Registry::get('session');
$user = unserialize($session->get('user', null));
$this->setUser($user);
}
开发者ID:soanni,项目名称:mvc,代码行数:9,代码来源:controller.php
示例15: delete
public static function delete()
{
$database = Framework\Registry::get('database');
Framework\Test::add(function () use($database) {
$example = new Model\Example(array("id" => 2));
$example->delete();
return Model\Example::count() == 1;
}, "Model deletes rows", "Model");
}
开发者ID:vjroby,项目名称:library,代码行数:9,代码来源:testmodel.php
示例16: all
/**
* @before _secure
*/
public function all()
{
$this->noview();
$results = Event::all(array("organization_id = ?" => Registry::get("session")->get("organization")->id));
$events = array();
foreach ($results as $r) {
$events[] = array("title" => $r->title, "start" => $this->returnTime($r->start), "end" => $this->returnTime($r->start), "allDay" => $r->allDay ? true : false, "id" => $r->id, "className" => "event");
}
echo json_encode($events);
}
开发者ID:SwiftSchool,项目名称:School,代码行数:13,代码来源:events.php
示例17: updateRaw
public static function updateRaw($table, $find, $set, $opts = [])
{
$collection = Registry::get("MongoDB")->{$table};
$many = $opts['many'] ?? false;
if ($many) {
$collection->updateMany($find, $set);
} else {
$collection->updateOne($find, $set);
}
}
开发者ID:vNative,项目名称:vnative,代码行数:10,代码来源:db.php
示例18: run
/**
* Запуск приложения
*
* @param array $configArray Массив конфигурации
* @throws \Exception
*/
public static function run(array $configArray)
{
$request = new Request();
$config = new Config($configArray);
Registry::set('request', $request);
Registry::set('config', $config);
Registry::set('pdo', new PDO('mysql:host=' . $config->get('db')['host'] . ';dbname=' . $config->get('db')['dbname'] . ';charset=utf8', $config->get('db')['user'], $config->get('db')['passwd']));
$routing = new Routing($request->server('REQUEST_URI'));
Registry::set('routing', $routing);
$routing->run();
}
开发者ID:lukianenko,项目名称:mindk,代码行数:17,代码来源:Application.php
示例19: render
/**
* @protected
* Will set variables to all the views of a controller
*/
public function render()
{
$session = Registry::get("session");
if ($this->actionView) {
$this->actionView->set("educator", $session->get("educator"))->set("scholar", $session->get("scholar"))->set("organization", $session->get("organization"));
}
if ($this->layoutView) {
$this->layoutView->set("educator", $session->get("educator"))->set("scholar", $session->get("scholar"))->set("organization", $session->get("organization"));
}
parent::render();
}
开发者ID:SwiftSchool,项目名称:School,代码行数:15,代码来源:home.php
示例20: profile
public function profile()
{
$session = Registry::get('session');
$user = unserialize($session->get('user', null));
if (empty($user)) {
$user = new stdClass();
$user->first = 'Mr.';
$user->last = 'Smith';
}
$this->getActionView()->set('user', $user);
}
开发者ID:soanni,项目名称:mvc,代码行数:11,代码来源:users.php
注:本文中的Framework\Registry类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论