3 final class PhabricatorXHPASTViewRunController
4 extends PhabricatorXHPASTViewController
{
6 public function handleRequest(AphrontRequest
$request) {
7 $viewer = $this->getViewer();
9 if ($request->isFormPost()) {
10 $source = $request->getStr('source');
12 $future = PhutilXHPASTBinary
::getParserFuture($source);
13 $resolved = $future->resolve();
15 // This is just to let it throw exceptions if stuff is broken.
17 XHPASTTree
::newFromDataAndResolvedExecFuture($source, $resolved);
18 } catch (XHPASTSyntaxErrorException
$ex) {
19 // This is possibly expected.
22 list($err, $stdout, $stderr) = $resolved;
24 $storage_tree = id(new PhabricatorXHPASTParseTree())
29 ->setAuthorPHID($viewer->getPHID())
32 return id(new AphrontRedirectResponse())
33 ->setURI('/xhpast/view/'.$storage_tree->getID().'/');
36 $form = id(new AphrontFormView())
39 id(new AphrontFormTextAreaControl())
40 ->setLabel(pht('Source'))
42 ->setValue("<?php\n\n")
43 ->setHeight(AphrontFormTextAreaControl
::HEIGHT_VERY_TALL
))
45 id(new AphrontFormSubmitControl())
46 ->setValue(pht('Parse')));
48 $form_box = id(new PHUIObjectBoxView())
49 ->setHeaderText(pht('Generate XHP AST'))
50 ->setBackground(PHUIObjectBoxView
::BLUE_PROPERTY
)
53 $title = pht('XHPAST View');
54 $header = id(new PHUIHeaderView())
56 ->setHeaderIcon('fa-ambulance');
58 $view = id(new PHUITwoColumnView())
64 return $this->newPage()