Exemplo n.º 1
0
 public function ajaxAction()
 {
     $application = $this->container['application'];
     $input = new StringInput($this->command);
     $input->setInteractive(false);
     $output = new BufferedOutput();
     $formatter = $output->getFormatter();
     $formatter->setDecorated(true);
     $output->setFormatter(new HtmlOutputFormatter($formatter));
     $application->setAutoExit(false);
     $endpoint = preg_replace('/(updater\\/|updater\\/index.php)$/', '', $this->request->getRequestUri());
     $fullEndpoint = sprintf('%s://%s%sindex.php/occ/', $this->request->getServerProtocol(), $this->request->getHost(), $endpoint !== '' ? $endpoint : '/');
     $application->setEndpoint($fullEndpoint);
     $application->setAuthToken($this->request->header('X_Updater_Auth'));
     // Some commands dump things out instead of returning a value
     ob_start();
     $errorCode = $application->run($input, $output);
     if (!($result = $output->fetch())) {
         $result = ob_get_contents();
         // If empty, replace it by the catched output
     }
     ob_end_clean();
     $result = nl2br($result);
     $result = preg_replace('|<br />\\r.*<br />(\\r.*?)<br />|', '$1<br />', $result);
     return ['input' => $this->command, 'output' => $result, 'environment' => '', 'error_code' => $errorCode];
 }
Exemplo n.º 2
0
 public function showLogin(Engine $templates)
 {
     // If it is a request with invalid token just return "false" so that we can catch this
     $token = $this->request->header('Authorization') !== null ? $this->request->header('Authorization') : '';
     if ($token !== '') {
         return 'false';
     }
     $content = $templates->render('partials/login', ['title' => 'Login Required']);
     return $content;
 }
Exemplo n.º 3
0
 /**
  * @dataProvider varsProvider
  */
 public function testPostParameter($vars, $key, $expected)
 {
     $request = new Request($vars);
     $actual = $request->postParameter($key);
     $this->assertEquals($expected, $actual);
 }
Exemplo n.º 4
0
 /**
  * @dataProvider hostProvider
  * @param $vars
  * @param $expected
  */
 public function testGetHost($vars, $expected)
 {
     $request = new Request($vars);
     $actual = $request->getHost();
     $this->assertEquals($expected, $actual);
 }