本文整理汇总了PHP中Queue::seek方法的典型用法代码示例。如果您正苦于以下问题:PHP Queue::seek方法的具体用法?PHP Queue::seek怎么用?PHP Queue::seek使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Queue
的用法示例。
在下文中一共展示了Queue::seek方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: work
public static function work(&$controllerContext, &$viewContext)
{
$queue = new Queue(Config::$userQueuePath);
$queueItem = new QueueItem(strtolower($controllerContext->userName));
$j['user'] = $controllerContext->userName;
$j['pos'] = $queue->seek($queueItem);
$viewContext->layoutName = 'layout-json';
$viewContext->json = $j;
}
示例2: preWork
public static function preWork(&$controllerContext, &$viewContext)
{
$controllerContext->cache->setPrefix($controllerContext->userName);
if (BanHelper::getUserBanState($controllerContext->userName) == BanHelper::USER_BAN_TOTAL) {
$controllerContext->cache->bypass(true);
$viewContext->userName = $controllerContext->userName;
$viewContext->viewName = 'error-user-blocked';
$viewContext->meta->title = 'User blocked — ' . Config::$title;
return;
}
$module = $controllerContext->module;
HttpHeadersHelper::setCurrentHeader('Content-Type', $module::getContentType());
$viewContext->media = $controllerContext->media;
$viewContext->module = $controllerContext->module;
$viewContext->meta->noIndex = true;
$viewContext->contentType = $module::getContentType();
if ($viewContext->contentType != 'text/html') {
$viewContext->layoutName = 'layout-raw';
}
Database::selectUser($controllerContext->userName);
$user = R::findOne('user', 'LOWER(name) = LOWER(?)', [$controllerContext->userName]);
if (empty($user)) {
if (!isset($_GET['referral']) || $_GET['referral'] !== 'search') {
$controllerContext->cache->bypass(true);
$viewContext->userName = $controllerContext->userName;
$viewContext->viewName = 'error-user-not-found';
$viewContext->meta->title = 'User not found — ' . Config::$title;
return;
}
$queue = new Queue(Config::$userQueuePath);
$queueItem = new QueueItem(strtolower($controllerContext->userName));
$queue->enqueue($queueItem);
$viewContext->queuePosition = $queue->seek($queueItem);
$controllerContext->cache->bypass(true);
//try to load cache, if it exists
$url = $controllerContext->url;
if ($controllerContext->cache->exists($url)) {
$controllerContext->cache->load($url);
flush();
$viewContext->layoutName = null;
$viewContext->viewName = null;
return;
}
$viewContext->userName = $controllerContext->userName;
$viewContext->viewName = 'error-user-enqueued';
$viewContext->meta->title = 'User enqueued — ' . Config::$title;
return;
}
$viewContext->user = $user;
$viewContext->meta->styles[] = '/media/css/menu.css';
$viewContext->updateWait = Config::$userQueueMinWait;
$module = $controllerContext->module;
$module::preWork($controllerContext, $viewContext);
}
示例3: work
public static function work(&$controllerContext, &$viewContext)
{
$queue = new Queue(Config::$userQueuePath);
$queueItem = new QueueItem(strtolower($controllerContext->userName));
$user = R::findOne('user', 'LOWER(name) = LOWER(?)', [$controllerContext->userName]);
$profileAge = time() - strtotime($user->processed);
$banned = BanHelper::getUserBanState($controllerContext->userName) != BanHelper::USER_BAN_NONE;
if ($profileAge > Config::$userQueueMinWait and !$banned && Config::$enqueueEnabled) {
$queue->enqueue($queueItem);
}
$j['user'] = $controllerContext->userName;
$j['pos'] = $queue->seek($queueItem);
$viewContext->layoutName = 'layout-json';
$viewContext->json = $j;
}