本文整理汇总了PHP中SessionManager::current_user方法的典型用法代码示例。如果您正苦于以下问题:PHP SessionManager::current_user方法的具体用法?PHP SessionManager::current_user怎么用?PHP SessionManager::current_user使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SessionManager
的用法示例。
在下文中一共展示了SessionManager::current_user方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Planet
<?php
require_once 'inc/shortcuts.php';
require_once 'inc/db.php';
require_once 'inc/routing.php';
require_once 'models/Planet.php';
require_once 'models/SessionManager.php';
$result = null;
if (SessionManager::is_authenticated() && ($form = is_form_submitted(['declination', 'hour_angle', 'brightness', 'size', 'color', 'message']))) {
try {
$planet = new Planet(['declination' => (double) $form['declination'], 'hour_angle' => (double) $form['hour_angle'], 'brightness' => (double) $form['brightness'], 'size' => (double) $form['size'], 'color' => $form['color'], 'message' => $form['message'], 'added_by' => SessionManager::current_user()]);
$planet->save();
redirect('/?planet_added=1');
} catch (DbException $e) {
$result = $e->getMessage();
}
}
$index = new Controller('index', ['result' => $result]);
$index->run();
示例2: render
<?php
require_once 'inc/shortcuts.php';
require_once 'models/User.php';
require_once 'models/Planet.php';
require_once 'models/SessionManager.php';
if (array_key_exists('id', $_GET)) {
$user_id = (int) $_GET['id'];
$user = User::find_one(['__pk__' => $user_id]);
if ($user) {
$self = $user->id === SessionManager::current_user()->id;
$planets = Planet::find(['added_by' => $user]);
render('user', ['user' => $user, 'planets' => $planets, 'self' => $self]);
exit;
}
}
$last_users = User::find(['__order_by__' => '-id'], 20);
render('users', ['last_users' => $last_users]);
示例3: render
<?php
require_once 'inc/shortcuts.php';
require_once 'models/SessionManager.php';
$result = false;
if (array_key_exists('result', $_GET)) {
$result = $_GET['result'];
}
render('index', ['authenticated' => SessionManager::is_authenticated(), 'result' => $result, 'current_user' => SessionManager::current_user()]);