Changeset View
Standalone View
src/applications/countdown/storage/PhabricatorCountdown.php
<?php | <?php | ||||
final class PhabricatorCountdown extends PhabricatorCountdownDAO | final class PhabricatorCountdown extends PhabricatorCountdownDAO | ||||
implements | implements | ||||
PhabricatorPolicyInterface, | PhabricatorPolicyInterface, | ||||
PhabricatorFlaggableInterface, | PhabricatorFlaggableInterface, | ||||
PhabricatorSubscribableInterface, | PhabricatorSubscribableInterface, | ||||
PhabricatorApplicationTransactionInterface, | PhabricatorApplicationTransactionInterface, | ||||
PhabricatorTokenReceiverInterface, | PhabricatorTokenReceiverInterface, | ||||
PhabricatorSpacesInterface, | PhabricatorSpacesInterface, | ||||
PhabricatorProjectInterface, | PhabricatorProjectInterface, | ||||
PhabricatorDestructibleInterface { | PhabricatorDestructibleInterface, | ||||
PhabricatorConduitResultInterface { | |||||
protected $title; | protected $title; | ||||
protected $authorPHID; | protected $authorPHID; | ||||
protected $epoch; | protected $epoch; | ||||
protected $description; | protected $description; | ||||
protected $viewPolicy; | protected $viewPolicy; | ||||
protected $editPolicy; | protected $editPolicy; | ||||
protected $mailKey; | protected $mailKey; | ||||
▲ Show 20 Lines • Show All 125 Lines • ▼ Show 20 Lines | /* -( PhabricatorSpacesInterface )------------------------------------------- */ | ||||
public function getSpacePHID() { | public function getSpacePHID() { | ||||
return $this->spacePHID; | return $this->spacePHID; | ||||
} | } | ||||
/* -( PhabricatorDestructibleInterface )----------------------------------- */ | /* -( PhabricatorDestructibleInterface )----------------------------------- */ | ||||
public function destroyObjectPermanently( | public function destroyObjectPermanently( | ||||
PhabricatorDestructionEngine $engine) { | PhabricatorDestructionEngine $engine) { | ||||
$this->openTransaction(); | $this->openTransaction(); | ||||
$this->delete(); | $this->delete(); | ||||
$this->saveTransaction(); | $this->saveTransaction(); | ||||
} | } | ||||
/* -( PhabricatorConduitResultInterface )---------------------------------- */ | |||||
public function getFieldSpecificationsForConduit() { | |||||
return array( | |||||
id(new PhabricatorConduitSearchFieldSpecification()) | |||||
->setKey('title') | |||||
->setType('string') | |||||
->setDescription(pht('The title of the countdown.')), | |||||
id(new PhabricatorConduitSearchFieldSpecification()) | |||||
->setKey('description') | |||||
->setType('remarkup') | |||||
->setDescription(pht('The description of the countdown.')), | |||||
id(new PhabricatorConduitSearchFieldSpecification()) | |||||
epriestley: Add a specification for `epoch` here too (for now, this is only used to generate documentation). | |||||
Not Done Inline ActionsShould the type be int or integer? amckinley: Should the type be `int` or `integer`? | |||||
Not Done Inline ActionsI think I've been using 'epoch' -- it's purely documentation for humans for now so it's kind of made up. epriestley: I think I've been using `'epoch'` -- it's purely documentation for humans for now so it's kind… | |||||
->setKey('epoch') | |||||
->setType('epoch') | |||||
->setDescription(pht('The end date of the countdown.')), | |||||
); | |||||
} | |||||
Done Inline ActionsFor remarkup fields like this, I started doing something to try to future-proof them recently in D17603:
See also discussion in T12461. But the idea is that we might eventually want to be able to return text/html for these fields, or store other flavors of markdown, and we can do that without breaking the API if we emit a dictionary. So the output is currently: "description": "asdf" ...but for consistency with the new scheme in D17603, should be: "description": { "raw": "asdf" } epriestley: For remarkup fields like this, I started doing something to try to future-proof them recently… | |||||
public function getFieldValuesForConduit() { | |||||
Done Inline ActionsPut an (int) cast on this so it emits into JSON as a number instead of a string (PHP is all loosey-goosey about this stuff and we currently don't try to enforce types when they come out of the database). That is, the output currently shows: "epoch": "19831981098" ...but better is: "epoch": 19831981098 ...so that languages which care more will have an easier time interacting with the API. epriestley: Put an `(int)` cast on this so it emits into JSON as a number instead of a string (PHP is all… | |||||
return array( | |||||
'title' => $this->getTitle(), | |||||
'description' => array( | |||||
'raw' => $this->getDescription(), | |||||
), | |||||
'epoch' => (int)$this->getEpoch(), | |||||
); | |||||
} | |||||
public function getConduitSearchAttachments() { | |||||
return array(); | |||||
} | |||||
} | } |
Add a specification for epoch here too (for now, this is only used to generate documentation).