Differential D19269 Diff 46127 src/applications/harbormaster/storage/build/HarbormasterBuildTarget.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/harbormaster/storage/build/HarbormasterBuildTarget.php
<?php | <?php | ||||
final class HarbormasterBuildTarget extends HarbormasterDAO | final class HarbormasterBuildTarget | ||||
implements PhabricatorPolicyInterface { | extends HarbormasterDAO | ||||
implements | |||||
PhabricatorPolicyInterface, | |||||
PhabricatorDestructibleInterface { | |||||
protected $name; | protected $name; | ||||
protected $buildPHID; | protected $buildPHID; | ||||
protected $buildStepPHID; | protected $buildStepPHID; | ||||
protected $className; | protected $className; | ||||
protected $details; | protected $details; | ||||
protected $variables; | protected $variables; | ||||
protected $targetStatus; | protected $targetStatus; | ||||
▲ Show 20 Lines • Show All 336 Lines • ▼ Show 20 Lines | return $this->getBuild()->hasAutomaticCapability( | ||||
$capability, | $capability, | ||||
$viewer); | $viewer); | ||||
} | } | ||||
public function describeAutomaticCapability($capability) { | public function describeAutomaticCapability($capability) { | ||||
return pht('Users must be able to see a build to view its build targets.'); | return pht('Users must be able to see a build to view its build targets.'); | ||||
} | } | ||||
/* -( PhabricatorDestructibleInterface )----------------------------------- */ | |||||
public function destroyObjectPermanently( | |||||
PhabricatorDestructionEngine $engine) { | |||||
$viewer = $engine->getViewer(); | |||||
$this->openTransaction(); | |||||
$lint_message = new HarbormasterBuildLintMessage(); | |||||
$conn = $lint_message->establishConnection('w'); | |||||
queryfx( | |||||
$conn, | |||||
'DELETE FROM %T WHERE buildTargetPHID = %s', | |||||
$lint_message->getTableName(), | |||||
$this->getPHID()); | |||||
$unit_message = new HarbormasterBuildUnitMessage(); | |||||
$conn = $unit_message->establishConnection('w'); | |||||
queryfx( | |||||
$conn, | |||||
'DELETE FROM %T WHERE buildTargetPHID = %s', | |||||
$unit_message->getTableName(), | |||||
$this->getPHID()); | |||||
$logs = id(new HarbormasterBuildLogQuery()) | |||||
->setViewer($viewer) | |||||
->withBuildTargetPHIDs(array($this->getPHID())) | |||||
->execute(); | |||||
foreach ($logs as $log) { | |||||
$engine->destroyObject($log); | |||||
} | |||||
$artifacts = id(new HarbormasterBuildArtifactQuery()) | |||||
->setViewer($viewer) | |||||
->withBuildTargetPHIDs(array($this->getPHID())) | |||||
->execute(); | |||||
foreach ($artifacts as $artifact) { | |||||
$engine->destroyObject($artifact); | |||||
} | |||||
$messages = id(new HarbormasterBuildMessageQuery()) | |||||
->setViewer($viewer) | |||||
->withReceiverPHIDs(array($this->getPHID())) | |||||
->execute(); | |||||
foreach ($messages as $message) { | |||||
$engine->destroyObject($message); | |||||
} | |||||
$this->delete(); | |||||
$this->saveTransaction(); | |||||
} | |||||
} | } |