2011-04-07 04:17:05 +02:00
|
|
|
<?php
|
|
|
|
|
2012-03-10 00:46:25 +01:00
|
|
|
final class PhabricatorXHPASTViewRunController
|
2011-04-07 04:17:05 +02:00
|
|
|
extends PhabricatorXHPASTViewController {
|
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$user = $request->getUser();
|
|
|
|
|
|
|
|
if ($request->isFormPost()) {
|
|
|
|
$source = $request->getStr('source');
|
|
|
|
|
2015-02-02 20:59:15 +01:00
|
|
|
$future = PhutilXHPASTBinary::getParserFuture($source);
|
2011-04-07 04:17:05 +02:00
|
|
|
$resolved = $future->resolve();
|
|
|
|
|
|
|
|
// This is just to let it throw exceptions if stuff is broken.
|
|
|
|
$parse_tree = XHPASTTree::newFromDataAndResolvedExecFuture(
|
|
|
|
$source,
|
|
|
|
$resolved);
|
|
|
|
|
|
|
|
list($err, $stdout, $stderr) = $resolved;
|
|
|
|
|
|
|
|
$storage_tree = new PhabricatorXHPASTViewParseTree();
|
|
|
|
$storage_tree->setInput($source);
|
|
|
|
$storage_tree->setStdout($stdout);
|
|
|
|
$storage_tree->setAuthorPHID($user->getPHID());
|
|
|
|
$storage_tree->save();
|
|
|
|
|
|
|
|
return id(new AphrontRedirectResponse())
|
|
|
|
->setURI('/xhpast/view/'.$storage_tree->getID().'/');
|
|
|
|
}
|
|
|
|
|
|
|
|
$form = id(new AphrontFormView())
|
|
|
|
->setUser($user)
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormTextAreaControl())
|
|
|
|
->setLabel('Source')
|
|
|
|
->setName('source')
|
2013-03-01 19:59:44 +01:00
|
|
|
->setValue("<?php\n\n")
|
2011-04-07 04:17:05 +02:00
|
|
|
->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL))
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormSubmitControl())
|
|
|
|
->setValue('Parse'));
|
|
|
|
|
2013-09-25 20:23:29 +02:00
|
|
|
$form_box = id(new PHUIObjectBoxView())
|
2013-08-27 18:43:45 +02:00
|
|
|
->setHeaderText(pht('Generate XHP AST'))
|
|
|
|
->setForm($form);
|
2011-04-07 04:17:05 +02:00
|
|
|
|
2013-08-27 18:43:45 +02:00
|
|
|
return $this->buildApplicationPage(
|
|
|
|
$form_box,
|
2011-04-07 04:17:05 +02:00
|
|
|
array(
|
2013-08-27 18:43:45 +02:00
|
|
|
'title' => pht('XHPAST View'),
|
2011-04-07 04:17:05 +02:00
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|