Page MenuHomePhabricator
Paste P1043

board_edit_sketch.php
ActivePublic

Authored by epriestley on Jan 9 2014, 5:10 PM.
Tags
None
Referenced Files
F100297: board_edit_sketch.php
Jan 9 2014, 5:10 PM
Subscribers
None
<?php
final class ProjectBoardEditController extends ProjectController {
private $id;
public function willProcessRequest(array $data) {
$this->projectID = = $data['projectID'];
$this->id = idx($data['id']);
}
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
// First, load the project and make sure the user can edit it.
// Use `PhabricatorProjectQuery` with `requireCapabilities()`.
$project = id(new PhabricatorProjectQuery())->...->executeOne();
if (!$project) {
// 404
}
// Now, either load an existing column (for an edit) or create a new one.
if ($this->id) {
$column = // load
// You can ignore this for now, we only care about create.
} else {
$column = PhabricatorProjectBoardColumn::initializeNewColumn($viewer);
}
if ($request->isFormPost()) {
// set values from the request on the $column, then call save()
// then redirect back to the board
}
// If we reach this, there were form errors or the request isn't a form
// submit. Render the create/edit form.
$form = new AphrontFormView();
// add fields
return $this->buildApplicationPage(
// ...
);
}
}

Event Timeline

epriestley changed the title of this paste from untitled to board_edit_sketch.php.
epriestley updated the paste's language from autodetect to autodetect.