Changeset View
Changeset View
Standalone View
Standalone View
src/applications/project/view/ProjectBoardTaskCard.php
| <?php | <?php | ||||
| final class ProjectBoardTaskCard extends Phobject { | final class ProjectBoardTaskCard extends Phobject { | ||||
| private $viewer; | private $viewer; | ||||
| private $task; | private $task; | ||||
| private $owner; | private $owner; | ||||
| private $project; | |||||
| private $handles; | |||||
| private $canEdit; | private $canEdit; | ||||
| public function setViewer(PhabricatorUser $viewer) { | public function setViewer(PhabricatorUser $viewer) { | ||||
| $this->viewer = $viewer; | $this->viewer = $viewer; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function getViewer() { | public function getViewer() { | ||||
| return $this->viewer; | return $this->viewer; | ||||
| Show All 10 Lines | final class ProjectBoardTaskCard extends Phobject { | ||||
| public function setOwner(PhabricatorObjectHandle $owner = null) { | public function setOwner(PhabricatorObjectHandle $owner = null) { | ||||
| $this->owner = $owner; | $this->owner = $owner; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function getOwner() { | public function getOwner() { | ||||
| return $this->owner; | return $this->owner; | ||||
| } | } | ||||
| public function setProject(PhabricatorProject $project) { | |||||
| $this->project = $project; | |||||
| return $this; | |||||
| } | |||||
| public function setHandles(array $handles) { | |||||
| assert_instances_of($handles, 'PhabricatorObjectHandle'); | |||||
| $this->handles = $handles; | |||||
| return $this; | |||||
| } | |||||
| public function setCanEdit($can_edit) { | public function setCanEdit($can_edit) { | ||||
| $this->canEdit = $can_edit; | $this->canEdit = $can_edit; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function getCanEdit() { | public function getCanEdit() { | ||||
| return $this->canEdit; | return $this->canEdit; | ||||
| } | } | ||||
| Show All 26 Lines | $card = id(new PHUIObjectItemView()) | ||||
| ->addSigil('edit-project-card') | ->addSigil('edit-project-card') | ||||
| ->setHref('/maniphest/task/edit/'.$task->getID().'/')) | ->setHref('/maniphest/task/edit/'.$task->getID().'/')) | ||||
| ->setBarColor($bar_color); | ->setBarColor($bar_color); | ||||
| if ($owner) { | if ($owner) { | ||||
| $card->addAttribute($owner->renderLink()); | $card->addAttribute($owner->renderLink()); | ||||
| } | } | ||||
| $project_handles = $this->getProjectHandles(); | |||||
| if (!empty($project_handles)) { | |||||
| $card->addAttribute( | |||||
| id(new PHUIHandleTagListView()) | |||||
| ->setLimit(4) | |||||
| ->setSlim(true) | |||||
| ->setHandles($project_handles)); | |||||
| } | |||||
| return $card; | return $card; | ||||
| } | } | ||||
| private function getProjectHandles() { | |||||
| $all_project_phids = $this->getTask()->getProjectPHIDs(); | |||||
| $filtered_project_phids = array_diff( | |||||
| $all_project_phids, array($this->project->getPHID())); | |||||
| return array_select_keys( | |||||
| $this->handles, | |||||
| $filtered_project_phids); | |||||
| } | |||||
| } | } | ||||