Path: blob/master/src/applications/drydock/storage/DrydockLog.php
12256 views
<?php12final class DrydockLog extends DrydockDAO3implements PhabricatorPolicyInterface {45protected $blueprintPHID;6protected $resourcePHID;7protected $leasePHID;8protected $operationPHID;9protected $epoch;10protected $type;11protected $data = array();1213private $blueprint = self::ATTACHABLE;14private $resource = self::ATTACHABLE;15private $lease = self::ATTACHABLE;16private $operation = self::ATTACHABLE;1718protected function getConfiguration() {19return array(20self::CONFIG_TIMESTAMPS => false,21self::CONFIG_SERIALIZATION => array(22'data' => self::SERIALIZATION_JSON,23),24self::CONFIG_COLUMN_SCHEMA => array(25'blueprintPHID' => 'phid?',26'resourcePHID' => 'phid?',27'leasePHID' => 'phid?',28'operationPHID' => 'phid?',29'type' => 'text64',30),31self::CONFIG_KEY_SCHEMA => array(32'key_blueprint' => array(33'columns' => array('blueprintPHID', 'type'),34),35'key_resource' => array(36'columns' => array('resourcePHID', 'type'),37),38'key_lease' => array(39'columns' => array('leasePHID', 'type'),40),41'key_operation' => array(42'columns' => array('operationPHID', 'type'),43),44'epoch' => array(45'columns' => array('epoch'),46),47),48) + parent::getConfiguration();49}5051public function attachBlueprint(DrydockBlueprint $blueprint = null) {52$this->blueprint = $blueprint;53return $this;54}5556public function getBlueprint() {57return $this->assertAttached($this->blueprint);58}5960public function attachResource(DrydockResource $resource = null) {61$this->resource = $resource;62return $this;63}6465public function getResource() {66return $this->assertAttached($this->resource);67}6869public function attachLease(DrydockLease $lease = null) {70$this->lease = $lease;71return $this;72}7374public function getLease() {75return $this->assertAttached($this->lease);76}7778public function attachOperation(79DrydockRepositoryOperation $operation = null) {80$this->operation = $operation;81return $this;82}8384public function getOperation() {85return $this->assertAttached($this->operation);86}8788public function isComplete() {89if ($this->getBlueprintPHID() && !$this->getBlueprint()) {90return false;91}9293if ($this->getResourcePHID() && !$this->getResource()) {94return false;95}9697if ($this->getLeasePHID() && !$this->getLease()) {98return false;99}100101if ($this->getOperationPHID() && !$this->getOperation()) {102return false;103}104105return true;106}107108109/* -( PhabricatorPolicyInterface )----------------------------------------- */110111112public function getCapabilities() {113return array(114PhabricatorPolicyCapability::CAN_VIEW,115);116}117118public function getPolicy($capability) {119// NOTE: We let you see that logs exist no matter what, but don't actually120// show you log content unless you can see all of the associated objects.121return PhabricatorPolicies::getMostOpenPolicy();122}123124public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {125return false;126}127128public function describeAutomaticCapability($capability) {129return pht(130'To view log details, you must be able to view all associated '.131'blueprints, resources, leases, and repository operations.');132}133134}135136137