ManiphestTask.php 22 KB
Newer Older
epriestley's avatar
epriestley committed
1 2
<?php

3
final class ManiphestTask extends ManiphestDAO
epriestley's avatar
epriestley committed
4
  implements
5
    PhabricatorSubscribableInterface,
epriestley's avatar
epriestley committed
6 7
    PhabricatorMarkupInterface,
    PhabricatorPolicyInterface,
8
    PhabricatorTokenReceiverInterface,
9
    PhabricatorFlaggableInterface,
10
    PhabricatorMentionableInterface,
epriestley's avatar
epriestley committed
11
    PhrequentTrackableInterface,
12
    PhabricatorCustomFieldInterface,
13
    PhabricatorDestructibleInterface,
14
    PhabricatorApplicationTransactionInterface,
epriestley's avatar
epriestley committed
15
    PhabricatorProjectInterface,
16
    PhabricatorSpacesInterface,
17
    PhabricatorConduitResultInterface,
epriestley's avatar
epriestley committed
18
    PhabricatorFulltextInterface,
19
    PhabricatorFerretInterface,
20
    DoorkeeperBridgedObjectInterface,
21
    PhabricatorEditEngineSubtypeInterface,
22
    PhabricatorEditEngineLockableInterface,
23
    PhabricatorEditEngineMFAInterface,
24 25
    PhabricatorPolicyCodexInterface,
    PhabricatorUnlockableInterface {
26 27

  const MARKUP_FIELD_DESCRIPTION = 'markup:desc';
epriestley's avatar
epriestley committed
28 29 30 31

  protected $authorPHID;
  protected $ownerPHID;

32
  protected $status;
epriestley's avatar
epriestley committed
33
  protected $priority;
34
  protected $subpriority = 0;
epriestley's avatar
epriestley committed
35

36 37
  protected $title = '';
  protected $description = '';
38
  protected $originalEmailSource;
39
  protected $mailKey;
40 41
  protected $viewPolicy = PhabricatorPolicies::POLICY_USER;
  protected $editPolicy = PhabricatorPolicies::POLICY_USER;
42

43
  protected $ownerOrdering;
epriestley's avatar
epriestley committed
44
  protected $spacePHID;
epriestley's avatar
epriestley committed
45
  protected $bridgedObjectPHID;
46
  protected $properties = array();
epriestley's avatar
epriestley committed
47
  protected $points;
48
  protected $subtype;
49

50 51
  protected $closedEpoch;
  protected $closerPHID;
52
  private $revisions = null;
53

54
  private $subscriberPHIDs = self::ATTACHABLE;
55
  private $groupByProjectPHID = self::ATTACHABLE;
epriestley's avatar
epriestley committed
56
  private $customFields = self::ATTACHABLE;
57
  private $edgeProjectPHIDs = self::ATTACHABLE;
epriestley's avatar
epriestley committed
58
  private $bridgedObject = self::ATTACHABLE;
59

60 61 62
  public static function initializeNewTask(PhabricatorUser $actor) {
    $app = id(new PhabricatorApplicationQuery())
      ->setViewer($actor)
63
      ->withClasses(array('PhabricatorManiphestApplication'))
64 65
      ->executeOne();

Joshua Spence's avatar
Joshua Spence committed
66 67
    $view_policy = $app->getPolicy(ManiphestDefaultViewCapability::CAPABILITY);
    $edit_policy = $app->getPolicy(ManiphestDefaultEditCapability::CAPABILITY);
68 69

    return id(new ManiphestTask())
70
      ->setStatus(ManiphestTaskStatus::getDefaultStatus())
71 72 73
      ->setPriority(ManiphestTaskPriority::getDefaultPriority())
      ->setAuthorPHID($actor->getPHID())
      ->setViewPolicy($view_policy)
74
      ->setEditPolicy($edit_policy)
75
      ->setSpacePHID($actor->getDefaultSpacePHID())
76
      ->setSubtype(PhabricatorEditEngineSubtype::SUBTYPE_DEFAULT)
77 78
      ->attachProjectPHIDs(array())
      ->attachSubscriberPHIDs(array());
79 80
  }

81
  protected function getConfiguration() {
epriestley's avatar
epriestley committed
82 83 84
    return array(
      self::CONFIG_AUX_PHID => true,
      self::CONFIG_SERIALIZATION => array(
85
        'properties' => self::SERIALIZATION_JSON,
epriestley's avatar
epriestley committed
86
      ),
87 88
      self::CONFIG_COLUMN_SCHEMA => array(
        'ownerPHID' => 'phid?',
89
        'status' => 'text64',
90
        'priority' => 'uint32',
91
        'title' => 'sort',
92 93 94 95 96
        'description' => 'text',
        'mailKey' => 'bytes20',
        'ownerOrdering' => 'text64?',
        'originalEmailSource' => 'text255?',
        'subpriority' => 'double',
epriestley's avatar
epriestley committed
97
        'points' => 'double?',
epriestley's avatar
epriestley committed
98
        'bridgedObjectPHID' => 'phid?',
99
        'subtype' => 'text64',
100 101
        'closedEpoch' => 'epoch?',
        'closerPHID' => 'phid?',
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
      ),
      self::CONFIG_KEY_SCHEMA => array(
        'key_phid' => null,
        'phid' => array(
          'columns' => array('phid'),
          'unique' => true,
        ),
        'priority' => array(
          'columns' => array('priority', 'status'),
        ),
        'status' => array(
          'columns' => array('status'),
        ),
        'ownerPHID' => array(
          'columns' => array('ownerPHID', 'status'),
        ),
        'authorPHID' => array(
          'columns' => array('authorPHID', 'status'),
        ),
        'ownerOrdering' => array(
          'columns' => array('ownerOrdering'),
        ),
        'priority_2' => array(
          'columns' => array('priority', 'subpriority'),
        ),
        'key_dateCreated' => array(
          'columns' => array('dateCreated'),
        ),
        'key_dateModified' => array(
          'columns' => array('dateModified'),
        ),
133 134 135
        'key_title' => array(
          'columns' => array('title(64)'),
        ),
epriestley's avatar
epriestley committed
136 137 138 139
        'key_bridgedobject' => array(
          'columns' => array('bridgedObjectPHID'),
          'unique' => true,
        ),
140 141 142
        'key_subtype' => array(
          'columns' => array('subtype'),
        ),
143 144 145 146 147 148
        'key_closed' => array(
          'columns' => array('closedEpoch'),
        ),
        'key_closer' => array(
          'columns' => array('closerPHID', 'closedEpoch'),
        ),
149
      ),
epriestley's avatar
epriestley committed
150 151 152
    ) + parent::getConfiguration();
  }

153 154 155
  public function loadDependsOnTaskPHIDs() {
    return PhabricatorEdgeQuery::loadDestinationPHIDs(
      $this->getPHID(),
156
      ManiphestTaskDependsOnTaskEdgeType::EDGECONST);
157 158 159 160 161
  }

  public function loadDependedOnByTaskPHIDs() {
    return PhabricatorEdgeQuery::loadDestinationPHIDs(
      $this->getPHID(),
162
      ManiphestTaskDependedOnByTaskEdgeType::EDGECONST);
163 164
  }

165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
  public function loadRevisions(PhabricatorUser $viewer) {
    if ($this->revisions) {
      return;
    }

    $phids = PhabricatorEdgeQuery::loadDestinationPHIDs(
      $this->getPHID(),
      ManiphestTaskHasRevisionEdgeType::EDGECONST);

    if (count($phids) == 0) {
      $this->revisions = array();
      return;
    }

    $this->revisions = id(new DifferentialRevisionQuery())
      ->setViewer($viewer)
      ->setOrder(DifferentialRevisionQuery::ORDER_CREATED)
      ->withPHIDs($phids)
      ->execute();
  }

epriestley's avatar
epriestley committed
186
  public function generatePHID() {
Joshua Spence's avatar
Joshua Spence committed
187
    return PhabricatorPHID::generateNewPHID(ManiphestTaskPHIDType::TYPECONST);
epriestley's avatar
epriestley committed
188 189
  }

190 191
  public function getSubscriberPHIDs() {
    return $this->assertAttached($this->subscriberPHIDs);
epriestley's avatar
epriestley committed
192 193
  }

194 195
  public function getProjectPHIDs() {
    return $this->assertAttached($this->edgeProjectPHIDs);
196 197
  }

198 199 200
  public function attachProjectPHIDs(array $phids) {
    $this->edgeProjectPHIDs = $phids;
    return $this;
201 202
  }

203 204
  public function attachSubscriberPHIDs(array $phids) {
    $this->subscriberPHIDs = $phids;
205 206 207 208
    return $this;
  }

  public function setOwnerPHID($phid) {
209
    $this->ownerPHID = nonempty($phid, null);
210 211 212
    return $this;
  }

213 214 215 216
  public function getMonogram() {
    return 'T'.$this->getID();
  }

217 218 219 220
  public function getURI() {
    return '/'.$this->getMonogram();
  }

221 222 223 224 225 226 227 228 229
  public function attachGroupByProjectPHID($phid) {
    $this->groupByProjectPHID = $phid;
    return $this;
  }

  public function getGroupByProjectPHID() {
    return $this->assertAttached($this->groupByProjectPHID);
  }

230 231
  public function save() {
    if (!$this->mailKey) {
232
      $this->mailKey = Filesystem::readRandomCharacters(20);
233
    }
234 235 236 237

    $result = parent::save();

    return $result;
238 239
  }

240 241 242
  public function isClosed() {
    return ManiphestTaskStatus::isClosedStatus($this->getStatus());
  }
243

244 245 246 247 248 249 250 251 252 253
  public function areCommentsLocked() {
    if ($this->areEditsLocked()) {
      return true;
    }

    return ManiphestTaskStatus::areCommentsLockedInStatus($this->getStatus());
  }

  public function areEditsLocked() {
    return ManiphestTaskStatus::areEditsLockedInStatus($this->getStatus());
254 255
  }

256 257 258 259 260 261 262 263 264
  public function setProperty($key, $value) {
    $this->properties[$key] = $value;
    return $this;
  }

  public function getProperty($key, $default = null) {
    return idx($this->properties, $key, $default);
  }

265 266 267 268
  public function getCoverImageFilePHID() {
    return idx($this->properties, 'cover.filePHID');
  }

269 270 271 272
  public function getCoverImageThumbnailPHID() {
    return idx($this->properties, 'cover.thumbnailPHID');
  }

273 274
  public function getPriorityKeyword() {
    $priority = $this->getPriority();
275 276 277 278 279 280 281

    $keyword = ManiphestTaskPriority::getKeywordForTaskPriority($priority);
    if ($keyword !== null) {
      return $keyword;
    }

    return ManiphestTaskPriority::UNKNOWN_PRIORITY_KEYWORD;
282 283
  }

284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396
  private function comparePriorityTo(ManiphestTask $other) {
    $upri = $this->getPriority();
    $vpri = $other->getPriority();

    if ($upri != $vpri) {
      return ($upri - $vpri);
    }

    $usub = $this->getSubpriority();
    $vsub = $other->getSubpriority();

    if ($usub != $vsub) {
      return ($usub - $vsub);
    }

    $uid = $this->getID();
    $vid = $other->getID();

    if ($uid != $vid) {
      return ($uid - $vid);
    }

    return 0;
  }

  public function isLowerPriorityThan(ManiphestTask $other) {
    return ($this->comparePriorityTo($other) < 0);
  }

  public function isHigherPriorityThan(ManiphestTask $other) {
    return ($this->comparePriorityTo($other) > 0);
  }

  public function getWorkboardProperties() {
    return array(
      'status' => $this->getStatus(),
      'points' => (double)$this->getPoints(),
    );
  }

  public function getReviewIcon(PhabricatorUser $viewer) {
    // Determine an overall review/CI status for the task, pessimising heavily
    // as we do so. Discount abandoned reviews as irrelevant, then proceed
    // in the following order: needs revision, changes planned, needs review,
    // in preparation, accepted, closed.
    $priorities = array(
      DifferentialRevisionStatus::NEEDS_REVISION => 5,
      DifferentialRevisionStatus::CHANGES_PLANNED => 4,
      DifferentialRevisionStatus::NEEDS_REVIEW => 3,
      DifferentialRevisionStatus::ACCEPTED => 1,
      DifferentialRevisionStatus::PUBLISHED => 0,
      DifferentialRevisionStatus::ABANDONED => -1,
      DifferentialRevisionStatus::DRAFT => -1,
    );
    $ci_diff_map = array(
      HarbormasterBuildableStatus::STATUS_PREPARING =>
        DifferentialRevisionStatus::NEEDS_REVIEW,
      HarbormasterBuildableStatus::STATUS_BUILDING =>
        DifferentialRevisionStatus::NEEDS_REVIEW,
      HarbormasterBuildableStatus::STATUS_PASSED =>
        DifferentialRevisionStatus::ACCEPTED,
      HarbormasterBuildableStatus::STATUS_FAILED =>
        DifferentialRevisionStatus::NEEDS_REVISION,
    );
    $status = DifferentialRevisionStatus::ABANDONED;

    $this->loadRevisions($viewer);

    if (count($this->revisions) == 0) {
      return null;
    }

    foreach ($this->revisions as $revision) {
      $rev_status = $revision->getStatus();

      $diff = $revision->loadActiveDiff();
      if ($diff) {
        $buildables = id(new HarbormasterBuildableQuery())
          ->setViewer($viewer)
          ->withBuildablePHIDs(array($diff->getPHID()))
          ->withManualBuildables(true)
          ->needBuilds(true)
          ->needTargets(true)
          ->execute();

        foreach ($buildables as $buildable) {
          $ci_status = $ci_diff_map[$buildable->getStatus()];
          if ($ci_status > $rev_status) {
            $rev_status = $ci_status;
          }
        }
      }

      if ($priorities[$rev_status] >
          $priorities[$status]) {
        $status = $rev_status;
      }
    }

    switch ($status) {
    case ArcanistDifferentialRevisionStatus::ABANDONED:
      return null;
    case ArcanistDifferentialRevisionStatus::NEEDS_REVISION:
    case ArcanistDifferentialRevisionStatus::CHANGES_PLANNED:
      return 'fa-frown-o red';
    case ArcanistDifferentialRevisionStatus::NEEDS_REVIEW:
    case ArcanistDifferentialRevisionStatus::IN_PREPARATION:
      return 'fa-meh-o darkgrey';
    case ArcanistDifferentialRevisionStatus::ACCEPTED:
    case ArcanistDifferentialRevisionStatus::CLOSED:
      return 'fa-smile-o green';
    }
  }
397

398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458
  public function getRAGStatus() {
    // Based on the RAG custom field, return the color of the task

    $fields_list = PhabricatorCustomField::getObjectFields($this,
        PhabricatorCustomField::ROLE_STORAGE);
    $fields_list->readFieldsFromStorage($this);
    $fields = $fields_list->getFields();

    $status = idx($fields, 'std:maniphest:collabora:rag-status')
      ->getProxy()->getFieldValue();

    switch ($status) {
      case 'collabora:rag-red':
        return 'red';
      case 'collabora:rag-amber':
        return 'yellow';
      case 'collabora:rag-green':
        return 'green';
    }

    return '';
  }

  public function getTaskProgress(PhabricatorUser $viewer) {
    // If a task has children, sum up all their points and return the
    // progress based on closed and in progress tasks. All statuses that are not
    // 'open' or 'closed' are considered in progress.

    $total_points = 0;
    $completed_points = 0;
    $in_progress = 0;

    $children = $this->loadDependsOnTaskPHIDs();

    foreach ($children as $child) {
      $task = id(new ManiphestTaskQuery())
        ->setViewer($viewer)
        ->withPHIDs(array($child))
        ->executeOne();

      $child_progress = $task->getTaskProgress($viewer);

      $total_points += $child_progress['total_points'];
      $completed_points += $child_progress['completed_points'];
      $in_progress += $child_progress['in_progress'];
    }

    $total_points += (float)$this->getPoints();
    if ($this->isClosed()) {
        $completed_points += (float)$this->getPoints();
    } elseif ($this->getStatus() != 'open') {
        $in_progress += $this->getPoints();
    }

    return array(
      "total_points" => $total_points,
      "completed_points" => $completed_points,
      "in_progress" => $in_progress,
    );
  }

459 460 461 462 463 464 465 466
/* -(  PhabricatorSubscribableInterface  )----------------------------------- */


  public function isAutomaticallySubscribed($phid) {
    return ($phid == $this->getOwnerPHID());
  }


467 468 469 470 471 472 473
/* -(  Markup Interface  )--------------------------------------------------- */


  /**
   * @task markup
   */
  public function getMarkupFieldKey($field) {
474 475
    $content = $this->getMarkupText($field);
    return PhabricatorMarkupEngine::digestRemarkupContent($this, $content);
476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512
  }


  /**
   * @task markup
   */
  public function getMarkupText($field) {
    return $this->getDescription();
  }


  /**
   * @task markup
   */
  public function newMarkupEngine($field) {
    return PhabricatorMarkupEngine::newManiphestMarkupEngine();
  }


  /**
   * @task markup
   */
  public function didMarkupText(
    $field,
    $output,
    PhutilMarkupEngine $engine) {
    return $output;
  }


  /**
   * @task markup
   */
  public function shouldUseMarkupCache($field) {
    return (bool)$this->getID();
  }

epriestley's avatar
epriestley committed
513 514 515 516 517 518 519

/* -(  Policy Interface  )--------------------------------------------------- */


  public function getCapabilities() {
    return array(
      PhabricatorPolicyCapability::CAN_VIEW,
520
      PhabricatorPolicyCapability::CAN_INTERACT,
epriestley's avatar
epriestley committed
521 522 523 524 525
      PhabricatorPolicyCapability::CAN_EDIT,
    );
  }

  public function getPolicy($capability) {
526 527 528
    switch ($capability) {
      case PhabricatorPolicyCapability::CAN_VIEW:
        return $this->getViewPolicy();
529
      case PhabricatorPolicyCapability::CAN_INTERACT:
530
        if ($this->areCommentsLocked()) {
531 532
          return PhabricatorPolicies::POLICY_NOONE;
        } else {
533
          return $this->getViewPolicy();
534
        }
535
      case PhabricatorPolicyCapability::CAN_EDIT:
536 537 538 539 540
        if ($this->areEditsLocked()) {
          return PhabricatorPolicies::POLICY_NOONE;
        } else {
          return $this->getEditPolicy();
        }
541
    }
epriestley's avatar
epriestley committed
542 543 544
  }

  public function hasAutomaticCapability($capability, PhabricatorUser $user) {
545 546 547 548 549 550 551 552 553
    // The owner of a task can always view and edit it.
    $owner_phid = $this->getOwnerPHID();
    if ($owner_phid) {
      $user_phid = $user->getPHID();
      if ($user_phid == $owner_phid) {
        return true;
      }
    }

epriestley's avatar
epriestley committed
554 555 556
    return false;
  }

557 558 559

/* -(  PhabricatorTokenReceiverInterface  )---------------------------------- */

560

561 562 563 564 565 566 567 568 569 570
  public function getUsersToNotifyOfTokenGiven() {
    // Sort of ambiguous who this was intended for; just let them both know.
    return array_filter(
      array_unique(
        array(
          $this->getAuthorPHID(),
          $this->getOwnerPHID(),
        )));
  }

epriestley's avatar
epriestley committed
571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591

/* -(  PhabricatorCustomFieldInterface  )------------------------------------ */


  public function getCustomFieldSpecificationForRole($role) {
    return PhabricatorEnv::getEnvConfig('maniphest.fields');
  }

  public function getCustomFieldBaseClass() {
    return 'ManiphestCustomField';
  }

  public function getCustomFields() {
    return $this->assertAttached($this->customFields);
  }

  public function attachCustomFields(PhabricatorCustomFieldAttachment $fields) {
    $this->customFields = $fields;
    return $this;
  }

592

593
/* -(  PhabricatorDestructibleInterface  )----------------------------------- */
594 595 596 597 598 599


  public function destroyObjectPermanently(
    PhabricatorDestructionEngine $engine) {

    $this->openTransaction();
600
    $this->delete();
601 602 603
    $this->saveTransaction();
  }

604 605 606 607 608 609 610 611 612 613 614 615

/* -(  PhabricatorApplicationTransactionInterface  )------------------------- */


  public function getApplicationTransactionEditor() {
    return new ManiphestTransactionEditor();
  }

  public function getApplicationTransactionTemplate() {
    return new ManiphestTransaction();
  }

epriestley's avatar
epriestley committed
616 617 618 619 620 621 622 623

/* -(  PhabricatorSpacesInterface  )----------------------------------------- */


  public function getSpacePHID() {
    return $this->spacePHID;
  }

624 625 626 627 628 629

/* -(  PhabricatorConduitResultInterface  )---------------------------------- */


  public function getFieldSpecificationsForConduit() {
    return array(
630 631 632 633
      id(new PhabricatorConduitSearchFieldSpecification())
        ->setKey('title')
        ->setType('string')
        ->setDescription(pht('The title of the task.')),
634 635 636 637
      id(new PhabricatorConduitSearchFieldSpecification())
        ->setKey('description')
        ->setType('remarkup')
        ->setDescription(pht('The task description.')),
638 639 640 641 642 643 644 645 646 647
      id(new PhabricatorConduitSearchFieldSpecification())
        ->setKey('authorPHID')
        ->setType('phid')
        ->setDescription(pht('Original task author.')),
      id(new PhabricatorConduitSearchFieldSpecification())
        ->setKey('ownerPHID')
        ->setType('phid?')
        ->setDescription(pht('Current task owner, if task is assigned.')),
      id(new PhabricatorConduitSearchFieldSpecification())
        ->setKey('status')
648 649
        ->setType('map<string, wild>')
        ->setDescription(pht('Information about task status.')),
650 651
      id(new PhabricatorConduitSearchFieldSpecification())
        ->setKey('priority')
652 653
        ->setType('map<string, wild>')
        ->setDescription(pht('Information about task priority.')),
654 655 656 657
      id(new PhabricatorConduitSearchFieldSpecification())
        ->setKey('points')
        ->setType('points')
        ->setDescription(pht('Point value of the task.')),
658 659 660 661
      id(new PhabricatorConduitSearchFieldSpecification())
        ->setKey('subtype')
        ->setType('string')
        ->setDescription(pht('Subtype of the task.')),
662 663 664 665 666 667 668 669 670 671
      id(new PhabricatorConduitSearchFieldSpecification())
        ->setKey('closerPHID')
        ->setType('phid?')
        ->setDescription(
          pht('User who closed the task, if the task is closed.')),
      id(new PhabricatorConduitSearchFieldSpecification())
        ->setKey('dateClosed')
        ->setType('int?')
        ->setDescription(
          pht('Epoch timestamp when the task was closed.')),
672 673 674 675
    );
  }

  public function getFieldValuesForConduit() {
676 677 678 679 680 681 682 683 684 685 686 687 688 689
    $status_value = $this->getStatus();
    $status_info = array(
      'value' => $status_value,
      'name' => ManiphestTaskStatus::getTaskStatusName($status_value),
      'color' => ManiphestTaskStatus::getStatusColor($status_value),
    );

    $priority_value = (int)$this->getPriority();
    $priority_info = array(
      'value' => $priority_value,
      'name' => ManiphestTaskPriority::getTaskPriorityName($priority_value),
      'color' => ManiphestTaskPriority::getTaskPriorityColor($priority_value),
    );

690 691 692 693 694
    $closed_epoch = $this->getClosedEpoch();
    if ($closed_epoch !== null) {
      $closed_epoch = (int)$closed_epoch;
    }

695 696
    return array(
      'name' => $this->getTitle(),
697 698 699
      'description' => array(
        'raw' => $this->getDescription(),
      ),
700 701
      'authorPHID' => $this->getAuthorPHID(),
      'ownerPHID' => $this->getOwnerPHID(),
702 703
      'status' => $status_info,
      'priority' => $priority_info,
704
      'points' => $this->getPoints(),
705
      'subtype' => $this->getSubtype(),
706 707
      'closerPHID' => $this->getCloserPHID(),
      'dateClosed' => $closed_epoch,
708 709 710
    );
  }

711
  public function getConduitSearchAttachments() {
712 713 714 715
    return array(
      id(new PhabricatorBoardColumnsSearchEngineAttachment())
        ->setAttachmentKey('columns'),
    );
716 717
  }

718 719 720
  public function newSubtypeObject() {
    $subtype_key = $this->getEditEngineSubtype();
    $subtype_map = $this->newEditEngineSubtypeMap();
721
    return $subtype_map->getSubtype($subtype_key);
722
  }
723 724 725 726 727 728 729 730

/* -(  PhabricatorFulltextInterface  )--------------------------------------- */


  public function newFulltextEngine() {
    return new ManiphestTaskFulltextEngine();
  }

epriestley's avatar
epriestley committed
731 732 733 734 735 736 737 738 739 740 741 742 743 744

/* -(  DoorkeeperBridgedObjectInterface  )----------------------------------- */


  public function getBridgedObject() {
    return $this->assertAttached($this->bridgedObject);
  }

  public function attachBridgedObject(
    DoorkeeperExternalObject $object = null) {
    $this->bridgedObject = $object;
    return $this;
  }

745 746 747 748 749 750 751 752 753 754 755 756

/* -(  PhabricatorEditEngineSubtypeInterface  )------------------------------ */


  public function getEditEngineSubtype() {
    return $this->getSubtype();
  }

  public function setEditEngineSubtype($value) {
    return $this->setSubtype($value);
  }

757 758
  public function newEditEngineSubtypeMap() {
    $config = PhabricatorEnv::getEnvConfig('maniphest.subtypes');
epriestley's avatar
epriestley committed
759 760
    return PhabricatorEditEngineSubtype::newSubtypeMap($config)
      ->setDatasource(new ManiphestTaskSubtypeDatasource());
761 762
  }

763 764 765 766 767 768 769 770

/* -(  PhabricatorEditEngineLockableInterface  )----------------------------- */


  public function newEditEngineLock() {
    return new ManiphestTaskEditEngineLock();
  }

771 772 773 774 775 776 777 778

/* -(  PhabricatorFerretInterface  )----------------------------------------- */


  public function newFerretEngine() {
    return new ManiphestTaskFerretEngine();
  }

779 780 781 782 783 784 785 786

/* -(  PhabricatorEditEngineMFAInterface  )---------------------------------- */


  public function newEditEngineMFAEngine() {
    return new ManiphestTaskMFAEngine();
  }

787 788 789 790 791 792 793 794

/* -(  PhabricatorPolicyCodexInterface  )------------------------------------ */


  public function newPolicyCodex() {
    return new ManiphestTaskPolicyCodex();
  }

795 796 797 798 799 800 801 802

/* -(  PhabricatorUnlockableInterface  )------------------------------------- */


  public function newUnlockEngine() {
    return new ManiphestTaskUnlockEngine();
  }

epriestley's avatar
epriestley committed
803
}