Changeset View
Changeset View
Standalone View
Standalone View
src/applications/passphrase/storage/PassphraseCredential.php
<?php | <?php | ||||
final class PassphraseCredential extends PassphraseDAO | final class PassphraseCredential extends PassphraseDAO | ||||
implements | implements | ||||
PhabricatorApplicationTransactionInterface, | PhabricatorApplicationTransactionInterface, | ||||
PhabricatorPolicyInterface, | PhabricatorPolicyInterface, | ||||
PhabricatorDestructibleInterface { | PhabricatorDestructibleInterface, | ||||
PhabricatorSpacesInterface { | |||||
protected $name; | protected $name; | ||||
protected $credentialType; | protected $credentialType; | ||||
protected $providesType; | protected $providesType; | ||||
protected $viewPolicy; | protected $viewPolicy; | ||||
protected $editPolicy; | protected $editPolicy; | ||||
protected $description; | protected $description; | ||||
protected $username; | protected $username; | ||||
protected $secretID; | protected $secretID; | ||||
protected $isDestroyed; | protected $isDestroyed; | ||||
protected $isLocked = 0; | protected $isLocked = 0; | ||||
protected $allowConduit = 0; | protected $allowConduit = 0; | ||||
protected $authorPHID; | protected $authorPHID; | ||||
protected $spacePHID; | |||||
private $secret = self::ATTACHABLE; | private $secret = self::ATTACHABLE; | ||||
public static function initializeNewCredential(PhabricatorUser $actor) { | public static function initializeNewCredential(PhabricatorUser $actor) { | ||||
$app = id(new PhabricatorApplicationQuery()) | $app = id(new PhabricatorApplicationQuery()) | ||||
->setViewer($actor) | ->setViewer($actor) | ||||
->withClasses(array('PhabricatorPassphraseApplication')) | ->withClasses(array('PhabricatorPassphraseApplication')) | ||||
->executeOne(); | ->executeOne(); | ||||
$view_policy = $app->getPolicy(PassphraseDefaultViewCapability::CAPABILITY); | $view_policy = $app->getPolicy(PassphraseDefaultViewCapability::CAPABILITY); | ||||
$edit_policy = $app->getPolicy(PassphraseDefaultEditCapability::CAPABILITY); | $edit_policy = $app->getPolicy(PassphraseDefaultEditCapability::CAPABILITY); | ||||
return id(new PassphraseCredential()) | return id(new PassphraseCredential()) | ||||
->setName('') | ->setName('') | ||||
->setUsername('') | ->setUsername('') | ||||
->setDescription('') | ->setDescription('') | ||||
->setIsDestroyed(0) | ->setIsDestroyed(0) | ||||
->setAuthorPHID($actor->getPHID()) | ->setAuthorPHID($actor->getPHID()) | ||||
->setViewPolicy($view_policy) | ->setViewPolicy($view_policy) | ||||
->setEditPolicy($edit_policy); | ->setEditPolicy($edit_policy) | ||||
->setSpacePHID($actor->getDefaultSpacePHID()); | |||||
} | } | ||||
public function getMonogram() { | public function getMonogram() { | ||||
return 'K'.$this->getID(); | return 'K'.$this->getID(); | ||||
} | } | ||||
protected function getConfiguration() { | protected function getConfiguration() { | ||||
return array( | return array( | ||||
▲ Show 20 Lines • Show All 104 Lines • ▼ Show 20 Lines | $this->openTransaction(); | ||||
'id = %d', | 'id = %d', | ||||
$this->getSecretID()); | $this->getSecretID()); | ||||
foreach ($secrets as $secret) { | foreach ($secrets as $secret) { | ||||
$secret->delete(); | $secret->delete(); | ||||
} | } | ||||
$this->delete(); | $this->delete(); | ||||
$this->saveTransaction(); | $this->saveTransaction(); | ||||
} | } | ||||
/* -( PhabricatorSpacesInterface )----------------------------------------- */ | |||||
public function getSpacePHID() { | |||||
return $this->spacePHID; | |||||
} | |||||
} | } |