Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diviner/storage/DivinerLiveSymbol.php
| Show First 20 Lines • Show All 131 Lines • ▼ Show 20 Lines | public function getSortKey() { | ||||
| // case-insensitive way. | // case-insensitive way. | ||||
| return sprintf( | return sprintf( | ||||
| '%c:%s', | '%c:%s', | ||||
| ($this->getType() == DivinerAtom::TYPE_ARTICLE ? '0' : '1'), | ($this->getType() == DivinerAtom::TYPE_ARTICLE ? '0' : '1'), | ||||
| phutil_utf8_strtolower($this->getTitle())); | phutil_utf8_strtolower($this->getTitle())); | ||||
| } | } | ||||
| public function save() { | public function save() { | ||||
| // NOTE: The identity hash is just a sanity check because the unique tuple | // NOTE: The identity hash is just a sanity check because the unique tuple | ||||
| // on this table is way way too long to fit into a normal UNIQUE KEY. We | // on this table is way way too long to fit into a normal `UNIQUE KEY`. | ||||
| // don't use it directly, but its existence prevents duplicate records. | // We don't use it directly, but its existence prevents duplicate records. | ||||
| if (!$this->identityHash) { | if (!$this->identityHash) { | ||||
| $this->identityHash = PhabricatorHash::digestForIndex( | $this->identityHash = PhabricatorHash::digestForIndex( | ||||
| serialize( | serialize( | ||||
| array( | array( | ||||
| 'bookPHID' => $this->getBookPHID(), | 'bookPHID' => $this->getBookPHID(), | ||||
| 'context' => $this->getContext(), | 'context' => $this->getContext(), | ||||
| 'type' => $this->getType(), | 'type' => $this->getType(), | ||||
| 'name' => $this->getName(), | 'name' => $this->getName(), | ||||
| 'index' => $this->getAtomIndex(), | 'index' => $this->getAtomIndex(), | ||||
| ))); | ))); | ||||
| } | } | ||||
| return parent::save(); | return parent::save(); | ||||
| } | } | ||||
| public function getTitle() { | public function getTitle() { | ||||
| $title = parent::getTitle(); | $title = parent::getTitle(); | ||||
| if (!strlen($title)) { | if (!strlen($title)) { | ||||
| $title = $this->getName(); | $title = $this->getName(); | ||||
| } | } | ||||
| return $title; | return $title; | ||||
| } | } | ||||
| public function setTitle($value) { | public function setTitle($value) { | ||||
| $this->writeField('title', $value); | $this->writeField('title', $value); | ||||
| if (strlen($value)) { | if (strlen($value)) { | ||||
| $slug = DivinerAtomRef::normalizeTitleString($value); | $slug = DivinerAtomRef::normalizeTitleString($value); | ||||
| $hash = PhabricatorHash::digestForIndex($slug); | $hash = PhabricatorHash::digestForIndex($slug); | ||||
| $this->titleSlugHash = $hash; | $this->titleSlugHash = $hash; | ||||
| } else { | } else { | ||||
| $this->titleSlugHash = null; | $this->titleSlugHash = null; | ||||
| } | } | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function attachExtends(array $extends) { | public function attachExtends(array $extends) { | ||||
| assert_instances_of($extends, __CLASS__); | assert_instances_of($extends, __CLASS__); | ||||
| $this->extends = $extends; | $this->extends = $extends; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| Show All 10 Lines | final class DivinerLiveSymbol extends DivinerDAO | ||||
| public function getChildren() { | public function getChildren() { | ||||
| return $this->assertAttached($this->children); | return $this->assertAttached($this->children); | ||||
| } | } | ||||
| /* -( PhabricatorPolicyInterface )----------------------------------------- */ | /* -( PhabricatorPolicyInterface )----------------------------------------- */ | ||||
| public function getCapabilities() { | public function getCapabilities() { | ||||
| return $this->getBook()->getCapabilities(); | return $this->getBook()->getCapabilities(); | ||||
| } | } | ||||
| public function getPolicy($capability) { | public function getPolicy($capability) { | ||||
| return $this->getBook()->getPolicy($capability); | return $this->getBook()->getPolicy($capability); | ||||
| } | } | ||||
| public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { | public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { | ||||
| return $this->getBook()->hasAutomaticCapability($capability, $viewer); | return $this->getBook()->hasAutomaticCapability($capability, $viewer); | ||||
| } | } | ||||
| public function describeAutomaticCapability($capability) { | public function describeAutomaticCapability($capability) { | ||||
| return pht('Atoms inherit the policies of the books they are part of.'); | return pht('Atoms inherit the policies of the books they are part of.'); | ||||
| } | } | ||||
| /* -( Markup Interface )--------------------------------------------------- */ | /* -( PhabricatorMarkupInterface )------------------------------------------ */ | ||||
| public function getMarkupFieldKey($field) { | public function getMarkupFieldKey($field) { | ||||
| return $this->getPHID().':'.$field.':'.$this->getGraphHash(); | return $this->getPHID().':'.$field.':'.$this->getGraphHash(); | ||||
| } | } | ||||
| public function newMarkupEngine($field) { | public function newMarkupEngine($field) { | ||||
| return PhabricatorMarkupEngine::getEngine('diviner'); | return PhabricatorMarkupEngine::getEngine('diviner'); | ||||
| } | } | ||||
| public function getMarkupText($field) { | public function getMarkupText($field) { | ||||
| if (!$this->getAtom()) { | if (!$this->getAtom()) { | ||||
| return; | return; | ||||
| } | } | ||||
| return $this->getAtom()->getDocblockText(); | return $this->getAtom()->getDocblockText(); | ||||
| } | } | ||||
| public function didMarkupText($field, $output, PhutilMarkupEngine $engine) { | |||||
| public function didMarkupText( | |||||
| $field, | |||||
| $output, | |||||
| PhutilMarkupEngine $engine) { | |||||
| return $output; | return $output; | ||||
| } | } | ||||
| public function shouldUseMarkupCache($field) { | public function shouldUseMarkupCache($field) { | ||||
| return true; | return true; | ||||
| } | } | ||||
| /* -( PhabricatorDestructibleInterface )----------------------------------- */ | /* -( PhabricatorDestructibleInterface )----------------------------------- */ | ||||
| public function destroyObjectPermanently( | public function destroyObjectPermanently( | ||||
| PhabricatorDestructionEngine $engine) { | PhabricatorDestructionEngine $engine) { | ||||
| $this->openTransaction(); | $this->openTransaction(); | ||||
| $conn_w = $this->establishConnection('w'); | $conn_w = $this->establishConnection('w'); | ||||
| queryfx( | queryfx( | ||||
| $conn_w, | $conn_w, | ||||
| Show All 9 Lines | |||||