Example #1
0
 /**
  * Reinitialize the global request.
  * 
  * @return void
  */
 protected function restartRequest()
 {
     // FIXME: Ugly hack, but old contents from previous requests seem to
     // trip up the Foundation class.
     $_FILES = array();
     Request::$foundation = RequestFoundation::createFromGlobals();
 }
Example #2
0
 /**
  * Get the value of a cookie.
  *
  * <code>
  *		// Get the value of the "favorite" cookie
  *		$favorite = Cookie::get('favorite');
  *
  *		// Get the value of a cookie or return a default value
  *		$favorite = Cookie::get('framework', 'Laravel');
  * </code>
  *
  * @param  string  $name
  * @param  mixed   $default
  * @return string
  */
 public static function get($name, $default = null)
 {
     if (isset(static::$jar[$name])) {
         return static::$jar[$name];
     }
     return array_get(Request::foundation()->cookies->all(), $name, $default);
 }
Example #3
0
 /**
  * Set this request's URI to the given string
  * 
  * @param string  $uri
  */
 protected function setRequestUri($uri)
 {
     // FIXME: Ugly hack, but old contents from previous requests seem to
     // trip up the Foundation class.
     $_FILES = array();
     $_SERVER['REQUEST_URI'] = $uri;
     Request::$foundation = RequestFoundation::createFromGlobals();
 }
Example #4
0
 /**
  * Test the URL::to_asset method.
  *
  * @group laravel
  */
 public function testToAssetGeneratesURLWithoutFrontControllerInURL()
 {
     $this->assertEquals('http://localhost/image.jpg', URL::to_asset('image.jpg'));
     $this->assertEquals('https://localhost/image.jpg', URL::to_asset('image.jpg', true));
     Config::set('application.index', '');
     $this->assertEquals('http://localhost/image.jpg', URL::to_asset('image.jpg'));
     $this->assertEquals('https://localhost/image.jpg', URL::to_asset('image.jpg', true));
     Request::foundation()->server->add(array('HTTPS' => 'on'));
     $this->assertEquals('https://localhost/image.jpg', URL::to_asset('image.jpg'));
 }
Example #5
0
 /**
  * Get the value of a cookie.
  *
  * <code>
  *		// Get the value of the "favorite" cookie
  *		$favorite = Cookie::get('favorite');
  *
  *		// Get the value of a cookie or return a default value
  *		$favorite = Cookie::get('framework', 'Laravel');
  * </code>
  *
  * @param  string  $name
  * @param  mixed   $default
  * @return string
  */
 public static function get($name, $default = null)
 {
     if (isset(static::$jar[$name])) {
         return static::parse(static::$jar[$name]['value']);
     }
     if (!is_null($value = Request::foundation()->cookies->get($name))) {
         return static::parse($value);
     }
     return value($default);
 }
 /**
  * Test the Redirect::with_input function.
  *
  * @group laravel
  */
 public function testWithInputMethodFlashesInputToTheSession()
 {
     $this->setSession();
     $input = array('name' => 'Taylor', 'age' => 25);
     Request::foundation()->request->add($input);
     $redirect = Redirect::to('')->with_input();
     $this->assertEquals($input, Session::$instance->session['data'][':new:']['laravel_old_input']);
     $redirect = Redirect::to('')->with_input('only', array('name'));
     $this->assertEquals(array('name' => 'Taylor'), Session::$instance->session['data'][':new:']['laravel_old_input']);
     $redirect = Redirect::to('')->with_input('except', array('name'));
     $this->assertEquals(array('age' => 25), Session::$instance->session['data'][':new:']['laravel_old_input']);
 }
Example #7
0
 static function execCustom($block, array $options = array())
 {
     $options += array('args' => array(), 'verb' => null, 'ajax' => null, 'input' => null, 'layout' => null, 'prepare' => null, 'response' => false, 'return' => null);
     $input =& $options['input'];
     if (isset($input)) {
         $input = arrize($input);
         isset($options['verb']) or $options['verb'] = 'get';
     }
     $obj = static::factory($block);
     if ($obj instanceof self) {
         $obj->input = $input;
         $obj->top = $options['layout'];
     }
     $options['prepare'] and call_user_func($options['prepare'], $obj);
     // Substituting Symfony's request method as Laravel is explicitly using
     // global Request::method() when executing a controller's method.
     if ($verb = $options['verb'] and $verb != Request::method()) {
         $oldVerb = Request::foundation()->getMethod();
         Request::foundation()->setMethod($verb);
     }
     if (isset($options['ajax'])) {
         $oldAJAX = Request::ajax();
         Request::ajax($options['ajax']);
     }
     try {
         $exec = $obj->execute(static::actionFrom($block), arrizeAny($options['args']));
     } catch (\Exception $e) {
         $exception = $e;
     }
     // Reverting old (current) request state.
     isset($oldAJAX) and Request::ajax($oldAJAX);
     isset($oldVerb) and Request::foundation()->setMethod($oldVerb);
     if (isset($exception)) {
         throw $exception;
     }
     if ($options['response']) {
         $response = with(new static())->toResponse($exec);
     }
     return array_get(compact('obj', 'exec', 'response'), $options['return']);
 }
Example #8
0
 /**
  * Replace the input for the current request.
  *
  * @param  array  $input
  * @return void
  */
 public static function replace(array $input)
 {
     Request::foundation()->request->replace($input);
 }
Example #9
0
 /**
  * Clear the input for the current request.
  * @return void
  */
 public static function clear()
 {
     Request::foundation()->request->replace(array());
 }
Example #10
0
 /**
  * Test the Input::flush method.
  *
  * @group laravel
  */
 public function testFlushMethodClearsFlashedInput()
 {
     $this->setSession();
     $input = array('name' => 'Taylor', 'age' => 30);
     Request::foundation()->request->add($input);
     Input::flash();
     $this->assertEquals($input, Session::$instance->session['data'][':new:']['laravel_old_input']);
     Input::flush();
     $this->assertEquals(array(), Session::$instance->session['data'][':new:']['laravel_old_input']);
 }
Example #11
0
<?php

namespace Thin;

container();
Utils::cleanCache();
$_SERVER['REQUEST_URI'] = isAke($_SERVER, 'REQUEST_URI', '/');
Request::$foundation = \Symfony\Component\HttpFoundation\ThinRequest::createFromGlobals();
Autoloader::registerNamespace('ThinService', APPLICATION_PATH . DS . 'services');
Autoloader::registerNamespace('ThinHelper', APPLICATION_PATH . DS . 'helpers');
Autoloader::registerNamespace('ThinPlugin', APPLICATION_PATH . DS . 'plugins');
Autoloader::registerNamespace('ThinForm', APPLICATION_PATH . DS . 'forms');
Autoloader::registerNamespace('ThinTask', APPLICATION_PATH . DS . 'tasks');
Autoloader::registerNamespace('ThinHook', APPLICATION_PATH . DS . 'hooks');
Config::init();
date_default_timezone_set(Config::get('application.timezone', 'Europe/Paris'));
$app = App::instance();
$language = isAke($_REQUEST, 'thin_language', Config::get('application.language', DEFAULT_LANGUAGE));
$app->setLang(with(new Lang($language)));
$core = context('core');
$core->set('app', $app);
$core->log(function ($message) {
    Log::info($message);
});
define('NL', "\n");
define('THINSTART', microtime());
if (Arrays::exists('SERVER_NAME', $_SERVER)) {
    $protocol = 'http';
    if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
        $protocol = 'https';
    }
Example #12
0
 /**
  * Test the Request::forged method.
  *
  * @group laravel
  */
 public function testForgedMethodIndicatesIfRequestWasForged()
 {
     Session::$instance = new SessionPayloadTokenStub();
     $input = array(Session::csrf_token => 'Foo');
     Request::foundation()->request->add($input);
     $this->assertTrue(Request::forged());
     $input = array(Session::csrf_token => 'Taylor');
     Request::foundation()->request->add($input);
     $this->assertFalse(Request::forged());
 }