本文整理汇总了PHP中PhabricatorCustomField::getObjectFields方法的典型用法代码示例。如果您正苦于以下问题:PHP PhabricatorCustomField::getObjectFields方法的具体用法?PHP PhabricatorCustomField::getObjectFields怎么用?PHP PhabricatorCustomField::getObjectFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhabricatorCustomField
的用法示例。
在下文中一共展示了PhabricatorCustomField::getObjectFields方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCustomFieldList
public function getCustomFieldList()
{
$field_list = PhabricatorCustomField::getObjectFields($this->project, PhabricatorCustomField::ROLE_EDIT);
$field_list->setViewer($this->viewer);
$field_list->readFieldsFromStorage($this->project);
return $field_list;
}
示例2: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $this->getViewer();
$id = $request->getURIData('id');
$step = id(new HarbormasterBuildStepQuery())->setViewer($viewer)->withIDs(array($id))->executeOne();
if (!$step) {
return new Aphront404Response();
}
$plan = $step->getBuildPlan();
$plan_id = $plan->getID();
$plan_uri = $this->getApplicationURI("plan/{$plan_id}/");
$field_list = PhabricatorCustomField::getObjectFields($step, PhabricatorCustomField::ROLE_VIEW);
$field_list->setViewer($viewer)->readFieldsFromStorage($step);
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('Plan %d', $plan_id), $plan_uri);
$crumbs->addTextCrumb(pht('Step %d', $id));
$box = id(new PHUIObjectBoxView())->setHeaderText(pht('Build Step %d: %s', $id, $step->getName()));
$properties = $this->buildPropertyList($step, $field_list);
$actions = $this->buildActionList($step);
$properties->setActionList($actions);
$box->addPropertyList($properties);
$timeline = $this->buildTransactionTimeline($step, new HarbormasterBuildStepTransactionQuery());
$timeline->setShouldTerminate(true);
return $this->buildApplicationPage(array($crumbs, $box, $timeline), array('title' => pht('Step %d', $id)));
}
示例3: processRequest
public function processRequest()
{
$request = $this->getRequest();
$viewer = $request->getUser();
$user = id(new PhabricatorPeopleQuery())->setViewer($viewer)->withIDs(array($this->id))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
if (!$user) {
return new Aphront404Response();
}
$profile_uri = '/p/' . $user->getUsername() . '/';
$field_list = PhabricatorCustomField::getObjectFields($user, PhabricatorCustomField::ROLE_EDIT);
$field_list->setViewer($viewer)->readFieldsFromStorage($user);
$validation_exception = null;
if ($request->isFormPost()) {
$xactions = $field_list->buildFieldTransactionsFromRequest(new PhabricatorUserTransaction(), $request);
$editor = id(new PhabricatorUserProfileEditor())->setActor($viewer)->setContentSource(PhabricatorContentSource::newFromRequest($request))->setContinueOnNoEffect(true);
try {
$editor->applyTransactions($user, $xactions);
return id(new AphrontRedirectResponse())->setURI($profile_uri);
} catch (PhabricatorApplicationTransactionValidationException $ex) {
$validation_exception = $ex;
}
}
$title = pht('Edit Profile');
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb($user->getUsername(), $profile_uri);
$crumbs->addTextCrumb($title);
$form = id(new AphrontFormView())->setUser($viewer);
$field_list->appendFieldsToForm($form);
$form->appendChild(id(new AphrontFormSubmitControl())->addCancelButton($profile_uri)->setValue(pht('Save Profile')));
$form_box = id(new PHUIObjectBoxView())->setHeaderText(pht('Edit Profile'))->setValidationException($validation_exception)->setForm($form);
return $this->buildApplicationPage(array($crumbs, $form_box), array('title' => $title));
}
示例4: renderResultsList
public function renderResultsList(array $requests, PhabricatorSavedQuery $query)
{
assert_instances_of($requests, 'ReleephRequest');
$viewer = $this->getRequest()->getUser();
// TODO: This is generally a bit sketchy, but we don't do this kind of
// thing elsewhere at the moment. For the moment it shouldn't be hugely
// costly, and we can batch things later. Generally, this commits fewer
// sins than the old code did.
$engine = id(new PhabricatorMarkupEngine())->setViewer($viewer);
$list = array();
foreach ($requests as $pull) {
$field_list = PhabricatorCustomField::getObjectFields($pull, PhabricatorCustomField::ROLE_VIEW);
$field_list->setViewer($viewer)->readFieldsFromStorage($pull);
foreach ($field_list->getFields() as $field) {
if ($field->shouldMarkup()) {
$field->setMarkupEngine($engine);
}
}
$list[] = id(new ReleephRequestView())->setUser($viewer)->setCustomFields($field_list)->setPullRequest($pull)->setIsListView(true);
}
// This is quite sketchy, but the list has not actually rendered yet, so
// this still allows us to batch the markup rendering.
$engine->process();
return $list;
}
示例5: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $this->getViewer();
$id = $request->getURIData('id');
$step = id(new HarbormasterBuildStepQuery())->setViewer($viewer)->withIDs(array($id))->executeOne();
if (!$step) {
return new Aphront404Response();
}
$plan = $step->getBuildPlan();
$plan_id = $plan->getID();
$plan_uri = $this->getApplicationURI("plan/{$plan_id}/");
$field_list = PhabricatorCustomField::getObjectFields($step, PhabricatorCustomField::ROLE_VIEW);
$field_list->setViewer($viewer)->readFieldsFromStorage($step);
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('Plan %d', $plan_id), $plan_uri);
$crumbs->addTextCrumb(pht('Step %d', $id));
$crumbs->setBorder(true);
$header = id(new PHUIHeaderView())->setHeader(pht('Build Step %d: %s', $id, $step->getName()))->setHeaderIcon('fa-chevron-circle-right');
$properties = $this->buildPropertyList($step, $field_list);
$curtain = $this->buildCurtainView($step);
$timeline = $this->buildTransactionTimeline($step, new HarbormasterBuildStepTransactionQuery());
$timeline->setShouldTerminate(true);
$view = id(new PHUITwoColumnView())->setHeader($header)->setCurtain($curtain)->setMainColumn(array($properties, $timeline));
return $this->newPage()->setTitle(pht('Step %d', $id))->setCrumbs($crumbs)->appendChild($view);
}
示例6: processRequest
public function processRequest()
{
$request = $this->getRequest();
$viewer = $request->getUser();
$blueprint = id(new DrydockBlueprintQuery())->setViewer($viewer)->withIDs(array($this->id))->executeOne();
if (!$blueprint) {
return new Aphront404Response();
}
$title = $blueprint->getBlueprintName();
$header = id(new PHUIHeaderView())->setHeader($title)->setUser($viewer)->setPolicyObject($blueprint);
$actions = $this->buildActionListView($blueprint);
$properties = $this->buildPropertyListView($blueprint, $actions);
$blueprint_uri = 'blueprint/' . $blueprint->getID() . '/';
$blueprint_uri = $this->getApplicationURI($blueprint_uri);
$resources = id(new DrydockResourceQuery())->withBlueprintPHIDs(array($blueprint->getPHID()))->setViewer($viewer)->execute();
$resource_list = id(new DrydockResourceListView())->setUser($viewer)->setResources($resources)->render();
$resource_list->setNoDataString(pht('This blueprint has no resources.'));
$pager = new AphrontPagerView();
$pager->setURI(new PhutilURI($blueprint_uri), 'offset');
$pager->setOffset($request->getInt('offset'));
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('Blueprint %d', $blueprint->getID()));
$object_box = id(new PHUIObjectBoxView())->setHeader($header)->addPropertyList($properties);
$field_list = PhabricatorCustomField::getObjectFields($blueprint, PhabricatorCustomField::ROLE_VIEW);
$field_list->setViewer($viewer)->readFieldsFromStorage($blueprint);
$field_list->appendFieldsToPropertyList($blueprint, $viewer, $properties);
$timeline = $this->buildTransactionTimeline($blueprint, new DrydockBlueprintTransactionQuery());
$timeline->setShouldTerminate(true);
return $this->buildApplicationPage(array($crumbs, $object_box, $resource_list, $timeline), array('title' => $title));
}
示例7: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
$id = $request->getURIData('id');
$blueprint = id(new DrydockBlueprintQuery())->setViewer($viewer)->withIDs(array($id))->executeOne();
if (!$blueprint) {
return new Aphront404Response();
}
$title = $blueprint->getBlueprintName();
$header = id(new PHUIHeaderView())->setHeader($title)->setUser($viewer)->setPolicyObject($blueprint);
if ($blueprint->getIsDisabled()) {
$header->setStatus('fa-ban', 'red', pht('Disabled'));
} else {
$header->setStatus('fa-check', 'bluegrey', pht('Active'));
}
$actions = $this->buildActionListView($blueprint);
$properties = $this->buildPropertyListView($blueprint, $actions);
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('Blueprint %d', $blueprint->getID()));
$object_box = id(new PHUIObjectBoxView())->setHeader($header)->addPropertyList($properties);
$field_list = PhabricatorCustomField::getObjectFields($blueprint, PhabricatorCustomField::ROLE_VIEW);
$field_list->setViewer($viewer)->readFieldsFromStorage($blueprint);
$field_list->appendFieldsToPropertyList($blueprint, $viewer, $properties);
$resource_box = $this->buildResourceBox($blueprint);
$authorizations_box = $this->buildAuthorizationsBox($blueprint);
$timeline = $this->buildTransactionTimeline($blueprint, new DrydockBlueprintTransactionQuery());
$timeline->setShouldTerminate(true);
$log_query = id(new DrydockLogQuery())->withBlueprintPHIDs(array($blueprint->getPHID()));
$log_box = $this->buildLogBox($log_query, $this->getApplicationURI("blueprint/{$id}/logs/query/all/"));
return $this->buildApplicationPage(array($crumbs, $object_box, $resource_box, $authorizations_box, $log_box, $timeline), array('title' => $title));
}
示例8: buildSetFieldTransaction
function buildSetFieldTransaction($object, $field_key, $field_value, $template, $viewer)
{
$role = PhabricatorCustomField::ROLE_APPLICATIONTRANSACTIONS;
$fields = PhabricatorCustomField::getObjectFields($object, $role)->setViewer($viewer)->readFieldsFromStorage($object)->getFields();
$field = idx($fields, $field_key);
$transaction_type = $field->getApplicationTransactionType();
$xaction = id(clone $template)->setTransactionType($transaction_type);
if ($transaction_type == PhabricatorTransactions::TYPE_CUSTOMFIELD) {
// For TYPE_CUSTOMFIELD transactions only, we provide the old value
// as an input.
$old_value = $field->getOldValueForApplicationTransactions();
$xaction->setOldValue($old_value);
}
$field->getProxy()->setFieldValue($field_value);
$new_value = $field->getNewValueForApplicationTransactions();
$xaction->setNewValue($new_value);
if ($transaction_type == PhabricatorTransactions::TYPE_CUSTOMFIELD) {
// For TYPE_CUSTOMFIELD transactions, add the field key in metadata.
$xaction->setMetadataValue('customfield:key', $field->getFieldKey());
}
$metadata = $field->getApplicationTransactionMetadata();
foreach ($metadata as $key => $value) {
$xaction->setMetadataValue($key, $value);
}
return $xaction;
}
示例9: execute
protected function execute(ConduitAPIRequest $request)
{
$viewer = $request->getUser();
$corpus = $request->getValue('corpus');
$is_partial = $request->getValue('partial');
$revision = new DifferentialRevision();
$field_list = PhabricatorCustomField::getObjectFields($revision, DifferentialCustomField::ROLE_COMMITMESSAGE);
$field_list->setViewer($viewer);
$field_map = mpull($field_list->getFields(), null, 'getFieldKeyForConduit');
$this->errors = array();
$label_map = $this->buildLabelMap($field_list);
$corpus_map = $this->parseCommitMessage($corpus, $label_map);
$values = array();
foreach ($corpus_map as $field_key => $text_value) {
$field = idx($field_map, $field_key);
if (!$field) {
throw new Exception(pht('Parser emitted text value for field key "%s", but no such ' . 'field exists.', $field_key));
}
try {
$values[$field_key] = $field->parseValueFromCommitMessage($text_value);
} catch (DifferentialFieldParseException $ex) {
$this->errors[] = pht('Error parsing field "%s": %s', $field->renderCommitMessageLabel(), $ex->getMessage());
}
}
if (!$is_partial) {
foreach ($field_map as $key => $field) {
try {
$field->validateCommitMessageValue(idx($values, $key));
} catch (DifferentialFieldValidationException $ex) {
$this->errors[] = pht('Invalid or missing field "%s": %s', $field->renderCommitMessageLabel(), $ex->getMessage());
}
}
}
return array('errors' => $this->errors, 'fields' => $values);
}
示例10: processRequest
public function processRequest()
{
$request = $this->getRequest();
$viewer = $request->getUser();
// Load all projects with "Sprint" in the name.
$projects = id(new PhabricatorProjectQuery())->setViewer($viewer)->withDatasourceQuery('sprint')->execute();
$rows = array();
foreach ($projects as $project) {
// We need the custom fields so we can pull out the start and end date
// TODO: query in a loop is bad
$field_list = PhabricatorCustomField::getObjectFields($project, PhabricatorCustomField::ROLE_EDIT);
$field_list->setViewer($viewer);
$field_list->readFieldsFromStorage($project);
$aux_fields = $field_list->getFields();
$start = idx($aux_fields, 'isdc:sprint:startdate')->getProxy()->getFieldValue();
$end = idx($aux_fields, 'isdc:sprint:enddate')->getProxy()->getFieldValue();
$rows[] = array('project' => phutil_tag('a', array('href' => '/burndown/view/' . $project->getId(), 'style' => 'font-weight:bold'), $project->getName()), 'start' => phabricator_datetime($start, $viewer), 'end' => phabricator_datetime($end, $viewer));
}
$projects_table = id(new AphrontTableView($rows))->setHeaders(array('Project/Sprint name', 'Start Date', 'End Date'))->setColumnClasses(array('wide', 'date', 'date'));
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('Burndown List'));
$help = id(new PHUIBoxView())->appendChild(phutil_tag('p', array(), "To have a project show up in this list, make sure it's name includes" . "\"sprint\" and then edit it to set the start and end date."))->addMargin(PHUI::MARGIN_LARGE);
$box = id(new PHUIBoxView())->appendChild($projects_table)->addMargin(PHUI::MARGIN_LARGE);
return $this->buildApplicationPage(array($crumbs, $help, $box), array('title' => array(pht('Burndown List')), 'device' => true));
}
示例11: processRequest
public function processRequest()
{
$request = $this->getRequest();
$viewer = $request->getUser();
$request->validateCSRF();
$pull = id(new ReleephRequestQuery())->setViewer($viewer)->withIDs(array($this->requestID))->executeOne();
if (!$pull) {
return new Aphront404Response();
}
$branch = $pull->getBranch();
$product = $branch->getProduct();
$action = $this->action;
$origin_uri = '/' . $pull->getMonogram();
$editor = id(new ReleephRequestTransactionalEditor())->setActor($viewer)->setContinueOnNoEffect(true)->setContentSourceFromRequest($request);
$xactions = array();
switch ($action) {
case 'want':
case 'pass':
static $action_map = array('want' => ReleephRequest::INTENT_WANT, 'pass' => ReleephRequest::INTENT_PASS);
$intent = $action_map[$action];
$xactions[] = id(new ReleephRequestTransaction())->setTransactionType(ReleephRequestTransaction::TYPE_USER_INTENT)->setMetadataValue('isAuthoritative', $product->isAuthoritative($viewer))->setNewValue($intent);
break;
case 'mark-manually-picked':
case 'mark-manually-reverted':
if ($pull->getRequestUserPHID() === $viewer->getPHID() || $product->isAuthoritative($viewer)) {
// We're all good!
} else {
throw new Exception(pht("Bug! Only pushers or the requestor can manually change a " . "request's in-branch status!"));
}
if ($action === 'mark-manually-picked') {
$in_branch = 1;
$intent = ReleephRequest::INTENT_WANT;
} else {
$in_branch = 0;
$intent = ReleephRequest::INTENT_PASS;
}
$xactions[] = id(new ReleephRequestTransaction())->setTransactionType(ReleephRequestTransaction::TYPE_USER_INTENT)->setMetadataValue('isManual', true)->setMetadataValue('isAuthoritative', true)->setNewValue($intent);
$xactions[] = id(new ReleephRequestTransaction())->setTransactionType(ReleephRequestTransaction::TYPE_MANUAL_IN_BRANCH)->setNewValue($in_branch);
break;
default:
throw new Exception(pht('Unknown or unimplemented action %s.', $action));
}
$editor->applyTransactions($pull, $xactions);
if ($request->getBool('render')) {
$field_list = PhabricatorCustomField::getObjectFields($pull, PhabricatorCustomField::ROLE_VIEW);
$field_list->setViewer($viewer)->readFieldsFromStorage($pull);
// TODO: This should be more modern and general.
$engine = id(new PhabricatorMarkupEngine())->setViewer($viewer);
foreach ($field_list->getFields() as $field) {
if ($field->shouldMarkup()) {
$field->setMarkupEngine($engine);
}
}
$engine->process();
$pull_box = id(new ReleephRequestView())->setUser($viewer)->setCustomFields($field_list)->setPullRequest($pull)->setIsListView(true);
return id(new AphrontAjaxResponse())->setContent(array('markup' => hsprintf('%s', $pull_box)));
}
return id(new AphrontRedirectResponse())->setURI($origin_uri);
}
示例12: buildPropertyView
private function buildPropertyView(PhabricatorUser $user, PhabricatorActionListView $actions)
{
$viewer = $this->getRequest()->getUser();
$view = id(new PHUIPropertyListView())->setUser($viewer)->setObject($user)->setActionList($actions);
$field_list = PhabricatorCustomField::getObjectFields($user, PhabricatorCustomField::ROLE_VIEW);
$field_list->appendFieldsToPropertyList($user, $viewer, $view);
return $view;
}
示例13: buildAlmanacPropertiesTable
protected function buildAlmanacPropertiesTable(AlmanacPropertyInterface $object)
{
$viewer = $this->getViewer();
$properties = $object->getAlmanacProperties();
$this->requireResource('almanac-css');
$can_edit = PhabricatorPolicyFilter::hasCapability($viewer, $object, PhabricatorPolicyCapability::CAN_EDIT);
$field_list = PhabricatorCustomField::getObjectFields($object, PhabricatorCustomField::ROLE_DEFAULT);
// Before reading values from the object, read defaults.
$defaults = mpull($field_list->getFields(), 'getValueForStorage', 'getFieldKey');
$field_list->setViewer($viewer)->readFieldsFromStorage($object);
Javelin::initBehavior('phabricator-tooltips', array());
$icon_builtin = id(new PHUIIconView())->setIcon('fa-circle')->addSigil('has-tooltip')->setMetadata(array('tip' => pht('Builtin Property'), 'align' => 'E'));
$icon_custom = id(new PHUIIconView())->setIcon('fa-circle-o grey')->addSigil('has-tooltip')->setMetadata(array('tip' => pht('Custom Property'), 'align' => 'E'));
$builtins = $object->getAlmanacPropertyFieldSpecifications();
// Sort fields so builtin fields appear first, then fields are ordered
// alphabetically.
$fields = $field_list->getFields();
$fields = msort($fields, 'getFieldKey');
$head = array();
$tail = array();
foreach ($fields as $field) {
$key = $field->getFieldKey();
if (isset($builtins[$key])) {
$head[$key] = $field;
} else {
$tail[$key] = $field;
}
}
$fields = $head + $tail;
$rows = array();
foreach ($fields as $key => $field) {
$value = $field->getValueForStorage();
$is_builtin = isset($builtins[$key]);
$delete_uri = $this->getApplicationURI('property/delete/');
$delete_uri = id(new PhutilURI($delete_uri))->setQueryParams(array('objectPHID' => $object->getPHID(), 'key' => $key));
$edit_uri = $this->getApplicationURI('property/edit/');
$edit_uri = id(new PhutilURI($edit_uri))->setQueryParams(array('objectPHID' => $object->getPHID(), 'key' => $key));
$delete = javelin_tag('a', array('class' => $can_edit ? 'button grey small' : 'button grey small disabled', 'sigil' => 'workflow', 'href' => $delete_uri), $is_builtin ? pht('Reset') : pht('Delete'));
$default = idx($defaults, $key);
$is_default = $default !== null && $default === $value;
$display_value = PhabricatorConfigJSON::prettyPrintJSON($value);
if ($is_default) {
$display_value = phutil_tag('span', array('class' => 'almanac-default-property-value'), $display_value);
}
$display_key = $key;
if ($can_edit) {
$display_key = javelin_tag('a', array('href' => $edit_uri, 'sigil' => 'workflow'), $display_key);
}
$rows[] = array($is_builtin ? $icon_builtin : $icon_custom, $display_key, $display_value, $delete);
}
$table = id(new AphrontTableView($rows))->setNoDataString(pht('No properties.'))->setHeaders(array(null, pht('Name'), pht('Value'), null))->setColumnClasses(array(null, null, 'wide', 'action'));
$phid = $object->getPHID();
$add_uri = $this->getApplicationURI("property/edit/?objectPHID={$phid}");
$can_edit = PhabricatorPolicyFilter::hasCapability($viewer, $object, PhabricatorPolicyCapability::CAN_EDIT);
$add_button = id(new PHUIButtonView())->setTag('a')->setHref($add_uri)->setWorkflow(true)->setDisabled(!$can_edit)->setText(pht('Add Property'))->setIcon('fa-plus');
$header = id(new PHUIHeaderView())->setHeader(pht('Properties'))->addActionLink($add_button);
return id(new PHUIObjectBoxView())->setHeader($header)->setTable($table);
}
示例14: loadCustomFields
private function loadCustomFields()
{
if ($this->fields === null) {
$field_list = PhabricatorCustomField::getObjectFields($this, PhabricatorCustomField::ROLE_VIEW);
$field_list->readFieldsFromStorage($this);
$this->fields = $field_list->getFields();
}
return $this->fields;
}
示例15: buildPropertyListView
private function buildPropertyListView(PhabricatorProject $project)
{
$viewer = $this->getViewer();
$view = id(new PHUIPropertyListView())->setUser($viewer);
$view->addProperty(pht('Looks Like'), $viewer->renderHandle($project->getPHID())->setAsTag(true));
$field_list = PhabricatorCustomField::getObjectFields($project, PhabricatorCustomField::ROLE_VIEW);
$field_list->appendFieldsToPropertyList($project, $viewer, $view);
return $view;
}