Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diviner/publisher/DivinerLivePublisher.php
| <?php | <?php | ||||
| final class DivinerLivePublisher extends DivinerPublisher { | final class DivinerLivePublisher extends DivinerPublisher { | ||||
| private $book; | private $book; | ||||
| private function loadBook() { | private function loadBook() { | ||||
| if (!$this->book) { | if (!$this->book) { | ||||
| $book_name = $this->getConfig('name'); | $book_name = $this->getConfig('name'); | ||||
| $book = id(new DivinerLiveBook())->loadOneWhere('name = %s', $book_name); | $book = id(new DivinerLiveBook())->loadOneWhere( | ||||
| 'name = %s', | |||||
| $book_name); | |||||
| if (!$book) { | if (!$book) { | ||||
| $book = id(new DivinerLiveBook()) | $book = id(new DivinerLiveBook()) | ||||
| ->setName($book_name) | ->setName($book_name) | ||||
| ->setViewPolicy(PhabricatorPolicies::getMostOpenPolicy()) | ->setViewPolicy(PhabricatorPolicies::getMostOpenPolicy()) | ||||
| ->setEditPolicy(PhabricatorPolicies::POLICY_ADMIN) | |||||
| ->save(); | ->save(); | ||||
epriestley: Given that we define default policies, I'd expect this to be something like `DivinerLiveBook… | |||||
| } | } | ||||
| $book->setConfigurationData($this->getConfigurationData())->save(); | $book->setConfigurationData($this->getConfigurationData())->save(); | ||||
| $this->book = $book; | $this->book = $book; | ||||
| id(new PhabricatorSearchIndexer()) | id(new PhabricatorSearchIndexer()) | ||||
| ->queueDocumentForIndexing($book->getPHID()); | ->queueDocumentForIndexing($book->getPHID()); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 114 Lines • ▼ Show 20 Lines | foreach ($hashes as $hash) { | ||||
| // TODO: Yeah do that soon ^^^ | // TODO: Yeah do that soon ^^^ | ||||
| if ($atom->getType() !== DivinerAtom::TYPE_FILE) { | if ($atom->getType() !== DivinerAtom::TYPE_FILE) { | ||||
| $storage = $this->loadAtomStorageForSymbol($symbol) | $storage = $this->loadAtomStorageForSymbol($symbol) | ||||
| ->setAtomData($atom->toDictionary()) | ->setAtomData($atom->toDictionary()) | ||||
| ->setContent(null) | ->setContent(null) | ||||
| ->save(); | ->save(); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| public function findAtomByRef(DivinerAtomRef $ref) { | public function findAtomByRef(DivinerAtomRef $ref) { | ||||
| // TODO: Actually implement this. | // TODO: Actually implement this. | ||||
| return null; | return null; | ||||
| } | } | ||||
| } | } | ||||
Given that we define default policies, I'd expect this to be something like DivinerLiveBook::initializeNewBook() and set the defaults, now.