Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diviner/storage/DivinerLiveBook.php
| <?php | <?php | ||||
| final class DivinerLiveBook extends DivinerDAO | final class DivinerLiveBook extends DivinerDAO | ||||
| implements | implements | ||||
| PhabricatorPolicyInterface, | PhabricatorPolicyInterface, | ||||
| PhabricatorDestructibleInterface { | PhabricatorProjectInterface, | ||||
| PhabricatorDestructibleInterface, | |||||
| PhabricatorApplicationTransactionInterface { | |||||
| protected $name; | protected $name; | ||||
| protected $viewPolicy; | protected $viewPolicy; | ||||
| protected $editPolicy; | |||||
| protected $configurationData = array(); | protected $configurationData = array(); | ||||
| private $projectPHIDs = self::ATTACHABLE; | |||||
| 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( | ||||
| 'configurationData' => self::SERIALIZATION_JSON, | 'configurationData' => self::SERIALIZATION_JSON, | ||||
| ), | ), | ||||
| self::CONFIG_COLUMN_SCHEMA => array( | self::CONFIG_COLUMN_SCHEMA => array( | ||||
| 'name' => 'text64', | 'name' => 'text64', | ||||
| Show All 38 Lines | final class DivinerLiveBook extends DivinerDAO | ||||
| } | } | ||||
| public function getGroupName($group) { | public function getGroupName($group) { | ||||
| $groups = $this->getConfig('groups', array()); | $groups = $this->getConfig('groups', array()); | ||||
| $spec = idx($groups, $group, array()); | $spec = idx($groups, $group, array()); | ||||
| return idx($spec, 'name', $group); | return idx($spec, 'name', $group); | ||||
| } | } | ||||
| public function attachProjectPHIDs(array $project_phids) { | |||||
| $this->projectPHIDs = $project_phids; | |||||
| return $this; | |||||
| } | |||||
| public function getProjectPHIDs() { | |||||
| return $this->assertAttached($this->projectPHIDs); | |||||
| } | |||||
| /* -( PhabricatorPolicyInterface )----------------------------------------- */ | /* -( PhabricatorPolicyInterface )----------------------------------------- */ | ||||
| public function getCapabilities() { | public function getCapabilities() { | ||||
| return array( | return array( | ||||
| PhabricatorPolicyCapability::CAN_VIEW, | PhabricatorPolicyCapability::CAN_VIEW, | ||||
| PhabricatorPolicyCapability::CAN_EDIT, | |||||
| ); | ); | ||||
| } | } | ||||
| public function getPolicy($capability) { | public function getPolicy($capability) { | ||||
| return PhabricatorPolicies::getMostOpenPolicy(); | switch ($capability) { | ||||
| case PhabricatorPolicyCapability::CAN_VIEW: | |||||
| return $this->getViewPolicy(); | |||||
| case PhabricatorPolicyCapability::CAN_EDIT: | |||||
| 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; | ||||
| } | } | ||||
| /* -( PhabricatorDestructibleInterface )----------------------------------- */ | /* -( PhabricatorDestructibleInterface )----------------------------------- */ | ||||
| public function destroyObjectPermanently( | public function destroyObjectPermanently( | ||||
| PhabricatorDestructionEngine $engine) { | PhabricatorDestructionEngine $engine) { | ||||
| $this->openTransaction(); | $this->openTransaction(); | ||||
| $atoms = id(new DivinerAtomQuery()) | $atoms = id(new DivinerAtomQuery()) | ||||
| ->setViewer($engine->getViewer()) | ->setViewer($engine->getViewer()) | ||||
| ->withBookPHIDs(array($this->getPHID())) | ->withBookPHIDs(array($this->getPHID())) | ||||
| ->execute(); | ->execute(); | ||||
| foreach ($atoms as $atom) { | foreach ($atoms as $atom) { | ||||
| $engine->destroyObject($atom); | $engine->destroyObject($atom); | ||||
| } | } | ||||
| $this->delete(); | $this->delete(); | ||||
| $this->saveTransaction(); | $this->saveTransaction(); | ||||
| } | } | ||||
| /* -( PhabricatorApplicationTransactionInterface )------------------------- */ | |||||
| public function getApplicationTransactionEditor() { | |||||
| return new DivinerLiveBookEditor(); | |||||
| } | |||||
| public function getApplicationTransactionObject() { | |||||
| return $this; | |||||
| } | |||||
| public function getApplicationTransactionTemplate() { | |||||
| return new DivinerLiveBookTransaction(); | |||||
| } | |||||
| public function willRenderTimeline( | |||||
| PhabricatorApplicationTransactionView $timeline, | |||||
| AphrontRequest $request) { | |||||
| return $timeline; | |||||
| } | |||||
| } | } | ||||