Path: blob/master/src/applications/dashboard/storage/PhabricatorDashboardPortal.php
12242 views
<?php12final class PhabricatorDashboardPortal3extends PhabricatorDashboardDAO4implements5PhabricatorApplicationTransactionInterface,6PhabricatorPolicyInterface,7PhabricatorDestructibleInterface,8PhabricatorProjectInterface,9PhabricatorFulltextInterface,10PhabricatorFerretInterface {1112protected $name;13protected $viewPolicy;14protected $editPolicy;15protected $status;16protected $properties = array();1718public static function initializeNewPortal() {19return id(new self())20->setName('')21->setViewPolicy(PhabricatorPolicies::getMostOpenPolicy())22->setEditPolicy(PhabricatorPolicies::POLICY_USER)23->setStatus(PhabricatorDashboardPortalStatus::STATUS_ACTIVE);24}2526protected function getConfiguration() {27return array(28self::CONFIG_AUX_PHID => true,29self::CONFIG_SERIALIZATION => array(30'properties' => self::SERIALIZATION_JSON,31),32self::CONFIG_COLUMN_SCHEMA => array(33'name' => 'text255',34'status' => 'text32',35),36) + parent::getConfiguration();37}3839public function getPHIDType() {40return PhabricatorDashboardPortalPHIDType::TYPECONST;41}4243public function getPortalProperty($key, $default = null) {44return idx($this->properties, $key, $default);45}4647public function setPortalProperty($key, $value) {48$this->properties[$key] = $value;49return $this;50}5152public function getObjectName() {53return pht('Portal %d', $this->getID());54}5556public function getURI() {57return '/portal/view/'.$this->getID().'/';58}5960public function isArchived() {61$status_archived = PhabricatorDashboardPortalStatus::STATUS_ARCHIVED;62return ($this->getStatus() === $status_archived);63}646566/* -( PhabricatorApplicationTransactionInterface )------------------------- */676869public function getApplicationTransactionEditor() {70return new PhabricatorDashboardPortalEditor();71}7273public function getApplicationTransactionTemplate() {74return new PhabricatorDashboardPortalTransaction();75}767778/* -( PhabricatorPolicyInterface )----------------------------------------- */798081public function getCapabilities() {82return array(83PhabricatorPolicyCapability::CAN_VIEW,84PhabricatorPolicyCapability::CAN_EDIT,85);86}8788public function getPolicy($capability) {89switch ($capability) {90case PhabricatorPolicyCapability::CAN_VIEW:91return $this->getViewPolicy();92case PhabricatorPolicyCapability::CAN_EDIT:93return $this->getEditPolicy();94}95}9697public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {98return false;99}100101102/* -( PhabricatorDestructibleInterface )----------------------------------- */103104105public function destroyObjectPermanently(106PhabricatorDestructionEngine $engine) {107$this->delete();108}109110/* -( PhabricatorFulltextInterface )--------------------------------------- */111112public function newFulltextEngine() {113return new PhabricatorDashboardPortalFulltextEngine();114}115116/* -( PhabricatorFerretInterface )----------------------------------------- */117118public function newFerretEngine() {119return new PhabricatorDashboardPortalFerretEngine();120}121122}123124125