[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/phpast/controller/ -> PhabricatorXHPASTViewRunController.php (source)

   1  <?php
   2  
   3  final class PhabricatorXHPASTViewRunController
   4    extends PhabricatorXHPASTViewController {
   5  
   6    public function processRequest() {
   7  
   8      $request = $this->getRequest();
   9      $user = $request->getUser();
  10  
  11      if ($request->isFormPost()) {
  12        $source = $request->getStr('source');
  13  
  14        $future = xhpast_get_parser_future($source);
  15        $resolved = $future->resolve();
  16  
  17        // This is just to let it throw exceptions if stuff is broken.
  18        $parse_tree = XHPASTTree::newFromDataAndResolvedExecFuture(
  19          $source,
  20          $resolved);
  21  
  22        list($err, $stdout, $stderr) = $resolved;
  23  
  24        $storage_tree = new PhabricatorXHPASTViewParseTree();
  25        $storage_tree->setInput($source);
  26        $storage_tree->setStdout($stdout);
  27        $storage_tree->setAuthorPHID($user->getPHID());
  28        $storage_tree->save();
  29  
  30        return id(new AphrontRedirectResponse())
  31          ->setURI('/xhpast/view/'.$storage_tree->getID().'/');
  32      }
  33  
  34      $form = id(new AphrontFormView())
  35        ->setUser($user)
  36        ->appendChild(
  37          id(new AphrontFormTextAreaControl())
  38            ->setLabel('Source')
  39            ->setName('source')
  40            ->setValue("<?php\n\n")
  41            ->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL))
  42        ->appendChild(
  43          id(new AphrontFormSubmitControl())
  44            ->setValue('Parse'));
  45  
  46      $form_box = id(new PHUIObjectBoxView())
  47        ->setHeaderText(pht('Generate XHP AST'))
  48        ->setForm($form);
  49  
  50      return $this->buildApplicationPage(
  51        $form_box,
  52        array(
  53          'title' => pht('XHPAST View'),
  54        ));
  55    }
  56  
  57  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1