mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-11 17:32:41 +01:00
98 lines
2.2 KiB
PHP
98 lines
2.2 KiB
PHP
|
<?php
|
||
|
|
||
|
/**
|
||
|
* @group pholio
|
||
|
*/
|
||
|
final class PholioMock extends PholioDAO
|
||
|
implements
|
||
|
PhabricatorMarkupInterface,
|
||
|
PhabricatorPolicyInterface,
|
||
|
PhabricatorSubscribableInterface {
|
||
|
|
||
|
const MARKUP_FIELD_DESCRIPTION = 'markup:description';
|
||
|
|
||
|
protected $authorPHID;
|
||
|
protected $viewPolicy;
|
||
|
|
||
|
protected $name;
|
||
|
protected $originalName;
|
||
|
protected $description;
|
||
|
protected $coverPHID;
|
||
|
protected $mailKey;
|
||
|
|
||
|
public function getConfiguration() {
|
||
|
return array(
|
||
|
self::CONFIG_AUX_PHID => true,
|
||
|
) + parent::getConfiguration();
|
||
|
}
|
||
|
|
||
|
public function generatePHID() {
|
||
|
return PhabricatorPHID::generateNewPHID('MOCK');
|
||
|
}
|
||
|
|
||
|
public function save() {
|
||
|
if (!$this->getMailKey()) {
|
||
|
$this->setMailKey(Filesystem::readRandomCharacters(20));
|
||
|
}
|
||
|
return parent::save();
|
||
|
}
|
||
|
|
||
|
|
||
|
/* -( PhabricatorSubscribableInterface Implementation )-------------------- */
|
||
|
|
||
|
|
||
|
public function isAutomaticallySubscribed($phid) {
|
||
|
return ($this->authorPHID == $phid);
|
||
|
}
|
||
|
|
||
|
|
||
|
/* -( PhabricatorPolicyInterface Implementation )-------------------------- */
|
||
|
|
||
|
|
||
|
public function getCapabilities() {
|
||
|
return array(
|
||
|
PhabricatorPolicyCapability::CAN_VIEW,
|
||
|
PhabricatorPolicyCapability::CAN_EDIT,
|
||
|
);
|
||
|
}
|
||
|
|
||
|
public function getPolicy($capability) {
|
||
|
switch ($capability) {
|
||
|
case PhabricatorPolicyCapability::CAN_VIEW:
|
||
|
return $this->getViewPolicy();
|
||
|
case PhabricatorPolicyCapability::CAN_EDIT:
|
||
|
return PhabricatorPolicies::POLICY_NOONE;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
|
||
|
return ($viewer->getPHID() == $this->getAuthorPHID());
|
||
|
}
|
||
|
|
||
|
|
||
|
/* -( PhabricatorMarkupInterface )----------------------------------------- */
|
||
|
|
||
|
|
||
|
public function getMarkupFieldKey($field) {
|
||
|
$hash = PhabricatorHash::digest($this->getMarkupText($field));
|
||
|
return 'M:'.$hash;
|
||
|
}
|
||
|
|
||
|
public function newMarkupEngine($field) {
|
||
|
return PhabricatorMarkupEngine::newMarkupEngine(array());
|
||
|
}
|
||
|
|
||
|
public function getMarkupText($field) {
|
||
|
return $this->getDescription();
|
||
|
}
|
||
|
|
||
|
public function didMarkupText($field, $output, PhutilMarkupEngine $engine) {
|
||
|
return $output;
|
||
|
}
|
||
|
|
||
|
public function shouldUseMarkupCache($field) {
|
||
|
return (bool)$this->getID();
|
||
|
}
|
||
|
|
||
|
}
|