Page MenuHomestyx hydra

DrydockLeaseViewController.php
No OneTemporary

DrydockLeaseViewController.php

<?php
/*
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
final class DrydockLeaseViewController extends DrydockController {
private $id;
public function willProcessRequest(array $data) {
$this->id = $data['id'];
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$nav = $this->buildSideNav('lease');
$lease = id(new DrydockLease())->load($this->id);
if (!$lease) {
return new Aphront404Response();
}
$title = 'Lease '.$lease->getID();
$header = id(new PhabricatorHeaderView())
->setHeader($title);
$actions = $this->buildActionListView($lease);
$properties = $this->buildPropertyListView($lease);
$pager = new AphrontPagerView();
$pager->setURI(
new PhutilURI($this->getApplicationURI('lease/'.$lease->getID().'/')),
'offset');
$pager->setOffset($request->getInt('offset'));
$logs = id(new DrydockLogQuery())
->withLeaseIDs(array($lease->getID()))
->executeWithOffsetPager($pager);
$log_table = $this->buildLogTableView($logs);
$log_table->appendChild($pager);
$nav->appendChild(
array(
$header,
$actions,
$properties,
$log_table,
));
return $this->buildApplicationPage(
$nav,
array(
'device' => true,
'title' => $title,
));
}
private function buildActionListView(DrydockLease $lease) {
$view = id(new PhabricatorActionListView())
->setUser($this->getRequest()->getUser())
->setObject($lease);
return $view;
}
private function buildPropertyListView(DrydockLease $lease) {
$view = new PhabricatorPropertyListView();
switch ($lease->getStatus()) {
case DrydockLeaseStatus::STATUS_ACTIVE:
$status = pht('Active');
break;
case DrydockLeaseStatus::STATUS_RELEASED:
$status = pht('Released');
break;
case DrydockLeaseStatus::STATUS_EXPIRED:
$status = pht('Expired');
break;
case DrydockLeaseStatus::STATUS_PENDING:
$status = pht('Pending');
break;
case DrydockLeaseStatus::STATUS_BROKEN:
$status = pht('Broken');
break;
default:
$status = pht('Unknown');
break;
}
$view->addProperty(
pht('Status'),
$status);
$view->addProperty(
pht('Resource Type'),
phutil_escape_html($lease->getResourceType()));
$view->addProperty(
pht('Resource'),
phutil_escape_html($lease->getResourceID()));
return $view;
}
}

File Metadata

Mime Type
text/x-php
Expires
Tue, Dec 2, 9:37 PM (6 h, 54 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
432753
Default Alt Text
DrydockLeaseViewController.php (3 KB)

Event Timeline