本文整理匯總了PHP中ManiphestTask::initializeNewTask方法的典型用法代碼示例。如果您正苦於以下問題:PHP ManiphestTask::initializeNewTask方法的具體用法?PHP ManiphestTask::initializeNewTask怎麽用?PHP ManiphestTask::initializeNewTask使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ManiphestTask
的用法示例。
在下文中一共展示了ManiphestTask::initializeNewTask方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: generateObject
public function generateObject()
{
$author_phid = $this->loadPhabrictorUserPHID();
$author = id(new PhabricatorUser())->loadOneWhere('phid = %s', $author_phid);
$task = ManiphestTask::initializeNewTask($author)->setSubPriority($this->generateTaskSubPriority())->setTitle($this->generateTitle());
$content_source = PhabricatorContentSource::newForSource(PhabricatorContentSource::SOURCE_UNKNOWN, array());
$template = new ManiphestTransaction();
// Accumulate Transactions
$changes = array();
$changes[ManiphestTransaction::TYPE_TITLE] = $this->generateTitle();
$changes[ManiphestTransaction::TYPE_DESCRIPTION] = $this->generateDescription();
$changes[ManiphestTransaction::TYPE_OWNER] = $this->loadOwnerPHID();
$changes[ManiphestTransaction::TYPE_STATUS] = $this->generateTaskStatus();
$changes[ManiphestTransaction::TYPE_PRIORITY] = $this->generateTaskPriority();
$changes[PhabricatorTransactions::TYPE_SUBSCRIBERS] = array('=' => $this->getCCPHIDs());
$transactions = array();
foreach ($changes as $type => $value) {
$transaction = clone $template;
$transaction->setTransactionType($type);
$transaction->setNewValue($value);
$transactions[] = $transaction;
}
$transactions[] = id(new ManiphestTransaction())->setTransactionType(PhabricatorTransactions::TYPE_EDGE)->setMetadataValue('edge:type', PhabricatorProjectObjectHasProjectEdgeType::EDGECONST)->setNewValue(array('=' => array_fuse($this->getProjectPHIDs())));
// Apply Transactions
$editor = id(new ManiphestTransactionEditor())->setActor($author)->setContentSource($content_source)->setContinueOnNoEffect(true)->setContinueOnMissingFields(true)->applyTransactions($task, $transactions);
return $task;
}
示例2: testFileVisibility
public function testFileVisibility()
{
$engine = new PhabricatorTestStorageEngine();
$data = Filesystem::readRandomCharacters(64);
$author = $this->generateNewTestUser();
$viewer = $this->generateNewTestUser();
$users = array($author, $viewer);
$params = array('name' => 'test.dat', 'viewPolicy' => PhabricatorPolicies::POLICY_NOONE, 'authorPHID' => $author->getPHID(), 'storageEngines' => array($engine));
$file = PhabricatorFile::newFromFileData($data, $params);
$filter = new PhabricatorPolicyFilter();
// Test bare file policies.
$this->assertEqual(array(true, false), $this->canViewFile($users, $file), pht('File Visibility'));
// Create an object and test object policies.
$object = ManiphestTask::initializeNewTask($author);
$object->setViewPolicy(PhabricatorPolicies::getMostOpenPolicy());
$object->save();
$this->assertTrue($filter->hasCapability($author, $object, PhabricatorPolicyCapability::CAN_VIEW), pht('Object Visible to Author'));
$this->assertTrue($filter->hasCapability($viewer, $object, PhabricatorPolicyCapability::CAN_VIEW), pht('Object Visible to Others'));
// Attach the file to the object and test that the association opens a
// policy exception for the non-author viewer.
$file->attachToObject($object->getPHID());
// Test the attached file's visibility.
$this->assertEqual(array(true, true), $this->canViewFile($users, $file), pht('Attached File Visibility'));
// Create a "thumbnail" of the original file.
$params = array('name' => 'test.thumb.dat', 'viewPolicy' => PhabricatorPolicies::POLICY_NOONE, 'storageEngines' => array($engine));
$xform = PhabricatorFile::newFromFileData($data, $params);
id(new PhabricatorTransformedFile())->setOriginalPHID($file->getPHID())->setTransform('test-thumb')->setTransformedPHID($xform->getPHID())->save();
// Test the thumbnail's visibility.
$this->assertEqual(array(true, true), $this->canViewFile($users, $xform), pht('Attached Thumbnail Visibility'));
// Detach the object and make sure it affects the thumbnail.
$file->detachFromObject($object->getPHID());
// Test the detached thumbnail's visibility.
$this->assertEqual(array(true, false), $this->canViewFile($users, $xform), pht('Detached Thumbnail Visibility'));
}
示例3: processReceivedMail
protected function processReceivedMail(PhabricatorMetaMTAReceivedMail $mail, PhabricatorUser $sender)
{
$task = ManiphestTask::initializeNewTask($sender);
$task->setOriginalEmailSource($mail->getHeader('From'));
$handler = PhabricatorEnv::newObjectFromConfig('metamta.maniphest.reply-handler');
$handler->setMailReceiver($task);
$handler->setActor($sender);
$handler->setExcludeMailRecipientPHIDs($mail->loadExcludeMailRecipientPHIDs());
$handler->processEmail($mail);
$mail->setRelatedPHID($task->getPHID());
}
示例4: processReceivedMail
protected function processReceivedMail(PhabricatorMetaMTAReceivedMail $mail, PhabricatorUser $sender)
{
$task = ManiphestTask::initializeNewTask($sender);
$task->setOriginalEmailSource($mail->getHeader('From'));
$handler = new ManiphestReplyHandler();
$handler->setMailReceiver($task);
$handler->setActor($sender);
$handler->setExcludeMailRecipientPHIDs($mail->loadAllRecipientPHIDs());
if ($this->getApplicationEmail()) {
$handler->setApplicationEmail($this->getApplicationEmail());
}
$handler->processEmail($mail);
$mail->setRelatedPHID($task->getPHID());
}
示例5: testCustomPolicyRuleLunarPhase
public function testCustomPolicyRuleLunarPhase()
{
$user_a = $this->generateNewTestUser();
$author = $this->generateNewTestUser();
$policy = id(new PhabricatorPolicy())->setRules(array(array('action' => PhabricatorPolicy::ACTION_ALLOW, 'rule' => 'PhabricatorPolicyRuleLunarPhase', 'value' => 'new')))->save();
$task = ManiphestTask::initializeNewTask($author);
$task->setViewPolicy($policy->getPHID());
$task->save();
$time_a = PhabricatorTime::pushTime(934354800, 'UTC');
$can_a_view = PhabricatorPolicyFilter::hasCapability($user_a, $task, PhabricatorPolicyCapability::CAN_VIEW);
$this->assertTrue($can_a_view);
unset($time_a);
$time_b = PhabricatorTime::pushTime(1116745200, 'UTC');
$can_a_view = PhabricatorPolicyFilter::hasCapability($user_a, $task, PhabricatorPolicyCapability::CAN_VIEW);
$this->assertFalse($can_a_view);
unset($time_b);
}
示例6: addTask
function addTask($kan_task, $project_id)
{
$user = getAdmin();
$task = ManiphestTask::initializeNewTask($user);
$changes = array();
$transactions = array();
$changes[ManiphestTransaction::TYPE_TITLE] = $kan_task['title'];
$changes[ManiphestTransaction::TYPE_DESCRIPTION] = $kan_task['description'];
$changes[ManiphestTransaction::TYPE_STATUS] = ManiphestTaskStatus::getDefaultStatus();
$changes[PhabricatorTransactions::TYPE_COMMENT] = null;
$project_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST;
$transactions[] = id(new ManiphestTransaction())->setTransactionType(PhabricatorTransactions::TYPE_EDGE)->setMetadataValue('edge:type', $project_type)->setNewValue(array('=' => array_fuse(array($project_id))));
$template = new ManiphestTransaction();
foreach ($changes as $type => $value) {
$transaction = clone $template;
$transaction->setTransactionType($type);
$transaction->setNewValue($value);
$transactions[] = $transaction;
}
$editor = id(new ManiphestTransactionEditor())->setActor($user)->setContentSourceFromConduitRequest(new ConduitAPIRequest(array()))->setContinueOnNoEffect(true);
$editor->applyTransactions($task, $transactions);
}
示例7: newEditableObject
protected function newEditableObject()
{
return ManiphestTask::initializeNewTask($this->getViewer());
}
示例8: processRequest
public function processRequest()
{
$request = $this->getRequest();
$user = $request->getUser();
$response_type = $request->getStr('responseType', 'task');
$order = $request->getStr('order', PhabricatorProjectColumn::DEFAULT_ORDER);
$can_edit_assign = $this->hasApplicationCapability(ManiphestEditAssignCapability::CAPABILITY);
$can_edit_policies = $this->hasApplicationCapability(ManiphestEditPoliciesCapability::CAPABILITY);
$can_edit_priority = $this->hasApplicationCapability(ManiphestEditPriorityCapability::CAPABILITY);
$can_edit_projects = $this->hasApplicationCapability(ManiphestEditProjectsCapability::CAPABILITY);
$can_edit_status = $this->hasApplicationCapability(ManiphestEditStatusCapability::CAPABILITY);
$parent_task = null;
$template_id = null;
if ($this->id) {
$task = id(new ManiphestTaskQuery())->setViewer($user)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->withIDs(array($this->id))->executeOne();
if (!$task) {
return new Aphront404Response();
}
} else {
$task = ManiphestTask::initializeNewTask($user);
// We currently do not allow you to set the task status when creating
// a new task, although now that statuses are custom it might make
// sense.
$can_edit_status = false;
// These allow task creation with defaults.
if (!$request->isFormPost()) {
$task->setTitle($request->getStr('title'));
if ($can_edit_projects) {
$projects = $request->getStr('projects');
if ($projects) {
$tokens = $request->getStrList('projects');
$type_project = PhabricatorProjectProjectPHIDType::TYPECONST;
foreach ($tokens as $key => $token) {
if (phid_get_type($token) == $type_project) {
// If this is formatted like a PHID, leave it as-is.
continue;
}
if (preg_match('/^#/', $token)) {
// If this already has a "#", leave it as-is.
continue;
}
// Add a "#" prefix.
$tokens[$key] = '#' . $token;
}
$default_projects = id(new PhabricatorObjectQuery())->setViewer($user)->withNames($tokens)->execute();
$default_projects = mpull($default_projects, 'getPHID');
if ($default_projects) {
$task->attachProjectPHIDs($default_projects);
}
}
}
if ($can_edit_priority) {
$priority = $request->getInt('priority');
if ($priority !== null) {
$priority_map = ManiphestTaskPriority::getTaskPriorityMap();
if (isset($priority_map[$priority])) {
$task->setPriority($priority);
}
}
}
$task->setDescription($request->getStr('description'));
if ($can_edit_assign) {
$assign = $request->getStr('assign');
if (strlen($assign)) {
$assign_user = id(new PhabricatorPeopleQuery())->setViewer($user)->withUsernames(array($assign))->executeOne();
if (!$assign_user) {
$assign_user = id(new PhabricatorPeopleQuery())->setViewer($user)->withPHIDs(array($assign))->executeOne();
}
if ($assign_user) {
$task->setOwnerPHID($assign_user->getPHID());
}
}
}
}
$template_id = $request->getInt('template');
// You can only have a parent task if you're creating a new task.
$parent_id = $request->getInt('parent');
if ($parent_id) {
$parent_task = id(new ManiphestTaskQuery())->setViewer($user)->withIDs(array($parent_id))->executeOne();
if (!$template_id) {
$template_id = $parent_id;
}
}
}
$errors = array();
$e_title = true;
$field_list = PhabricatorCustomField::getObjectFields($task, PhabricatorCustomField::ROLE_EDIT);
$field_list->setViewer($user);
$field_list->readFieldsFromStorage($task);
$aux_fields = $field_list->getFields();
if ($request->isFormPost()) {
$changes = array();
$new_title = $request->getStr('title');
$new_desc = $request->getStr('description');
$new_status = $request->getStr('status');
if (!$task->getID()) {
$workflow = 'create';
} else {
$workflow = '';
}
//.........這裏部分代碼省略.........
示例9: testObjectPolicyRuleSubscribers
public function testObjectPolicyRuleSubscribers()
{
$author = $this->generateNewTestUser();
$rule = new PhabricatorSubscriptionsSubscribersPolicyRule();
$task = ManiphestTask::initializeNewTask($author);
$task->setViewPolicy($rule->getObjectPolicyFullKey());
$task->save();
$this->assertFalse(PhabricatorPolicyFilter::hasCapability($author, $task, PhabricatorPolicyCapability::CAN_VIEW));
id(new PhabricatorSubscriptionsEditor())->setActor($author)->setObject($task)->subscribeExplicit(array($author->getPHID()))->save();
$this->assertTrue(PhabricatorPolicyFilter::hasCapability($author, $task, PhabricatorPolicyCapability::CAN_VIEW));
}
示例10: newTask
private function newTask(PhabricatorUser $viewer, array $projects, $name = null)
{
$task = ManiphestTask::initializeNewTask($viewer);
if (!strlen($name)) {
$name = pht('Test Task');
}
$xactions = array();
$xactions[] = id(new ManiphestTransaction())->setTransactionType(ManiphestTransaction::TYPE_TITLE)->setNewValue($name);
if ($projects) {
$xactions[] = id(new ManiphestTransaction())->setTransactionType(PhabricatorTransactions::TYPE_EDGE)->setMetadataValue('edge:type', PhabricatorProjectObjectHasProjectEdgeType::EDGECONST)->setNewValue(array('=' => array_fuse(mpull($projects, 'getPHID'))));
}
$editor = id(new ManiphestTransactionEditor())->setActor($viewer)->setContentSource(PhabricatorContentSource::newConsoleSource())->setContinueOnNoEffect(true)->applyTransactions($task, $xactions);
return $task;
}
示例11: syncItem
private function syncItem(NuanceItem $item, NuanceItemCommand $command)
{
$xobj_phid = $item->getItemProperty('doorkeeper.xobj.phid');
if (!$xobj_phid) {
throw new Exception(pht('Unable to sync: no external object PHID.'));
}
// TODO: Write some kind of marker to prevent double-synchronization.
$viewer = $this->getViewer();
$xobj = id(new DoorkeeperExternalObjectQuery())->setViewer($viewer)->withPHIDs(array($xobj_phid))->executeOne();
if (!$xobj) {
throw new Exception(pht('Unable to sync: failed to load object "%s".', $xobj_phid));
}
$acting_as_phid = $this->getActingAsPHID($item);
$xactions = array();
$task = id(new ManiphestTaskQuery())->setViewer($viewer)->withBridgedObjectPHIDs(array($xobj_phid))->executeOne();
if (!$task) {
$task = ManiphestTask::initializeNewTask($viewer)->setAuthorPHID($acting_as_phid)->setBridgedObjectPHID($xobj_phid);
$title = $xobj->getProperty('task.title');
if (!strlen($title)) {
$title = pht('Nuance Item %d Task', $item->getID());
}
$description = $xobj->getProperty('task.description');
$created = $xobj->getProperty('task.created');
$state = $xobj->getProperty('task.state');
$xactions[] = id(new ManiphestTransaction())->setTransactionType(ManiphestTransaction::TYPE_TITLE)->setNewValue($title)->setDateCreated($created);
$xactions[] = id(new ManiphestTransaction())->setTransactionType(ManiphestTransaction::TYPE_DESCRIPTION)->setNewValue($description)->setDateCreated($created);
$task->setDateCreated($created);
// TODO: Synchronize state.
}
$event = $this->newRawEvent($item);
$comment = $event->getComment();
if (strlen($comment)) {
$xactions[] = id(new ManiphestTransaction())->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)->attachComment(id(new ManiphestTransactionComment())->setContent($comment));
}
$agent_phid = $command->getAuthorPHID();
$source = $this->newContentSource($item, $agent_phid);
$editor = id(new ManiphestTransactionEditor())->setActor($viewer)->setActingAsPHID($acting_as_phid)->setContentSource($source)->setContinueOnNoEffect(true)->setContinueOnMissingFields(true);
$xactions = $editor->applyTransactions($task, $xactions);
return array('objectPHID' => $task->getPHID(), 'xactionPHIDs' => mpull($xactions, 'getPHID'));
}
示例12: newTask
private function newTask(PhabricatorUser $viewer, $title)
{
$task = ManiphestTask::initializeNewTask($viewer);
$xactions = array();
$xactions[] = id(new ManiphestTransaction())->setTransactionType(ManiphestTransaction::TYPE_TITLE)->setNewValue($title);
$this->applyTaskTransactions($viewer, $task, $xactions);
return $task;
}
示例13: execute
protected function execute(ConduitAPIRequest $request)
{
$task = ManiphestTask::initializeNewTask($request->getUser());
$task = $this->applyRequest($task, $request, $is_new = true);
return $this->buildTaskInfoDictionary($task);
}
示例14: receiveEmail
protected function receiveEmail(PhabricatorMetaMTAReceivedMail $mail)
{
// NOTE: We'll drop in here on both the "reply to a task" and "create a
// new task" workflows! Make sure you test both if you make changes!
$task = $this->getMailReceiver();
$is_new_task = !$task->getID();
$user = $this->getActor();
$body_data = $mail->parseBody();
$body = $body_data['body'];
$body = $this->enhanceBodyWithAttachments($body, $mail->getAttachments());
$xactions = array();
$content_source = PhabricatorContentSource::newForSource(PhabricatorContentSource::SOURCE_EMAIL, array('id' => $mail->getID()));
$template = new ManiphestTransaction();
$is_unsub = false;
if ($is_new_task) {
$task = ManiphestTask::initializeNewTask($user);
$xactions[] = id(new ManiphestTransaction())->setTransactionType(ManiphestTransaction::TYPE_STATUS)->setNewValue(ManiphestTaskStatus::getDefaultStatus());
$xactions[] = id(new ManiphestTransaction())->setTransactionType(ManiphestTransaction::TYPE_TITLE)->setNewValue(nonempty($mail->getSubject(), pht('Untitled Task')));
$xactions[] = id(new ManiphestTransaction())->setTransactionType(ManiphestTransaction::TYPE_DESCRIPTION)->setNewValue($body);
} else {
$command = $body_data['command'];
$command_value = $body_data['command_value'];
$ttype = PhabricatorTransactions::TYPE_COMMENT;
$new_value = null;
switch ($command) {
case 'close':
$ttype = ManiphestTransaction::TYPE_STATUS;
$new_value = ManiphestTaskStatus::getDefaultClosedStatus();
break;
case 'claim':
$ttype = ManiphestTransaction::TYPE_OWNER;
$new_value = $user->getPHID();
break;
case 'assign':
$ttype = ManiphestTransaction::TYPE_OWNER;
if ($command_value) {
$assign_users = id(new PhabricatorPeopleQuery())->setViewer($user)->withUsernames(array($command_value))->execute();
if ($assign_users) {
$assign_user = head($assign_users);
$new_value = $assign_user->getPHID();
}
}
// assign to the user by default
if (!$new_value) {
$new_value = $user->getPHID();
}
break;
case 'unsubscribe':
$is_unsub = true;
$ttype = ManiphestTransaction::TYPE_CCS;
$ccs = $task->getCCPHIDs();
foreach ($ccs as $k => $phid) {
if ($phid == $user->getPHID()) {
unset($ccs[$k]);
}
}
$new_value = array_values($ccs);
break;
}
if ($ttype != PhabricatorTransactions::TYPE_COMMENT) {
$xaction = clone $template;
$xaction->setTransactionType($ttype);
$xaction->setNewValue($new_value);
$xactions[] = $xaction;
}
if (strlen($body)) {
$xaction = clone $template;
$xaction->setTransactionType(PhabricatorTransactions::TYPE_COMMENT);
$xaction->attachComment(id(new ManiphestTransactionComment())->setContent($body));
$xactions[] = $xaction;
}
}
$ccs = $mail->loadCCPHIDs();
$old_ccs = $task->getCCPHIDs();
$new_ccs = array_merge($old_ccs, $ccs);
if (!$is_unsub) {
$new_ccs[] = $user->getPHID();
}
$new_ccs = array_unique($new_ccs);
if (array_diff($new_ccs, $old_ccs)) {
$cc_xaction = clone $template;
$cc_xaction->setTransactionType(ManiphestTransaction::TYPE_CCS);
$cc_xaction->setNewValue($new_ccs);
$xactions[] = $cc_xaction;
}
$event = new PhabricatorEvent(PhabricatorEventType::TYPE_MANIPHEST_WILLEDITTASK, array('task' => $task, 'mail' => $mail, 'new' => $is_new_task, 'transactions' => $xactions));
$event->setUser($user);
PhutilEventEngine::dispatchEvent($event);
$task = $event->getValue('task');
$xactions = $event->getValue('transactions');
$editor = id(new ManiphestTransactionEditor())->setActor($user)->setParentMessageID($mail->getMessageID())->setExcludeMailRecipientPHIDs($this->getExcludeMailRecipientPHIDs())->setContinueOnNoEffect(true)->setContinueOnMissingFields(true)->setContentSource($content_source)->applyTransactions($task, $xactions);
$event = new PhabricatorEvent(PhabricatorEventType::TYPE_MANIPHEST_DIDEDITTASK, array('task' => $task, 'new' => $is_new_task, 'transactions' => $xactions));
$event->setUser($user);
PhutilEventEngine::dispatchEvent($event);
}
示例15: generateTask
public function generateTask($project, $start, $end)
{
// Decide when the task was created
switch (mt_rand(0, 10)) {
case 0:
// A few are created during sprint
$date_created = mt_rand($start, $end);
break;
default:
// Most are created sometime in the 3 days before the sprint
$date_created = mt_rand($start - 3 * 24 * 60 * 60, $start);
break;
}
$author = $this->loadPhabrictorUser();
$task = ManiphestTask::initializeNewTask($author);
$task->setDateCreated($date_created);
$content_source = PhabricatorContentSource::newForSource(PhabricatorContentSource::SOURCE_UNKNOWN, array());
$template = new ManiphestTransaction();
// Accumulate Transactions
$changes = array();
$changes[ManiphestTransaction::TYPE_TITLE] = $this->generateTitle();
$changes[ManiphestTransaction::TYPE_DESCRIPTION] = $this->generateDescription();
$changes[ManiphestTransaction::TYPE_OWNER] = $this->loadOwnerPHID();
$changes[ManiphestTransaction::TYPE_STATUS] = ManiphestTaskStatus::STATUS_OPEN;
$changes[ManiphestTransaction::TYPE_PRIORITY] = $this->generateTaskPriority();
$changes[ManiphestTransaction::TYPE_CCS] = $this->getCCPHIDs();
$transactions = array();
foreach ($changes as $type => $value) {
$transaction = clone $template;
$transaction->setTransactionType($type);
$transaction->setDateCreated($date_created);
$transaction->setNewValue($value);
$transactions[] = $transaction;
}
// For most tasks, project will be added when created
// But for a few, let's add it later
$project_added = mt_rand(0, 10) == 0 ? mt_rand($date_created, $end) : $date_created;
$transactions[] = id(new ManiphestTransaction())->setTransactionType(PhabricatorTransactions::TYPE_EDGE)->setDateCreated($project_added)->setMetadataValue('edge:type', PhabricatorProjectObjectHasProjectEdgeType::EDGECONST)->setNewValue(array('=' => array($project->getPHID() => $project->getPHID())));
// Set points when created
$points = mt_rand(0, 10);
$transactions[] = id(new ManiphestTransaction())->setTransactionType(PhabricatorTransactions::TYPE_CUSTOMFIELD)->setMetadataValue('customfield:key', 'isdc:sprint:storypoints')->setDateCreated($date_created)->setOldValue(null)->setNewValue($points);
$editor = id(new ManiphestTransactionEditor())->setActor($author)->setContentSource($content_source)->setContinueOnNoEffect(true)->setContinueOnMissingFields(true);
// Apply and clear transactions
$editor->applyTransactions($task, $transactions);
$transactions = array();
// For some tasks, change points part way through sprint
if (mt_rand(0, 10) == 0) {
$transactions[] = id(new ManiphestTransaction())->setTransactionType(PhabricatorTransactions::TYPE_CUSTOMFIELD)->setMetadataValue('customfield:key', 'isdc:sprint:storypoints')->setDateCreated(mt_rand($date_created, $end))->setOldValue($points)->setNewValue(mt_rand(0, 10));
}
// Close some amount of the tasks in the sprint
$total_days = floor(($end - $start) / 24 * 60 * 60);
$elapsed_days = floor((time() - $start) / 24 * 60 * 60);
if (mt_rand(0, $total_days) <= $elapsed_days) {
$transactions[] = id(new ManiphestTransaction())->setTransactionType(ManiphestTransaction::TYPE_STATUS)->setDateCreated(mt_rand(max($date_created, $start), $end))->setNewValue(ManiphestTaskStatus::STATUS_CLOSED_RESOLVED);
}
// Apply any "during sprint" transactions
if ($transactions) {
$editor->applyTransactions($task, $transactions);
}
return $task;
}