-
Notifications
You must be signed in to change notification settings - Fork 11.4k
[5.2] Blade push with layouts weird ordering #12769
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -516,6 +516,34 @@ public function callCreator(View $view) | |
*/ | ||
public function startSection($section, $content = '') | ||
{ | ||
if (! isset($this->sections[$section])) { | ||
$this->sections[$section] = []; | ||
$this->sections[$section][0] = null; | ||
} | ||
if ($content === '') { | ||
if (ob_start()) { | ||
$this->sectionStack[] = $section; | ||
} | ||
} else { | ||
$this->extendSection($section, $content); | ||
} | ||
} | ||
|
||
/** | ||
* Start injecting content into a push section. | ||
* | ||
* @param string $section | ||
* @param string $content | ||
* @return void | ||
*/ | ||
public function startSectionPush($section, $content = '') | ||
{ | ||
if (! isset($this->sections[$section])) { | ||
$this->sections[$section] = []; | ||
} | ||
if (! isset($this->sections[$section][$this->renderCount])) { | ||
$this->sections[$section][$this->renderCount] = null; | ||
} | ||
if ($content === '') { | ||
if (ob_start()) { | ||
$this->sectionStack[] = $section; | ||
|
@@ -567,7 +595,7 @@ public function stopSection($overwrite = false) | |
$last = array_pop($this->sectionStack); | ||
|
||
if ($overwrite) { | ||
$this->sections[$last] = ob_get_clean(); | ||
$this->setSectionContent($last, ob_get_clean()); | ||
} else { | ||
$this->extendSection($last, ob_get_clean()); | ||
} | ||
|
@@ -589,11 +617,7 @@ public function appendSection() | |
|
||
$last = array_pop($this->sectionStack); | ||
|
||
if (isset($this->sections[$last])) { | ||
$this->sections[$last] .= ob_get_clean(); | ||
} else { | ||
$this->sections[$last] = ob_get_clean(); | ||
} | ||
$this->setSectionContent($last, ob_get_clean(), true); | ||
|
||
return $last; | ||
} | ||
|
@@ -607,11 +631,10 @@ public function appendSection() | |
*/ | ||
protected function extendSection($section, $content) | ||
{ | ||
if (isset($this->sections[$section])) { | ||
$content = str_replace('@parent', $content, $this->sections[$section]); | ||
if (! is_null($this->getSectionContent($section))) { | ||
$content = str_replace('@parent', $content, $this->getSectionContent($section)); | ||
} | ||
|
||
$this->sections[$section] = $content; | ||
$this->setSectionContent($section, $content); | ||
} | ||
|
||
/** | ||
|
@@ -626,7 +649,7 @@ public function yieldContent($section, $default = '') | |
$sectionContent = $default; | ||
|
||
if (isset($this->sections[$section])) { | ||
$sectionContent = $this->sections[$section]; | ||
$sectionContent = implode(array_reverse($this->sections[$section])); | ||
} | ||
|
||
$sectionContent = str_replace('@@parent', '--parent--holder--', $sectionContent); | ||
|
@@ -874,6 +897,37 @@ public function getSections() | |
return $this->sections; | ||
} | ||
|
||
/** | ||
* Get the section from the last element. | ||
* | ||
* @param string $section | ||
* @return string|null | ||
*/ | ||
public function getSectionContent($section) | ||
{ | ||
return end($this->sections[$section]); | ||
} | ||
|
||
/** | ||
* Set the section to the last element. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you, fix two |
||
* | ||
* @param string $section | ||
* @param string $content | ||
* @param bool $append | ||
* @return void | ||
*/ | ||
public function setSectionContent($section, $content, $append = false) | ||
{ | ||
end($this->sections[$section]); | ||
$key = key($this->sections[$section]); | ||
|
||
if (is_null($this->sections[$section][$key]) || $append === false) { | ||
$this->sections[$section][$key] = $content; | ||
} else { | ||
$this->sections[$section][$key] .= $content; | ||
} | ||
} | ||
|
||
/** | ||
* Get all of the registered named views in environment. | ||
* | ||
|
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing newline