From ce67639179e7f112eee8b86737b8d19dc2406c36 Mon Sep 17 00:00:00 2001 From: Vincent Gabriel Date: Mon, 15 May 2017 08:36:47 -0700 Subject: [PATCH 1/5] Add getSection to view factory --- src/Illuminate/View/Concerns/ManagesLayouts.php | 12 ++++++++++++ tests/View/ViewFactoryTest.php | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/Illuminate/View/Concerns/ManagesLayouts.php b/src/Illuminate/View/Concerns/ManagesLayouts.php index cd494f8e0aa5..db4d3fe94961 100644 --- a/src/Illuminate/View/Concerns/ManagesLayouts.php +++ b/src/Illuminate/View/Concerns/ManagesLayouts.php @@ -182,6 +182,18 @@ public function hasSection($name) return array_key_exists($name, $this->sections); } + /** + * Return a section if it exists otherwise return $default + * + * @param string $name + * @param string $default + * @return mixed + */ + public function getSection($name, $default=null) + { + return $this->getSections()[$name] ?? $default; + } + /** * Get the entire array of sections. * diff --git a/tests/View/ViewFactoryTest.php b/tests/View/ViewFactoryTest.php index 695a711e53fb..23afb6157e4f 100755 --- a/tests/View/ViewFactoryTest.php +++ b/tests/View/ViewFactoryTest.php @@ -349,6 +349,18 @@ public function testHasSection() $this->assertFalse($factory->hasSection('bar')); } + public function testGetSection() + { + $factory = $this->getFactory(); + $factory->startSection('foo'); + echo 'hi'; + $factory->stopSection(); + + $this->assertEquals('hi', $factory->getSection('foo')); + $this->assertNull($factory->getSection('bar')); + $this->assertEquals('default', $factory->getSection('bar', 'default')); + } + public function testMakeWithSlashAndDot() { $factory = $this->getFactory(); From bdf399f9e5b8c81f9588f4aa3f2b47df6b8e01d9 Mon Sep 17 00:00:00 2001 From: Vincent Gabriel Date: Mon, 15 May 2017 08:47:38 -0700 Subject: [PATCH 2/5] support php 5.6 --- .idea/blade.xml | 4 + .idea/deployment.xml | 4 + .idea/laravel-framework.iml | 18 ++ .idea/modules.xml | 8 + .idea/vcs.xml | 6 + .idea/workspace.xml | 282 ++++++++++++++++++ .../View/Concerns/ManagesLayouts.php | 2 +- 7 files changed, 323 insertions(+), 1 deletion(-) create mode 100644 .idea/blade.xml create mode 100644 .idea/deployment.xml create mode 100644 .idea/laravel-framework.iml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 .idea/workspace.xml diff --git a/.idea/blade.xml b/.idea/blade.xml new file mode 100644 index 000000000000..ddb9fb5402a7 --- /dev/null +++ b/.idea/blade.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/deployment.xml b/.idea/deployment.xml new file mode 100644 index 000000000000..4a679291cc0e --- /dev/null +++ b/.idea/deployment.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/laravel-framework.iml b/.idea/laravel-framework.iml new file mode 100644 index 000000000000..be511acdbe68 --- /dev/null +++ b/.idea/laravel-framework.iml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 000000000000..fcdcaacd43f2 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 000000000000..94a25f7f4cb4 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 000000000000..e6f485fec56c --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,282 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + hassection + + + + + + + + + + + true + DEFINITION_ORDER + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1494862487785 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Illuminate/View/Concerns/ManagesLayouts.php b/src/Illuminate/View/Concerns/ManagesLayouts.php index db4d3fe94961..6b2f29f82d59 100644 --- a/src/Illuminate/View/Concerns/ManagesLayouts.php +++ b/src/Illuminate/View/Concerns/ManagesLayouts.php @@ -191,7 +191,7 @@ public function hasSection($name) */ public function getSection($name, $default=null) { - return $this->getSections()[$name] ?? $default; + return isset($this->getSections()[$name]) ? $this->getSections()[$name] : $default; } /** From ae1710b5d6c4af1799392659f2a3815b618a9409 Mon Sep 17 00:00:00 2001 From: Vincent Gabriel Date: Mon, 15 May 2017 08:47:58 -0700 Subject: [PATCH 3/5] support php 5.6 --- .idea/blade.xml | 4 - .idea/deployment.xml | 4 - .idea/laravel-framework.iml | 18 --- .idea/modules.xml | 8 - .idea/vcs.xml | 6 - .idea/workspace.xml | 282 ------------------------------------ 6 files changed, 322 deletions(-) delete mode 100644 .idea/blade.xml delete mode 100644 .idea/deployment.xml delete mode 100644 .idea/laravel-framework.iml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/vcs.xml delete mode 100644 .idea/workspace.xml diff --git a/.idea/blade.xml b/.idea/blade.xml deleted file mode 100644 index ddb9fb5402a7..000000000000 --- a/.idea/blade.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/deployment.xml b/.idea/deployment.xml deleted file mode 100644 index 4a679291cc0e..000000000000 --- a/.idea/deployment.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/laravel-framework.iml b/.idea/laravel-framework.iml deleted file mode 100644 index be511acdbe68..000000000000 --- a/.idea/laravel-framework.iml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index fcdcaacd43f2..000000000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7f4cb4..000000000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml deleted file mode 100644 index e6f485fec56c..000000000000 --- a/.idea/workspace.xml +++ /dev/null @@ -1,282 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - hassection - - - - - - - - - - - true - DEFINITION_ORDER - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1494862487785 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file From afc02625b2bbaaa4d39f0a83f22bdbb1ff9112a0 Mon Sep 17 00:00:00 2001 From: Vincent Gabriel Date: Mon, 15 May 2017 08:49:08 -0700 Subject: [PATCH 4/5] styleci changes --- src/Illuminate/View/Concerns/ManagesLayouts.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/View/Concerns/ManagesLayouts.php b/src/Illuminate/View/Concerns/ManagesLayouts.php index 6b2f29f82d59..cc2cd967e84f 100644 --- a/src/Illuminate/View/Concerns/ManagesLayouts.php +++ b/src/Illuminate/View/Concerns/ManagesLayouts.php @@ -183,13 +183,13 @@ public function hasSection($name) } /** - * Return a section if it exists otherwise return $default + * Return a section if it exists otherwise return $default. * * @param string $name * @param string $default * @return mixed */ - public function getSection($name, $default=null) + public function getSection($name, $default = null) { return isset($this->getSections()[$name]) ? $this->getSections()[$name] : $default; } From 9fcb78ea49dbb7563a63cde64f14914e37937893 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Mon, 15 May 2017 12:21:32 -0500 Subject: [PATCH 5/5] Update ManagesLayouts.php --- src/Illuminate/View/Concerns/ManagesLayouts.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/View/Concerns/ManagesLayouts.php b/src/Illuminate/View/Concerns/ManagesLayouts.php index cc2cd967e84f..1224ee82c227 100644 --- a/src/Illuminate/View/Concerns/ManagesLayouts.php +++ b/src/Illuminate/View/Concerns/ManagesLayouts.php @@ -183,7 +183,7 @@ public function hasSection($name) } /** - * Return a section if it exists otherwise return $default. + * Get the contents of a section. * * @param string $name * @param string $default