public static function getCookieData()
 {
     // On 3.1, Cookie::get_all does not exist
     if (!method_exists('Cookie', 'get_all')) {
         return $_COOKIE;
     }
     return Cookie::get_all();
 }
 /**
  * The entry-point. called by Clockwork itself.
  * @param Request $request
  * @return \Clockwork\Request\Request
  */
 function resolve(Request $request)
 {
     // Retrieve the timeline
     $timeline = Injector::inst()->get('ClockworkTimeline');
     $timeline->finalize();
     $request->timelineData = $timeline->toArray();
     // Retrieve the query log
     $db = DB::getConn();
     if ($db instanceof DatabaseProxy) {
         $request->databaseQueries = $db->getQueries();
     }
     // Retrieve the log
     $log = Injector::inst()->get('ClockworkLog');
     $request->log = $log->toArray();
     // Fill in the rest of the request - these may not be finalized yet when the PhpDataSource sees them
     $request->cookies = \Cookie::get_all();
     $request->sessionData = \Session::get_all();
     // Give some knowledge about the controller if we have it
     if (isset(self::$controller)) {
         $request->controller = self::$controller;
     }
     // TODO: routing
     return $request;
 }
Ejemplo n.º 3
0
 /**
  * Test that we can distinguish between vars that were loaded on instantiation
  * and those added later
  */
 public function testExistingVersusNew()
 {
     //load with a cookie
     $cookieJar = new CookieJar(array('cookieExisting' => 'i woz here'));
     Injector::inst()->registerService($cookieJar, 'Cookie_Backend');
     //set a new cookie
     Cookie::set('cookieNew', 'i am new');
     //check we can fetch new and old cookie values
     $this->assertEquals('i woz here', Cookie::get('cookieExisting'));
     $this->assertEquals('i woz here', Cookie::get('cookieExisting', false));
     $this->assertEquals('i am new', Cookie::get('cookieNew'));
     //there should be no original value for the new cookie
     $this->assertEmpty(Cookie::get('cookieNew', false));
     //change the existing cookie, can we fetch the new and old value
     Cookie::set('cookieExisting', 'i woz changed');
     $this->assertEquals('i woz changed', Cookie::get('cookieExisting'));
     $this->assertEquals('i woz here', Cookie::get('cookieExisting', false));
     //check we can get all cookies
     $this->assertEquals(array('cookieExisting' => 'i woz changed', 'cookieNew' => 'i am new'), Cookie::get_all());
     //check we can get all original cookies
     $this->assertEquals(array('cookieExisting' => 'i woz here'), Cookie::get_all(false));
 }