Skip to content
This repository was archived by the owner on Jan 18, 2018. It is now read-only.

Commit 0a8e823

Browse files
Fixed request binding
1 parent a92bbf5 commit 0a8e823

4 files changed

Lines changed: 29 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ CHANGE LOG
1010
## V0.3 Alpha (Upcoming)
1111

1212
* PHP 5.6 and HHVM compatibility
13+
* Fixed request binding
1314
* Composer tweaks
1415

1516

src/Classes/Navigation.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,17 @@ public function getRequest()
312312
return $this->request;
313313
}
314314

315+
/**
316+
* Set the request instance.
317+
*
318+
* @param \Illuminate\Http\Request $request
319+
* @return void
320+
*/
321+
public function setRequest(Request $request)
322+
{
323+
return $this->request = $request;
324+
}
325+
315326
/**
316327
* Get the url instance.
317328
*

src/NavigationServiceProvider.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ protected function registerNavigation()
7070
$htmlmin = $app['htmlmin'];
7171
$view = $app['config']['graham-campbell/navigation::view'];
7272

73-
return new Classes\Navigation($events, $request, $url, $htmlmin, $view);
73+
$navigation = new Classes\Navigation($events, $request, $url, $htmlmin, $view);
74+
$app->refresh('request', $navigation, 'setRequest');
75+
return $navigation;
7476
});
7577
}
7678

tests/Classes/NavigationTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
namespace GrahamCampbell\Tests\Navigation\Classes;
1818

1919
use Mockery;
20+
use Illuminate\Http\Request;
2021
use GrahamCampbell\Navigation\Classes\Navigation;
2122
use GrahamCampbell\TestBench\Classes\AbstractTestCase;
2223

@@ -257,6 +258,19 @@ public function testGetHTMLWithBar()
257258
$this->assertEquals($return, 'html goes here');
258259
}
259260

261+
public function testSetRequest()
262+
{
263+
$navigation = $this->getNavigation()();
264+
265+
$request = new Request();
266+
267+
$navigation->setRequest($request);
268+
269+
$return = $navigation->getRequest();
270+
271+
$this->assertEquals($request, $return);
272+
}
273+
260274
protected function getNavigation()
261275
{
262276
$events = Mockery::mock('Illuminate\Events\Dispatcher');

0 commit comments

Comments
 (0)