Differential D20408 Diff 48715 src/applications/dashboard/layoutconfig/PhabricatorDashboardPanelRefList.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/dashboard/layoutconfig/PhabricatorDashboardPanelRefList.php
Show First 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | final class PhabricatorDashboardPanelRefList | ||||
public function getColumns() { | public function getColumns() { | ||||
return $this->columns; | return $this->columns; | ||||
} | } | ||||
public function getPanelRefs() { | public function getPanelRefs() { | ||||
return $this->refs; | return $this->refs; | ||||
} | } | ||||
public function getPanelRef($panel_key) { | |||||
foreach ($this->getPanelRefs() as $ref) { | |||||
if ($ref->getPanelKey() === $panel_key) { | |||||
return $ref; | |||||
} | |||||
} | |||||
return null; | |||||
} | |||||
public function toDictionary() { | |||||
return array_values(mpull($this->getPanelRefs(), 'toDictionary')); | |||||
} | |||||
public function newPanelRef(PhabricatorDashboardPanel $panel, $column_key) { | |||||
$ref = id(new PhabricatorDashboardPanelRef()) | |||||
->setPanelKey($this->newPanelKey()) | |||||
->setPanelPHID($panel->getPHID()) | |||||
->setColumnKey($column_key); | |||||
$this->refs[] = $ref; | |||||
return $ref; | |||||
} | |||||
public function removePanelRef(PhabricatorDashboardPanelRef $target) { | |||||
foreach ($this->refs as $key => $ref) { | |||||
if ($ref->getPanelKey() !== $target->getPanelKey()) { | |||||
continue; | |||||
} | |||||
unset($this->refs[$key]); | |||||
return $ref; | |||||
} | |||||
return null; | |||||
} | |||||
private function newPanelKey() { | |||||
return Filesystem::readRandomCharacters(8); | |||||
} | |||||
} | } |