Changeset View
Changeset View
Standalone View
Standalone View
src/applications/dashboard/storage/PhabricatorDashboard.php
| Show All 18 Lines | final class PhabricatorDashboard extends PhabricatorDashboardDAO | ||||
| protected $editPolicy; | protected $editPolicy; | ||||
| protected $status; | protected $status; | ||||
| protected $icon; | protected $icon; | ||||
| protected $layoutConfig = array(); | protected $layoutConfig = array(); | ||||
| const STATUS_ACTIVE = 'active'; | const STATUS_ACTIVE = 'active'; | ||||
| const STATUS_ARCHIVED = 'archived'; | const STATUS_ARCHIVED = 'archived'; | ||||
| private $panels = self::ATTACHABLE; | |||||
| private $edgeProjectPHIDs = self::ATTACHABLE; | |||||
| private $panelRefList; | private $panelRefList; | ||||
| public static function initializeNewDashboard(PhabricatorUser $actor) { | public static function initializeNewDashboard(PhabricatorUser $actor) { | ||||
| return id(new PhabricatorDashboard()) | return id(new PhabricatorDashboard()) | ||||
| ->setName('') | ->setName('') | ||||
| ->setIcon('fa-dashboard') | ->setIcon('fa-dashboard') | ||||
| ->setViewPolicy(PhabricatorPolicies::getMostOpenPolicy()) | ->setViewPolicy(PhabricatorPolicies::getMostOpenPolicy()) | ||||
| ->setEditPolicy($actor->getPHID()) | ->setEditPolicy($actor->getPHID()) | ||||
| ->setStatus(self::STATUS_ACTIVE) | ->setStatus(self::STATUS_ACTIVE) | ||||
| ->setAuthorPHID($actor->getPHID()) | ->setAuthorPHID($actor->getPHID()); | ||||
| ->attachPanels(array()); | |||||
| } | } | ||||
| public static function getStatusNameMap() { | public static function getStatusNameMap() { | ||||
| return array( | return array( | ||||
| self::STATUS_ACTIVE => pht('Active'), | self::STATUS_ACTIVE => pht('Active'), | ||||
| self::STATUS_ARCHIVED => pht('Archived'), | self::STATUS_ARCHIVED => pht('Archived'), | ||||
| ); | ); | ||||
| } | } | ||||
| protected function getConfiguration() { | protected function getConfiguration() { | ||||
| return array( | return array( | ||||
| self::CONFIG_AUX_PHID => true, | self::CONFIG_AUX_PHID => true, | ||||
| self::CONFIG_SERIALIZATION => array( | self::CONFIG_SERIALIZATION => array( | ||||
| 'layoutConfig' => self::SERIALIZATION_JSON, | 'layoutConfig' => self::SERIALIZATION_JSON, | ||||
| ), | ), | ||||
| self::CONFIG_COLUMN_SCHEMA => array( | self::CONFIG_COLUMN_SCHEMA => array( | ||||
| 'name' => 'sort255', | 'name' => 'sort255', | ||||
| 'status' => 'text32', | 'status' => 'text32', | ||||
| 'icon' => 'text32', | 'icon' => 'text32', | ||||
| 'authorPHID' => 'phid', | 'authorPHID' => 'phid', | ||||
| ), | ), | ||||
| ) + parent::getConfiguration(); | ) + parent::getConfiguration(); | ||||
| } | } | ||||
| public function generatePHID() { | public function getPHIDType() { | ||||
| return PhabricatorPHID::generateNewPHID( | return PhabricatorDashboardDashboardPHIDType::TYPECONST; | ||||
| PhabricatorDashboardDashboardPHIDType::TYPECONST); | |||||
| } | } | ||||
| public function getRawLayoutMode() { | public function getRawLayoutMode() { | ||||
| $config = $this->getRawLayoutConfig(); | $config = $this->getRawLayoutConfig(); | ||||
| return idx($config, 'layoutMode'); | return idx($config, 'layoutMode'); | ||||
| } | } | ||||
| public function setRawLayoutMode($mode) { | public function setRawLayoutMode($mode) { | ||||
| $config = $this->getRawLayoutConfig(); | $config = $this->getRawLayoutConfig(); | ||||
| $config['layoutMode'] = $mode; | $config['layoutMode'] = $mode; | ||||
| return $this->setRawLayoutConfig($config); | |||||
| } | |||||
| // If a cached panel ref list exists, clear it. | public function getRawPanels() { | ||||
| $this->panelRefList = null; | $config = $this->getRawLayoutConfig(); | ||||
| return idx($config, 'panels'); | |||||
| } | |||||
| return $this->setLayoutConfig($config); | public function setRawPanels(array $panels) { | ||||
| $config = $this->getRawLayoutConfig(); | |||||
| $config['panels'] = $panels; | |||||
| return $this->setRawLayoutConfig($config); | |||||
| } | } | ||||
| private function getRawLayoutConfig() { | private function getRawLayoutConfig() { | ||||
| $config = $this->getLayoutConfig(); | $config = $this->getLayoutConfig(); | ||||
| if (!is_array($config)) { | if (!is_array($config)) { | ||||
| $config = array(); | $config = array(); | ||||
| } | } | ||||
| return $config; | return $config; | ||||
| } | } | ||||
| private function setRawLayoutConfig(array $config) { | |||||
| // If a cached panel ref list exists, clear it. | |||||
| $this->panelRefList = null; | |||||
| return $this->setLayoutConfig($config); | |||||
| } | |||||
| public function isArchived() { | public function isArchived() { | ||||
| return ($this->getStatus() == self::STATUS_ARCHIVED); | return ($this->getStatus() == self::STATUS_ARCHIVED); | ||||
| } | } | ||||
| public function getURI() { | public function getURI() { | ||||
| return urisprintf('/dashboard/view/%d/', $this->getID()); | return urisprintf('/dashboard/view/%d/', $this->getID()); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 94 Lines • Show Last 20 Lines | |||||