mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-28 17:52:43 +01:00
9b0fa5747b
Summary: Ref T2015. Moves a bunch of raw object loads into modern policy-aware queries. Also straightens out the Log and Lease policies a little bit: there are legitimate states where these objects are not attached to a resource (particularly, while a lease is being acquired). Handle these more gracefully. Test Plan: Lint / browsed stuff. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T2015 Differential Revision: https://secure.phabricator.com/D7836
66 lines
1.6 KiB
PHP
66 lines
1.6 KiB
PHP
<?php
|
|
|
|
final class DrydockLog extends DrydockDAO
|
|
implements PhabricatorPolicyInterface {
|
|
|
|
protected $resourceID;
|
|
protected $leaseID;
|
|
protected $epoch;
|
|
protected $message;
|
|
|
|
private $resource = self::ATTACHABLE;
|
|
private $lease = self::ATTACHABLE;
|
|
|
|
public function getConfiguration() {
|
|
return array(
|
|
self::CONFIG_TIMESTAMPS => false,
|
|
) + parent::getConfiguration();
|
|
}
|
|
|
|
public function attachResource(DrydockResource $resource = null) {
|
|
$this->resource = $resource;
|
|
return $this;
|
|
}
|
|
|
|
public function getResource() {
|
|
return $this->assertAttached($this->resource);
|
|
}
|
|
|
|
public function attachLease(DrydockLease $lease = null) {
|
|
$this->lease = $lease;
|
|
return $this;
|
|
}
|
|
|
|
public function getLease() {
|
|
return $this->assertAttached($this->lease);
|
|
}
|
|
|
|
|
|
/* -( PhabricatorPolicyInterface )----------------------------------------- */
|
|
|
|
|
|
public function getCapabilities() {
|
|
return array(
|
|
PhabricatorPolicyCapability::CAN_VIEW,
|
|
);
|
|
}
|
|
|
|
public function getPolicy($capability) {
|
|
if ($this->getResource()) {
|
|
return $this->getResource()->getPolicy($capability);
|
|
}
|
|
return $this->getLease()->getPolicy($capability);
|
|
}
|
|
|
|
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
|
|
if ($this->getResource()) {
|
|
return $this->getResource()->hasAutomaticCapability($capability, $viewer);
|
|
}
|
|
return $this->getLease()->hasAutomaticCapability($capability, $viewer);
|
|
}
|
|
|
|
public function describeAutomaticCapability($capability) {
|
|
return pht('Logs inherit the policy of their resources.');
|
|
}
|
|
|
|
}
|