2013-05-20 19:18:26 +02:00
|
|
|
<?php
|
|
|
|
|
2013-05-31 19:52:25 +02:00
|
|
|
final class DivinerLiveSymbol extends DivinerDAO
|
|
|
|
implements PhabricatorPolicyInterface {
|
2013-05-20 19:18:26 +02:00
|
|
|
|
|
|
|
protected $phid;
|
|
|
|
protected $bookPHID;
|
|
|
|
protected $context;
|
|
|
|
protected $type;
|
|
|
|
protected $name;
|
|
|
|
protected $atomIndex;
|
|
|
|
protected $graphHash;
|
|
|
|
protected $identityHash;
|
|
|
|
|
2013-05-31 19:52:25 +02:00
|
|
|
private $book;
|
|
|
|
|
2013-05-20 19:18:26 +02:00
|
|
|
public function getConfiguration() {
|
|
|
|
return array(
|
|
|
|
self::CONFIG_AUX_PHID => true,
|
|
|
|
self::CONFIG_TIMESTAMPS => false,
|
|
|
|
) + parent::getConfiguration();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function generatePHID() {
|
|
|
|
return PhabricatorPHID::generateNewPHID(
|
|
|
|
PhabricatorPHIDConstants::PHID_TYPE_ATOM);
|
|
|
|
}
|
|
|
|
|
2013-05-31 19:52:25 +02:00
|
|
|
public function getBook() {
|
|
|
|
if ($this->book === null) {
|
|
|
|
throw new Exception("Call attachBook() before getBook()!");
|
|
|
|
}
|
|
|
|
return $this->book;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function attachBook(DivinerLiveBook $book) {
|
|
|
|
$this->book = $book;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2013-05-20 19:18:26 +02:00
|
|
|
public function save() {
|
|
|
|
|
|
|
|
// 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
|
|
|
|
// don't use it directly, but its existence prevents duplicate records.
|
|
|
|
|
|
|
|
if (!$this->identityHash) {
|
|
|
|
$this->identityHash = PhabricatorHash::digestForIndex(
|
|
|
|
serialize(
|
|
|
|
array(
|
|
|
|
'bookPHID' => $this->getBookPHID(),
|
|
|
|
'context' => $this->getContext(),
|
|
|
|
'type' => $this->getType(),
|
|
|
|
'name' => $this->getName(),
|
|
|
|
'index' => $this->getAtomIndex(),
|
|
|
|
)));
|
|
|
|
}
|
|
|
|
|
|
|
|
return parent::save();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-05-31 19:52:25 +02:00
|
|
|
/* -( PhabricatorPolicyInterface )----------------------------------------- */
|
|
|
|
|
|
|
|
public function getCapabilities() {
|
|
|
|
return $this->getBook()->getCapabilities();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function getPolicy($capability) {
|
|
|
|
return $this->getBook()->getPolicy($capability);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
|
|
|
|
return $this->getBook()->hasAutomaticCapability($capability, $viewer);
|
|
|
|
}
|
|
|
|
|
2013-05-20 19:18:26 +02:00
|
|
|
}
|