Created
March 4, 2014 03:09
-
-
Save larowlan/9339613 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Foo\Bar\Whistle; | |
use Drupal\Core\RequestInfo; | |
class Sniffer { | |
public function getMine($request) { | |
$raw = RequestInfo::getRawVariables($request); | |
return $raw->get('bar'); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Foo\Bar\Whistle\Tests; | |
use Foo\Bar\Whistle\Sniffer; | |
use Symfony\Component\HttpFoundation\Request; | |
use Symfony\Component\HttpFoundation\ParameterBag; | |
class ConsumerTest { | |
protected $sniffer; | |
public function setUp() { | |
$this->sniffer = new Sniffer(); | |
} | |
public function testGetMine() { | |
$request = new Request(); | |
$bag = new ParameterBag(); | |
$bag->set('bar', 'goat'); | |
$request->attributes->set('_raw_variables', $bag); | |
$this->assertEquals($this->sniffer->getMine($request), 'goat'); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Drupal\Core\Routing; | |
use Symfony\Component\HttpFoundation\Request; | |
class RequestInfo { | |
// Gets the raw variables. | |
public static method getRawVariables(Request $request) { | |
return $request->attributes->get('_raw_variables'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment