Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/Robbo/Presenter/View/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ class View extends BaseView {
*/
public function with($key, $value = null)
{
return parent::with($key, $this->environment->makePresentable($value));
if (is_array($key))
{
foreach ($key as $name => $value) {
$key[$name] = $this->environment->makePresentable($value);
}
return parent::with($key);
}
else
{
return parent::with($key, $this->environment->makePresentable($value));
}
}
}
19 changes: 19 additions & 0 deletions tests/ViewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,25 @@ public function testWithMakesPresentable()

$this->assertTrue($view['presenter'] instanceof Presenter);
}

public function testWithMakesArrayPresentable()
{
$env = new EnvironmentStub(
m::mock('Illuminate\View\Engines\EngineResolver'),
m::mock('Illuminate\View\ViewFinderInterface'),
m::mock('Illuminate\Events\Dispatcher')
);

$view = new View($env, m::mock('Illuminate\View\Engines\EngineInterface'), 'test', 'test/path');

$data = array(
'presenter' => new ViewPresentableStub
);

$view->with($data);

$this->assertTrue($view['presenter'] instanceof Presenter);
}
}

class ViewPresentableStub implements PresentableInterface {
Expand Down