Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phriction/storage/PhrictionDocument.php
| Show All 13 Lines | implements | ||||
| PhabricatorConduitResultInterface, | PhabricatorConduitResultInterface, | ||||
| PhabricatorPolicyCodexInterface, | PhabricatorPolicyCodexInterface, | ||||
| PhabricatorSpacesInterface { | PhabricatorSpacesInterface { | ||||
| protected $slug; | protected $slug; | ||||
| protected $depth; | protected $depth; | ||||
| protected $contentPHID; | protected $contentPHID; | ||||
| protected $status; | protected $status; | ||||
| protected $mailKey; | |||||
| protected $viewPolicy; | protected $viewPolicy; | ||||
| protected $editPolicy; | protected $editPolicy; | ||||
| protected $spacePHID; | protected $spacePHID; | ||||
| protected $editedEpoch; | protected $editedEpoch; | ||||
| private $contentObject = self::ATTACHABLE; | private $contentObject = self::ATTACHABLE; | ||||
| private $ancestors = array(); | private $ancestors = array(); | ||||
| protected function getConfiguration() { | protected function getConfiguration() { | ||||
| return array( | return array( | ||||
| self::CONFIG_AUX_PHID => true, | self::CONFIG_AUX_PHID => true, | ||||
| self::CONFIG_TIMESTAMPS => false, | self::CONFIG_TIMESTAMPS => false, | ||||
| self::CONFIG_COLUMN_SCHEMA => array( | self::CONFIG_COLUMN_SCHEMA => array( | ||||
| 'slug' => 'sort128', | 'slug' => 'sort128', | ||||
| 'depth' => 'uint32', | 'depth' => 'uint32', | ||||
| 'status' => 'text32', | 'status' => 'text32', | ||||
| 'mailKey' => 'bytes20', | |||||
| 'editedEpoch' => 'epoch', | 'editedEpoch' => 'epoch', | ||||
| ), | ), | ||||
| self::CONFIG_KEY_SCHEMA => array( | self::CONFIG_KEY_SCHEMA => array( | ||||
| 'slug' => array( | 'slug' => array( | ||||
| 'columns' => array('slug'), | 'columns' => array('slug'), | ||||
| 'unique' => true, | 'unique' => true, | ||||
| ), | ), | ||||
| 'depth' => array( | 'depth' => array( | ||||
| ▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | if ($parent_doc) { | ||||
| ->setSpacePHID($actor->getDefaultSpacePHID()); | ->setSpacePHID($actor->getDefaultSpacePHID()); | ||||
| } | } | ||||
| $document->setEditedEpoch(PhabricatorTime::getNow()); | $document->setEditedEpoch(PhabricatorTime::getNow()); | ||||
| return $document; | return $document; | ||||
| } | } | ||||
| public function save() { | |||||
| if (!$this->getMailKey()) { | |||||
| $this->setMailKey(Filesystem::readRandomCharacters(20)); | |||||
| } | |||||
| return parent::save(); | |||||
| } | |||||
| public static function getSlugURI($slug, $type = 'document') { | public static function getSlugURI($slug, $type = 'document') { | ||||
| static $types = array( | static $types = array( | ||||
| 'document' => '/w/', | 'document' => '/w/', | ||||
| 'history' => '/phriction/history/', | 'history' => '/phriction/history/', | ||||
| ); | ); | ||||
| if (empty($types[$type])) { | if (empty($types[$type])) { | ||||
| throw new Exception(pht("Unknown URI type '%s'!", $type)); | throw new Exception(pht("Unknown URI type '%s'!", $type)); | ||||
| ▲ Show 20 Lines • Show All 211 Lines • ▼ Show 20 Lines | return array( | ||||
| id(new PhrictionContentSearchEngineAttachment()) | id(new PhrictionContentSearchEngineAttachment()) | ||||
| ->setAttachmentKey('content'), | ->setAttachmentKey('content'), | ||||
| ); | ); | ||||
| } | } | ||||
| /* -( PhabricatorPolicyCodexInterface )------------------------------------ */ | /* -( PhabricatorPolicyCodexInterface )------------------------------------ */ | ||||
| public function newPolicyCodex() { | public function newPolicyCodex() { | ||||
| return new PhrictionDocumentPolicyCodex(); | return new PhrictionDocumentPolicyCodex(); | ||||
| } | } | ||||
| } | } | ||||