diff --git a/src/Illuminate/View/Factory.php b/src/Illuminate/View/Factory.php index 85778720..313899b1 100755 --- a/src/Illuminate/View/Factory.php +++ b/src/Illuminate/View/Factory.php @@ -45,20 +45,6 @@ class Factory { */ protected $shared = array(); - /** - * Array of registered view name aliases. - * - * @var array - */ - protected $aliases = array(); - - /** - * All of the registered view names. - * - * @var array - */ - protected $names = array(); - /** * The extension to engine bindings. * @@ -121,8 +107,6 @@ public function __construct(EngineResolver $engines, ViewFinderInterface $finder */ public function make($view, $data = array(), $mergeData = array()) { - if (isset($this->aliases[$view])) $view = $this->aliases[$view]; - $path = $this->finder->find($view); $data = array_merge($mergeData, $this->parseData($data)); @@ -143,42 +127,6 @@ protected function parseData($data) return $data instanceof Arrayable ? $data->toArray() : $data; } - /** - * Get the evaluated view contents for a named view. - * - * @param string $view - * @param mixed $data - * @return \Illuminate\View\View - */ - public function of($view, $data = array()) - { - return $this->make($this->names[$view], $data); - } - - /** - * Register a named view. - * - * @param string $view - * @param string $name - * @return void - */ - public function name($view, $name) - { - $this->names[$name] = $view; - } - - /** - * Add an alias for a view. - * - * @param string $view - * @param string $alias - * @return void - */ - public function alias($view, $alias) - { - $this->aliases[$alias] = $view; - } - /** * Determine if a given view exists. * @@ -614,21 +562,31 @@ public function yieldContent($section, $default = '') */ public function flushSections() { - $this->renderCount = 0; - $this->sections = array(); $this->sectionStack = array(); } + /** + * Flush all of the factory state like sections and stacks. + * + * @return void + */ + public function flushState() + { + $this->renderCount = 0; + + $this->flushSections(); + } + /** * Flush all of the section contents if done rendering. * * @return void */ - public function flushSectionsIfDoneRendering() + public function flushStateIfDoneRendering() { - if ($this->doneRendering()) $this->flushSections(); + if ($this->doneRendering()) $this->flushState(); } /** @@ -833,14 +791,4 @@ public function getSections() return $this->sections; } - /** - * Get all of the registered named views in environment. - * - * @return array - */ - public function getNames() - { - return $this->names; - } - } diff --git a/src/Illuminate/View/View.php b/src/Illuminate/View/View.php index de4dfcad..5a33e7e2 100755 --- a/src/Illuminate/View/View.php +++ b/src/Illuminate/View/View.php @@ -76,11 +76,11 @@ public function render(?Closure $callback = null) // Once we have the contents of the view, we will flush the sections if we are // done rendering all views so that there is nothing left hanging over when // another view gets rendered in the future by the application developer. - $this->factory->flushSectionsIfDoneRendering(); + $this->factory->flushStateIfDoneRendering(); return $response ?: $contents; } catch (Exception $e) { - $this->factory->flushSections(); + $this->factory->flushState(); throw $e; } diff --git a/tests/View/ViewFactoryTest.php b/tests/View/ViewFactoryTest.php index 7bdf90c1..83ee781b 100755 --- a/tests/View/ViewFactoryTest.php +++ b/tests/View/ViewFactoryTest.php @@ -78,32 +78,6 @@ public function testEmptyViewsCanBeReturnedFromRenderEach() } - public function testAddANamedViews() - { - $factory = $this->getFactory(); - $factory->name('bar', 'foo'); - - $this->assertEquals(['foo' => 'bar'], $factory->getNames()); - } - - - public function testMakeAViewFromNamedView() - { - $factory = $this->getFactory(); - $factory->getFinder()->shouldReceive('find')->once()->with('view')->andReturn('path.php'); - $factory->getEngineResolver()->shouldReceive('resolve')->once()->with('php')->andReturn($engine = m::mock( - EngineInterface::class - )); - $factory->getFinder()->shouldReceive('addExtension')->once()->with('php'); - $factory->getDispatcher()->shouldReceive('dispatch'); - $factory->addExtension('php', 'php'); - $factory->name('view', 'foo'); - $view = $factory->of('foo', ['data']); - - $this->assertSame($engine, $view->getEngine()); - } - - public function testRawStringsMayBeReturnedFromRenderEach() { $this->assertEquals('foo', $this->getFactory()->renderEach('foo', [], 'item', 'raw|foo')); @@ -349,22 +323,6 @@ public function testSectionFlushing() } - public function testMakeWithAlias() - { - $factory = $this->getFactory(); - $factory->alias('real', 'alias'); - $factory->getFinder()->shouldReceive('find')->once()->with('real')->andReturn('path.php'); - $factory->getEngineResolver()->shouldReceive('resolve')->once()->with('php')->andReturn(m::mock( - EngineInterface::class - )); - $factory->getDispatcher()->shouldReceive('dispatch'); - - $view = $factory->make('alias'); - - $this->assertEquals('real', $view->getName()); - } - - public function testExceptionIsThrownForUnknownExtension() { $this->expectException('InvalidArgumentException'); diff --git a/tests/View/ViewTest.php b/tests/View/ViewTest.php index f6797238..b85d7ab3 100755 --- a/tests/View/ViewTest.php +++ b/tests/View/ViewTest.php @@ -49,7 +49,7 @@ public function testRenderProperlyRendersView() $view->getFactory()->shouldReceive('getShared')->once()->andReturn(['shared' => 'foo']); $view->getEngine()->shouldReceive('get')->once()->with('path', ['foo' => 'bar', 'shared' => 'foo'])->andReturn('contents'); $view->getFactory()->shouldReceive('decrementRender')->once()->ordered(); - $view->getFactory()->shouldReceive('flushSectionsIfDoneRendering')->once(); + $view->getFactory()->shouldReceive('flushStateIfDoneRendering')->once(); $me = $this; $callback = function(View $rendered, $contents) use ($me, $view) @@ -86,7 +86,7 @@ public function testSectionsAreNotFlushedWhenNotDoneRendering() $view->getFactory()->shouldReceive('getShared')->twice()->andReturn(['shared' => 'foo']); $view->getEngine()->shouldReceive('get')->twice()->with('path', ['foo' => 'bar', 'shared' => 'foo'])->andReturn('contents'); $view->getFactory()->shouldReceive('decrementRender')->twice(); - $view->getFactory()->shouldReceive('flushSectionsIfDoneRendering')->twice(); + $view->getFactory()->shouldReceive('flushStateIfDoneRendering')->twice(); $this->assertEquals('contents', $view->render()); $this->assertEquals('contents', (string) $view); @@ -176,7 +176,7 @@ public function testViewGatherDataWithRenderable() $view->getFactory()->shouldReceive('getShared')->once()->andReturn(['shared' => 'foo']); $view->getEngine()->shouldReceive('get')->once()->andReturn('contents'); $view->getFactory()->shouldReceive('decrementRender')->once()->ordered(); - $view->getFactory()->shouldReceive('flushSectionsIfDoneRendering')->once(); + $view->getFactory()->shouldReceive('flushStateIfDoneRendering')->once(); $view->renderable = m::mock(Renderable::class); $view->renderable->shouldReceive('render')->once()->andReturn('text'); @@ -192,7 +192,7 @@ public function testViewRenderSections() $view->getFactory()->shouldReceive('getShared')->once()->andReturn(['shared' => 'foo']); $view->getEngine()->shouldReceive('get')->once()->andReturn('contents'); $view->getFactory()->shouldReceive('decrementRender')->once()->ordered(); - $view->getFactory()->shouldReceive('flushSectionsIfDoneRendering')->once(); + $view->getFactory()->shouldReceive('flushStateIfDoneRendering')->once(); $view->getFactory()->shouldReceive('getSections')->once()->andReturn(['foo','bar']); $sections = $view->renderSections();