Changeset View
Changeset View
Standalone View
Standalone View
src/applications/project/engine/PhabricatorBoardLayoutEngine.php
| <?php | <?php | ||||
| final class PhabricatorBoardLayoutEngine extends Phobject { | final class PhabricatorBoardLayoutEngine extends Phobject { | ||||
| private $viewer; | private $viewer; | ||||
| private $boardPHIDs; | private $boardPHIDs; | ||||
| private $objectPHIDs; | private $objectPHIDs; | ||||
| private $boards; | private $boards; | ||||
| private $columnMap; | private $columnMap = array(); | ||||
| private $objectColumnMap = array(); | private $objectColumnMap = array(); | ||||
| private $boardLayout = array(); | private $boardLayout = array(); | ||||
| private $remQueue = array(); | private $remQueue = array(); | ||||
| private $addQueue = array(); | private $addQueue = array(); | ||||
| public function setViewer(PhabricatorUser $viewer) { | public function setViewer(PhabricatorUser $viewer) { | ||||
| $this->viewer = $viewer; | $this->viewer = $viewer; | ||||
| ▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | foreach ($boards as $board_phid => $board) { | ||||
| $board_positions = idx($positions, $board_phid, array()); | $board_positions = idx($positions, $board_phid, array()); | ||||
| $this->layoutBoard($board, $board_columns, $board_positions); | $this->layoutBoard($board, $board_columns, $board_positions); | ||||
| } | } | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function getColumns($board_phid) { | |||||
| $columns = idx($this->boardLayout, $board_phid, array()); | |||||
| return array_select_keys($this->columnMap, array_keys($columns)); | |||||
| } | |||||
| public function getColumnObjectPHIDs($board_phid, $column_phid) { | |||||
| $columns = idx($this->boardLayout, $board_phid, array()); | |||||
| $positions = idx($columns, $column_phid, array()); | |||||
| return mpull($positions, 'getObjectPHID'); | |||||
| } | |||||
| public function getObjectColumns($board_phid, $object_phid) { | public function getObjectColumns($board_phid, $object_phid) { | ||||
| $board_map = idx($this->objectColumnMap, $board_phid, array()); | $board_map = idx($this->objectColumnMap, $board_phid, array()); | ||||
| $column_phids = idx($board_map, $object_phid); | $column_phids = idx($board_map, $object_phid); | ||||
| if (!$column_phids) { | if (!$column_phids) { | ||||
| return array(); | return array(); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 258 Lines • ▼ Show 20 Lines | final class PhabricatorBoardLayoutEngine extends Phobject { | ||||
| private function layoutBoard( | private function layoutBoard( | ||||
| $board, | $board, | ||||
| array $columns, | array $columns, | ||||
| array $positions) { | array $positions) { | ||||
| $board_phid = $board->getPHID(); | $board_phid = $board->getPHID(); | ||||
| $position_groups = mgroup($positions, 'getObjectPHID'); | $position_groups = mgroup($positions, 'getObjectPHID'); | ||||
| $layout = array(); | |||||
| foreach ($columns as $column) { | foreach ($columns as $column) { | ||||
| $column_phid = $column->getPHID(); | |||||
| $layout[$column_phid] = array(); | |||||
| if ($column->isDefaultColumn()) { | if ($column->isDefaultColumn()) { | ||||
| $default_phid = $column->getPHID(); | $default_phid = $column_phid; | ||||
| break; | |||||
| } | } | ||||
| } | } | ||||
| $layout = array(); | |||||
| $object_phids = $this->getObjectPHIDs(); | $object_phids = $this->getObjectPHIDs(); | ||||
| foreach ($object_phids as $object_phid) { | foreach ($object_phids as $object_phid) { | ||||
| $positions = idx($position_groups, $object_phid, array()); | $positions = idx($position_groups, $object_phid, array()); | ||||
| // Remove any positions in columns which no longer exist. | // Remove any positions in columns which no longer exist. | ||||
| foreach ($positions as $key => $position) { | foreach ($positions as $key => $position) { | ||||
| $column_phid = $position->getColumnPHID(); | $column_phid = $position->getColumnPHID(); | ||||
| if (empty($columns[$column_phid])) { | if (empty($columns[$column_phid])) { | ||||
| Show All 39 Lines | |||||