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


PHP PhabricatorTime::getNow方法代码示例

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


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

示例1: renderResultList

 protected function renderResultList(array $countdowns, PhabricatorSavedQuery $query, array $handles)
 {
     assert_instances_of($countdowns, 'PhabricatorCountdown');
     $viewer = $this->requireViewer();
     $list = new PHUIObjectItemListView();
     $list->setUser($viewer);
     foreach ($countdowns as $countdown) {
         $id = $countdown->getID();
         $ended = false;
         $epoch = $countdown->getEpoch();
         if ($epoch <= PhabricatorTime::getNow()) {
             $ended = true;
         }
         $item = id(new PHUIObjectItemView())->setUser($viewer)->setObject($countdown)->setObjectName("C{$id}")->setHeader($countdown->getTitle())->setHref($this->getApplicationURI("{$id}/"))->addByline(pht('Created by %s', $handles[$countdown->getAuthorPHID()]->renderLink()));
         if ($ended) {
             $item->addAttribute(pht('Launched on %s', phabricator_datetime($epoch, $viewer)));
             $item->setDisabled(true);
         } else {
             $time_left = $epoch - PhabricatorTime::getNow();
             $num = round($time_left / (60 * 60 * 24));
             $noun = pht('Days');
             if ($num < 1) {
                 $num = round($time_left / (60 * 60), 1);
                 $noun = pht('Hours');
             }
             $item->setCountdown($num, $noun);
             $item->addAttribute(phabricator_datetime($epoch, $viewer));
         }
         $list->addItem($item);
     }
     $result = new PhabricatorApplicationSearchResultView();
     $result->setObjectList($list);
     $result->setNoDataString(pht('No countdowns found.'));
     return $result;
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:35,代码来源:PhabricatorCountdownSearchEngine.php

示例2: execute

 public function execute(PhutilArgumentParser $args)
 {
     $console = PhutilConsole::getConsole();
     $viewer = $this->getViewer();
     $since = PhabricatorTime::getNow() - phutil_units('30 days in seconds');
     $until = PhabricatorTime::getNow();
     $mails = id(new PhabricatorMetaMTAMailQuery())->setViewer($viewer)->withDateCreatedBetween($since, $until)->execute();
     $unfiltered = array();
     foreach ($mails as $mail) {
         $unfiltered_actors = mpull($mail->loadAllActors(), 'getPHID');
         foreach ($unfiltered_actors as $phid) {
             if (empty($unfiltered[$phid])) {
                 $unfiltered[$phid] = 0;
             }
             $unfiltered[$phid]++;
         }
     }
     arsort($unfiltered);
     $table = id(new PhutilConsoleTable())->setBorders(true)->addColumn('user', array('title' => pht('User')))->addColumn('unfiltered', array('title' => pht('Unfiltered')));
     $handles = $viewer->loadHandles(array_keys($unfiltered));
     $names = mpull(iterator_to_array($handles), 'getName', 'getPHID');
     foreach ($unfiltered as $phid => $count) {
         $table->addRow(array('user' => idx($names, $phid), 'unfiltered' => $count));
     }
     $table->draw();
     echo "\n";
     echo pht('Mail sent in the last 30 days.') . "\n";
     echo pht('"Unfiltered" is raw volume before preferences were applied.') . "\n";
     echo "\n";
     return 0;
 }
开发者ID:JohnnyEstilles,项目名称:phabricator,代码行数:31,代码来源:PhabricatorMailManagementVolumeWorkflow.php

示例3: loadTasks

 protected function loadTasks(PhutilArgumentParser $args)
 {
     $ids = $args->getArg('id');
     $class = $args->getArg('class');
     $min_failures = $args->getArg('min-failure-count');
     if (!$ids && !$class && !$min_failures) {
         throw new PhutilArgumentUsageException(pht('Use --id, --class, or --min-failure-count to select tasks.'));
     }
     $active_query = new PhabricatorWorkerActiveTaskQuery();
     $archive_query = new PhabricatorWorkerArchiveTaskQuery();
     if ($ids) {
         $active_query = $active_query->withIDs($ids);
         $archive_query = $archive_query->withIDs($ids);
     }
     if ($class) {
         $class_array = array($class);
         $active_query = $active_query->withClassNames($class_array);
         $archive_query = $archive_query->withClassNames($class_array);
     }
     if ($min_failures) {
         $active_query = $active_query->withFailureCountBetween($min_failures, null);
         $archive_query = $archive_query->withFailureCountBetween($min_failures, null);
     }
     $active_tasks = $active_query->execute();
     $archive_tasks = $archive_query->execute();
     $tasks = mpull($active_tasks, null, 'getID') + mpull($archive_tasks, null, 'getID');
     if ($ids) {
         foreach ($ids as $id) {
             if (empty($tasks[$id])) {
                 throw new PhutilArgumentUsageException(pht('No task exists with id "%s"!', $id));
             }
         }
     }
     if ($class && $min_failures) {
         if (!$tasks) {
             throw new PhutilArgumentUsageException(pht('No task exists with class "%s" and at least %d failures!', $class, $min_failures));
         }
     } else {
         if ($class) {
             if (!$tasks) {
                 throw new PhutilArgumentUsageException(pht('No task exists with class "%s"!', $class));
             }
         } else {
             if ($min_failures) {
                 if (!$tasks) {
                     throw new PhutilArgumentUsageException(pht('No tasks exist with at least %d failures!', $min_failures));
                 }
             }
         }
     }
     // When we lock tasks properly, this gets populated as a side effect. Just
     // fake it when doing manual CLI stuff. This makes sure CLI yields have
     // their expires times set properly.
     foreach ($tasks as $task) {
         if ($task instanceof PhabricatorWorkerActiveTask) {
             $task->setServerTime(PhabricatorTime::getNow());
         }
     }
     return $tasks;
 }
开发者ID:NeoArmageddon,项目名称:phabricator,代码行数:60,代码来源:PhabricatorWorkerManagementWorkflow.php

示例4: handleRequest

 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $id = $request->getURIData('id');
     $countdown = id(new PhabricatorCountdownQuery())->setViewer($viewer)->withIDs(array($id))->executeOne();
     if (!$countdown) {
         return new Aphront404Response();
     }
     $countdown_view = id(new PhabricatorCountdownView())->setUser($viewer)->setCountdown($countdown)->setHeadless(true);
     $id = $countdown->getID();
     $title = $countdown->getTitle();
     $crumbs = $this->buildApplicationCrumbs()->addTextCrumb("C{$id}");
     $epoch = $countdown->getEpoch();
     if ($epoch >= PhabricatorTime::getNow()) {
         $icon = 'fa-clock-o';
         $color = '';
         $status = pht('Running');
     } else {
         $icon = 'fa-check-square-o';
         $color = 'dark';
         $status = pht('Launched');
     }
     $header = id(new PHUIHeaderView())->setHeader($title)->setUser($viewer)->setPolicyObject($countdown)->setStatus($icon, $color, $status);
     $actions = $this->buildActionListView($countdown);
     $properties = $this->buildPropertyListView($countdown, $actions);
     $object_box = id(new PHUIObjectBoxView())->setHeader($header)->addPropertyList($properties);
     $timeline = $this->buildTransactionTimeline($countdown, new PhabricatorCountdownTransactionQuery());
     $add_comment = $this->buildCommentForm($countdown);
     $content = array($crumbs, $object_box, $countdown_view, $timeline, $add_comment);
     return $this->buildApplicationPage($content, array('title' => $title, 'pageObjects' => array($countdown->getPHID())));
 }
开发者ID:fengshao0907,项目名称:phabricator,代码行数:31,代码来源:PhabricatorCountdownViewController.php

示例5: execute

 public function execute(PhutilArgumentParser $args)
 {
     $console = PhutilConsole::getConsole();
     $tasks = $this->loadTasks($args);
     foreach ($tasks as $task) {
         $can_execute = !$task->isArchived();
         if (!$can_execute) {
             $console->writeOut("**<bg:yellow> %s </bg>** %s\n", pht('ARCHIVED'), pht('%s is already archived, and can not be executed.', $this->describeTask($task)));
             continue;
         }
         // NOTE: This ignores leases, maybe it should respect them without
         // a parameter like --force?
         $task->setLeaseOwner(null);
         $task->setLeaseExpires(PhabricatorTime::getNow());
         $task->save();
         $task_data = id(new PhabricatorWorkerTaskData())->loadOneWhere('id = %d', $task->getDataID());
         $task->setData($task_data->getData());
         $console->writeOut(pht('Executing task %d (%s)...', $task->getID(), $task->getTaskClass()));
         $task = $task->executeTask();
         $ex = $task->getExecutionException();
         if ($ex) {
             throw $ex;
         }
     }
     return 0;
 }
开发者ID:fengshao0907,项目名称:phabricator,代码行数:26,代码来源:PhabricatorWorkerManagementExecuteWorkflow.php

示例6: handleRequest

 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $id = $request->getURIData('id');
     $countdown = id(new PhabricatorCountdownQuery())->setViewer($viewer)->withIDs(array($id))->executeOne();
     if (!$countdown) {
         return new Aphront404Response();
     }
     $countdown_view = id(new PhabricatorCountdownView())->setUser($viewer)->setCountdown($countdown);
     $id = $countdown->getID();
     $title = $countdown->getTitle();
     $crumbs = $this->buildApplicationCrumbs()->addTextCrumb("C{$id}")->setBorder(true);
     $epoch = $countdown->getEpoch();
     if ($epoch >= PhabricatorTime::getNow()) {
         $icon = 'fa-clock-o';
         $color = '';
         $status = pht('Running');
     } else {
         $icon = 'fa-check-square-o';
         $color = 'dark';
         $status = pht('Launched');
     }
     $header = id(new PHUIHeaderView())->setHeader($title)->setUser($viewer)->setPolicyObject($countdown)->setStatus($icon, $color, $status)->setHeaderIcon('fa-rocket');
     $curtain = $this->buildCurtain($countdown);
     $subheader = $this->buildSubheaderView($countdown);
     $timeline = $this->buildTransactionTimeline($countdown, new PhabricatorCountdownTransactionQuery());
     $comment_view = id(new PhabricatorCountdownEditEngine())->setViewer($viewer)->buildEditEngineCommentView($countdown);
     $content = array($countdown_view, $timeline, $comment_view);
     $view = id(new PHUITwoColumnView())->setHeader($header)->setSubheader($subheader)->setCurtain($curtain)->setMainColumn($content);
     return $this->newPage()->setTitle($title)->setCrumbs($crumbs)->setPageObjectPHIDs(array($countdown->getPHID()))->appendChild($view);
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:31,代码来源:PhabricatorCountdownViewController.php

示例7: revokeToken

 public function revokeToken()
 {
     if ($this->isRevocable()) {
         $this->setTokenExpires(PhabricatorTime::getNow() - 1)->save();
     }
     return $this;
 }
开发者ID:pugong,项目名称:phabricator,代码行数:7,代码来源:PhabricatorAuthTemporaryToken.php

示例8: buildAbstractDocument

 protected function buildAbstractDocument(PhabricatorSearchAbstractDocument $document, $object)
 {
     $revision = id(new DifferentialRevisionQuery())->setViewer($this->getViewer())->withPHIDs(array($object->getPHID()))->needReviewerStatus(true)->executeOne();
     // TODO: This isn't very clean, but custom fields currently rely on it.
     $object->attachReviewerStatus($revision->getReviewerStatus());
     $document->setDocumentTitle($revision->getTitle());
     $document->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR, $revision->getAuthorPHID(), PhabricatorPeopleUserPHIDType::TYPECONST, $revision->getDateCreated());
     $document->addRelationship($revision->isClosed() ? PhabricatorSearchRelationship::RELATIONSHIP_CLOSED : PhabricatorSearchRelationship::RELATIONSHIP_OPEN, $revision->getPHID(), DifferentialRevisionPHIDType::TYPECONST, PhabricatorTime::getNow());
     // If a revision needs review, the owners are the reviewers. Otherwise, the
     // owner is the author (e.g., accepted, rejected, closed).
     $status_review = ArcanistDifferentialRevisionStatus::NEEDS_REVIEW;
     if ($revision->getStatus() == $status_review) {
         $reviewers = $revision->getReviewerStatus();
         $reviewers = mpull($reviewers, 'getReviewerPHID', 'getReviewerPHID');
         if ($reviewers) {
             foreach ($reviewers as $phid) {
                 $document->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_OWNER, $phid, PhabricatorPeopleUserPHIDType::TYPECONST, $revision->getDateModified());
                 // Bogus timestamp.
             }
         } else {
             $document->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_UNOWNED, $revision->getPHID(), PhabricatorPeopleUserPHIDType::TYPECONST, $revision->getDateModified());
             // Bogus timestamp.
         }
     } else {
         $document->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_OWNER, $revision->getAuthorPHID(), PhabricatorPHIDConstants::PHID_TYPE_VOID, $revision->getDateCreated());
     }
 }
开发者ID:truSense,项目名称:phabricator,代码行数:27,代码来源:DifferentialRevisionFulltextEngine.php

示例9: buildAbstractDocument

 protected function buildAbstractDocument(PhabricatorSearchAbstractDocument $document, $object)
 {
     $blog = $object;
     $document->setDocumentTitle($blog->getName());
     $document->addField(PhabricatorSearchDocumentFieldType::FIELD_BODY, $blog->getDescription());
     $document->addRelationship($blog->isArchived() ? PhabricatorSearchRelationship::RELATIONSHIP_CLOSED : PhabricatorSearchRelationship::RELATIONSHIP_OPEN, $blog->getPHID(), PhabricatorPhameBlogPHIDType::TYPECONST, PhabricatorTime::getNow());
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:7,代码来源:PhameBlogFulltextEngine.php

示例10: buildAbstractDocument

 protected function buildAbstractDocument(PhabricatorSearchAbstractDocument $document, $object)
 {
     $credential = $object;
     $document->setDocumentTitle($credential->getName());
     $document->addField(PhabricatorSearchDocumentFieldType::FIELD_BODY, $credential->getDescription());
     $document->addRelationship($credential->getIsDestroyed() ? PhabricatorSearchRelationship::RELATIONSHIP_CLOSED : PhabricatorSearchRelationship::RELATIONSHIP_OPEN, $credential->getPHID(), PassphraseCredentialPHIDType::TYPECONST, PhabricatorTime::getNow());
 }
开发者ID:phpengineer,项目名称:phabricator,代码行数:7,代码来源:PassphraseCredentialFulltextEngine.php

示例11: executeQuery

 protected final function executeQuery()
 {
     $future = $this->newQueryFuture();
     $drequest = $this->getRequest();
     $name = basename($drequest->getPath());
     $ttl = PhabricatorTime::getNow() + phutil_units('48 hours in seconds');
     try {
         $threshold = PhabricatorFileStorageEngine::getChunkThreshold();
         $future->setReadBufferSize($threshold);
         $source = id(new PhabricatorExecFutureFileUploadSource())->setName($name)->setTTL($ttl)->setViewPolicy(PhabricatorPolicies::POLICY_NOONE)->setExecFuture($future);
         $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
         $file = $source->uploadFile();
         unset($unguarded);
     } catch (CommandException $ex) {
         if (!$future->getWasKilledByTimeout()) {
             throw $ex;
         }
         $this->didHitTimeLimit = true;
         $file = null;
     }
     $byte_limit = $this->getByteLimit();
     if ($byte_limit && $file->getByteSize() > $byte_limit) {
         $this->didHitByteLimit = true;
         $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
         id(new PhabricatorDestructionEngine())->destroyObject($file);
         unset($unguarded);
         $file = null;
     }
     return $file;
 }
开发者ID:endlessm,项目名称:phabricator,代码行数:30,代码来源:DiffusionFileFutureQuery.php

示例12: getDisplayMinutes

 public function getDisplayMinutes()
 {
     $epoch = $this->getEpoch();
     $now = PhabricatorTime::getNow();
     $minutes = (int) ceil(($epoch - $now) / 60);
     return new PhutilNumber($minutes);
 }
开发者ID:NeoArmageddon,项目名称:phabricator,代码行数:7,代码来源:PhabricatorCalendarEventNotificationView.php

示例13: applyCustomInternalTransaction

 protected function applyCustomInternalTransaction(PhabricatorLiskDAO $object, PhabricatorApplicationTransaction $xaction)
 {
     switch ($xaction->getTransactionType()) {
         case PhamePostTransaction::TYPE_TITLE:
             return $object->setTitle($xaction->getNewValue());
         case PhamePostTransaction::TYPE_SUBTITLE:
             return $object->setSubtitle($xaction->getNewValue());
         case PhamePostTransaction::TYPE_BODY:
             return $object->setBody($xaction->getNewValue());
         case PhamePostTransaction::TYPE_BLOG:
             return $object->setBlogPHID($xaction->getNewValue());
         case PhamePostTransaction::TYPE_HEADERIMAGE:
             return $object->setHeaderImagePHID($xaction->getNewValue());
         case PhamePostTransaction::TYPE_VISIBILITY:
             if ($xaction->getNewValue() == PhameConstants::VISIBILITY_DRAFT) {
                 $object->setDatePublished(0);
             } else {
                 if ($xaction->getNewValue() == PhameConstants::VISIBILITY_ARCHIVED) {
                     $object->setDatePublished(0);
                 } else {
                     $object->setDatePublished(PhabricatorTime::getNow());
                 }
             }
             return $object->setVisibility($xaction->getNewValue());
     }
     return parent::applyCustomInternalTransaction($object, $xaction);
 }
开发者ID:NeoArmageddon,项目名称:phabricator,代码行数:27,代码来源:PhamePostEditor.php

示例14: buildAbstractDocument

 protected function buildAbstractDocument(PhabricatorSearchAbstractDocument $document, $object)
 {
     $project = $object;
     $project->updateDatasourceTokens();
     $document->setDocumentTitle($project->getName());
     $document->addRelationship($project->isArchived() ? PhabricatorSearchRelationship::RELATIONSHIP_CLOSED : PhabricatorSearchRelationship::RELATIONSHIP_OPEN, $project->getPHID(), PhabricatorProjectProjectPHIDType::TYPECONST, PhabricatorTime::getNow());
 }
开发者ID:phpengineer,项目名称:phabricator,代码行数:7,代码来源:PhabricatorProjectFulltextEngine.php

示例15: buildWhereClause

 protected function buildWhereClause(AphrontDatabaseConnection $conn_r)
 {
     $where = array();
     if ($this->ids !== null) {
         $where[] = qsprintf($conn_r, 'id IN (%Ld)', $this->ids);
     }
     if ($this->objectPHIDs !== null) {
         $where[] = qsprintf($conn_r, 'objectPHID IN (%Ls)', $this->objectPHIDs);
     }
     if ($this->tokens !== null) {
         $where[] = qsprintf($conn_r, 'token IN (%Ls)', $this->tokens);
     }
     if ($this->tokenTypes !== null) {
         $where[] = qsprintf($conn_r, 'tokenType IN (%Ls)', $this->tokenTypes);
     }
     if ($this->expired !== null) {
         if ($this->expired) {
             $where[] = qsprintf($conn_r, 'expires <= %d', PhabricatorTime::getNow());
         } else {
             $where[] = qsprintf($conn_r, 'expires IS NULL OR expires > %d', PhabricatorTime::getNow());
         }
     }
     $where[] = $this->buildPagingClause($conn_r);
     return $this->formatWhereClause($where);
 }
开发者ID:barcelonascience,项目名称:phabricator,代码行数:25,代码来源:PhabricatorConduitTokenQuery.php


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