Changeset View
Changeset View
Standalone View
Standalone View
src/applications/nuance/storage/NuanceQueue.php
<?php | <?php | ||||
final class NuanceQueue | final class NuanceQueue | ||||
extends NuanceDAO | extends NuanceDAO | ||||
implements PhabricatorPolicyInterface { | implements | ||||
PhabricatorPolicyInterface, | |||||
PhabricatorApplicationTransactionInterface { | |||||
protected $name; | protected $name; | ||||
protected $mailKey; | protected $mailKey; | ||||
protected $viewPolicy; | protected $viewPolicy; | ||||
protected $editPolicy; | protected $editPolicy; | ||||
protected function getConfiguration() { | protected function getConfiguration() { | ||||
return array( | return array( | ||||
self::CONFIG_AUX_PHID => true, | self::CONFIG_AUX_PHID => true, | ||||
self::CONFIG_COLUMN_SCHEMA => array( | self::CONFIG_COLUMN_SCHEMA => array( | ||||
'name' => 'text255?', | 'name' => 'text255?', | ||||
'mailKey' => 'bytes20', | 'mailKey' => 'bytes20', | ||||
), | ), | ||||
) + parent::getConfiguration(); | ) + parent::getConfiguration(); | ||||
} | } | ||||
public function generatePHID() { | public function generatePHID() { | ||||
return PhabricatorPHID::generateNewPHID( | return PhabricatorPHID::generateNewPHID( | ||||
NuanceQueuePHIDType::TYPECONST); | NuanceQueuePHIDType::TYPECONST); | ||||
} | } | ||||
public static function initializeNewQueue() { | |||||
return new NuanceQueue(); | |||||
} | |||||
public function save() { | public function save() { | ||||
if (!$this->getMailKey()) { | if (!$this->getMailKey()) { | ||||
$this->setMailKey(Filesystem::readRandomCharacters(20)); | $this->setMailKey(Filesystem::readRandomCharacters(20)); | ||||
} | } | ||||
return parent::save(); | return parent::save(); | ||||
} | } | ||||
public function getURI() { | public function getURI() { | ||||
return '/nuance/queue/view/'.$this->getID().'/'; | return '/nuance/queue/view/'.$this->getID().'/'; | ||||
} | } | ||||
/* -( PhabricatorPolicyInterface )----------------------------------------- */ | |||||
public function getCapabilities() { | public function getCapabilities() { | ||||
return array( | return array( | ||||
PhabricatorPolicyCapability::CAN_VIEW, | PhabricatorPolicyCapability::CAN_VIEW, | ||||
PhabricatorPolicyCapability::CAN_EDIT, | PhabricatorPolicyCapability::CAN_EDIT, | ||||
); | ); | ||||
} | } | ||||
public function getPolicy($capability) { | public function getPolicy($capability) { | ||||
switch ($capability) { | switch ($capability) { | ||||
case PhabricatorPolicyCapability::CAN_VIEW: | case PhabricatorPolicyCapability::CAN_VIEW: | ||||
return $this->getViewPolicy(); | return $this->getViewPolicy(); | ||||
case PhabricatorPolicyCapability::CAN_EDIT: | case PhabricatorPolicyCapability::CAN_EDIT: | ||||
return $this->getEditPolicy(); | return $this->getEditPolicy(); | ||||
} | } | ||||
} | } | ||||
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { | public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { | ||||
return false; | return false; | ||||
} | } | ||||
public function describeAutomaticCapability($capability) { | public function describeAutomaticCapability($capability) { | ||||
return null; | return null; | ||||
} | } | ||||
/* -( PhabricatorApplicationTransactionInterface )------------------------- */ | |||||
public function getApplicationTransactionEditor() { | |||||
return new NuanceQueueEditor(); | |||||
} | |||||
public function getApplicationTransactionObject() { | |||||
return $this; | |||||
} | |||||
public function getApplicationTransactionTemplate() { | |||||
return new NuanceQueueTransaction(); | |||||
} | |||||
public function willRenderTimeline( | |||||
PhabricatorApplicationTransactionView $timeline, | |||||
AphrontRequest $request) { | |||||
return $timeline; | |||||
} | |||||
} | } |