当前位置: 首页>>代码示例>>PHP>>正文


PHP Queue::remove方法代码示例

本文整理汇总了PHP中Queue::remove方法的典型用法代码示例。如果您正苦于以下问题:PHP Queue::remove方法的具体用法?PHP Queue::remove怎么用?PHP Queue::remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Queue的用法示例。

在下文中一共展示了Queue::remove方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: remove

 public function remove()
 {
     $id = array_shift($this->args);
     $this->out('Removing ' . $id);
     if (Queue::remove($id, $this->params['force'])) {
         $this->out('Queue Removed.');
     } else {
         $this->out('Failed to remove Queue.');
         $this->out(Queue::view($id));
     }
 }
开发者ID:webtechnick,项目名称:cakephp-queue-plugin,代码行数:11,代码来源:QueueShell.php


示例2: deleteItem

 public static function deleteItem($params)
 {
     $format = Utils::getFormat($params['args'], 2, 4);
     $projectType = Utils::getProjectType($params['args']);
     $projectSlugIndex = $projectType == 'system' ? 0 : 2;
     $projectSlug = $params['args'][$projectSlugIndex];
     $project = new Project($projectSlug);
     $itemIndex = $projectType == 'system' ? 1 : 3;
     $itemId = $params['args'][$itemIndex];
     $user = User::getAuthenticatedUser();
     switch ($params['method']) {
         // POST: Delete an item
         case 'POST':
             $status = 'success';
             $message = '';
             // Make sure the user is project admin or site admin
             RoleController::forceClearance(array('project.admin', 'project.owner', 'system.admin'), $user, array('project' => $project));
             // Load item to make sure it exists
             $item = new Item($itemId, $projectSlug);
             // Delete the file
             Media::removeFileForItem($item);
             // Delete from project proof queue
             $queue = new Queue("project.proof:{$project->slug}", false);
             $queue->remove($item);
             $queue->save();
             // Delete from project review queue (if it's there)
             $queue = new Queue("project.review:{$project->slug}", false);
             $queue->remove($item);
             $queue->save();
             // Delete from database
             if (!$item->deleteFromDatabase()) {
                 $status = 'error';
                 $message = 'errors.deleting_item';
             }
             echo json_encode(array('status' => $status, 'message' => $message));
             break;
     }
 }
开发者ID:hmmbug,项目名称:unbindery,代码行数:38,代码来源:ItemPageController.class.php


示例3: json_encode

}
echo json_encode($queue->getItems());
echo "\n";
echo "test 1 done\n\n";
try {
    Queue::register('compare', array('Point', 'compareItems'));
    Queue::register('destroy', 'destroyQueue');
} catch (Exception $e) {
    echo "FAIL\n";
    echo $e->getMessage();
}
$queue = new Queue('2');
echo "queue 1 loaded\n";
$item = $queue->getFirstItem();
echo 'first item: ' . $item . "\n";
$item = $queue->remove(new Point(4, 0));
echo 'fourth item: ' . $item . "\n";
$item = $queue->getFirstItem();
echo 'second item: ' . $item . "\n";
if ($queue->save()) {
    echo "\nsaved.\n";
}
echo json_encode($queue->getItems());
echo "\n";
$items = $queue->getItems();
$items[] = new Point(4, 3);
$items[] = new Point(5, 3);
$items[] = new Point(1, 1);
$queue->setItems($items);
$queue->add(new Point(42, 222));
if ($queue->save()) {
开发者ID:hmmbug,项目名称:unbindery,代码行数:31,代码来源:queue-test.php


示例4: getNextAvailableItem

 public static function getNextAvailableItem($params)
 {
     $username = $params['username'];
     $projectSlug = $params['projectSlug'];
     $type = $params['type'];
     $role = $type . "er";
     $success = false;
     $errorCode = '';
     $db = Settings::getProtected('db');
     $auth = Settings::getProtected('auth');
     // Make sure we're authenticated as the user we say we are
     $auth->forceAuthentication();
     $loggedInUsername = $auth->getUsername();
     if ($username != $loggedInUsername) {
         $code = "not-authenticated-as-correct-user";
     }
     // Load user
     $user = new User($username);
     // Does this user belong to the project?
     if (!$user->isMember($projectSlug, $role)) {
         $code = "not-a-member";
     }
     // Does this user already have an item from this project?
     if ($user->hasProjectItem($projectSlug)) {
         $code = "has-unfinished-item";
     }
     // Load the user's queue
     $userQueue = new Queue("user.{$type}:{$username}", false, array('include-removed' => true));
     $userQueueItems = $userQueue->getItems();
     // Load the project's queue
     $queue = new Queue("project.{$type}:{$projectSlug}");
     $queueItems = $queue->getItems();
     // Go through the project queue and get the first item the user hasn't yet done
     foreach ($queueItems as $item) {
         if (!in_array($item, $userQueueItems)) {
             $nextItem = $item;
             break;
         }
     }
     if (isset($nextItem) && $nextItem->item_id != -1) {
         // Concatenate proofed transcripts
         if ($type == 'review') {
             // Get proofed transcripts for the new item
             $transcripts = $db->loadItemTranscripts($nextItem->project_id, $nextItem->item_id, 'proof');
             // Only diff them if there's more than one
             if (count($transcripts) > 1) {
                 $transcriptText = Transcript::diff($transcripts);
             } else {
                 $transcriptText = $transcripts[0]['transcript'];
             }
             // Only get the fields for the first transcript
             $transcriptFields = $transcripts[0]['fields'];
             // Create transcript and add to the database
             $transcript = new Transcript();
             $transcript->setText($transcriptText);
             $transcript->setFields($transcriptFields);
             $transcript->save(array('item' => $nextItem, 'status' => 'draft', 'type' => 'review'));
         }
         // Reload the user's queue, this time ignoring items they've already done
         // Add it to the user's queue
         $userQueue = new Queue("user.{$type}:{$username}", false);
         $userQueue->add($nextItem);
         $userQueue->save();
         // Remove it from the project queue
         $queue->remove($nextItem);
         $queue->save();
         $success = true;
         $code = $nextItem->item_id;
     } else {
         $code = "no-item-available";
     }
     return array('status' => $success, 'code' => $code);
 }
开发者ID:hmmbug,项目名称:unbindery,代码行数:73,代码来源:DispatchController.class.php



注:本文中的Queue::remove方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。