mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-28 01:32:42 +01:00
f5d2f8e07a
Summary: Ref T8116. This adds a control for creating publishers (default: administrators) and default publisher/package edit controls. I've left the edit defaults at "no one" for now to force you to select a policy. This might be something to look at later. Test Plan: Created publishers, packages. Tried to create publishers with "can create" policy set restrictively. Reviewers: chad Reviewed By: chad Maniphest Tasks: T8116 Differential Revision: https://secure.phabricator.com/D16319
96 lines
2.5 KiB
PHP
96 lines
2.5 KiB
PHP
<?php
|
|
|
|
final class PhabricatorPackagesPublisherEditEngine
|
|
extends PhabricatorPackagesEditEngine {
|
|
|
|
const ENGINECONST = 'packages.publisher';
|
|
|
|
public function getEngineName() {
|
|
return pht('Package Publishers');
|
|
}
|
|
|
|
public function getSummaryHeader() {
|
|
return pht('Edit Package Publisher Configurations');
|
|
}
|
|
|
|
public function getSummaryText() {
|
|
return pht('This engine is used to edit Packages publishers.');
|
|
}
|
|
|
|
protected function newEditableObject() {
|
|
$viewer = $this->getViewer();
|
|
return PhabricatorPackagesPublisher::initializeNewPublisher($viewer);
|
|
}
|
|
|
|
protected function newObjectQuery() {
|
|
return new PhabricatorPackagesPublisherQuery();
|
|
}
|
|
|
|
protected function getObjectCreateTitleText($object) {
|
|
return pht('Create Publisher');
|
|
}
|
|
|
|
protected function getObjectCreateButtonText($object) {
|
|
return pht('Create Publisher');
|
|
}
|
|
|
|
protected function getObjectEditTitleText($object) {
|
|
return pht('Edit Publisher: %s', $object->getName());
|
|
}
|
|
|
|
protected function getObjectEditShortText($object) {
|
|
return pht('Edit Publisher');
|
|
}
|
|
|
|
protected function getObjectCreateShortText() {
|
|
return pht('Create Publisher');
|
|
}
|
|
|
|
protected function getObjectName() {
|
|
return pht('Publisher');
|
|
}
|
|
|
|
protected function getEditorURI() {
|
|
return '/packages/publisher/edit/';
|
|
}
|
|
|
|
protected function getObjectCreateCancelURI($object) {
|
|
return '/packages/publisher/';
|
|
}
|
|
|
|
protected function getObjectViewURI($object) {
|
|
return $object->getURI();
|
|
}
|
|
|
|
protected function getCreateNewObjectPolicy() {
|
|
return $this->getApplication()->getPolicy(
|
|
PhabricatorPackagesCreatePublisherCapability::CAPABILITY);
|
|
}
|
|
|
|
protected function buildCustomEditFields($object) {
|
|
$fields = array();
|
|
|
|
$fields[] = id(new PhabricatorTextEditField())
|
|
->setKey('name')
|
|
->setLabel(pht('Name'))
|
|
->setDescription(pht('Name of the publisher.'))
|
|
->setTransactionType(
|
|
PhabricatorPackagesPublisherNameTransaction::TRANSACTIONTYPE)
|
|
->setIsRequired(true)
|
|
->setValue($object->getName());
|
|
|
|
if ($this->getIsCreate()) {
|
|
$fields[] = id(new PhabricatorTextEditField())
|
|
->setKey('publisherKey')
|
|
->setLabel(pht('Publisher Key'))
|
|
->setDescription(pht('Unique key to identify the publisher.'))
|
|
->setTransactionType(
|
|
PhabricatorPackagesPublisherKeyTransaction::TRANSACTIONTYPE)
|
|
->setIsRequired(true)
|
|
->setValue($object->getPublisherKey());
|
|
}
|
|
|
|
return $fields;
|
|
}
|
|
|
|
}
|