Skip to content
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

[BUGFIX] Prevent property spill-over to next call #419

Merged
merged 1 commit into from
Nov 16, 2018
Merged
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
3 changes: 3 additions & 0 deletions src/Core/ViewHelper/AbstractTagBasedViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ public function initializeArguments()
public function initialize()
{
parent::initialize();
$this->tag->reset();
$this->tag->setTagName($this->tagName);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this could be moved to setTagBuilder() and drop the $this->tagName injection from the constructor ...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather, I'd remove the line that sets the tag name in setTagBuilder since setter methods shouldn't mutate the object that is passed.

TagBuilders are already initialized with tag name as constructor argument ;)

In the future, tag based VH should become compilable in a way that TagBuilder is constructed outside and has one instance per execution, then passed to a static method that will render the tag. Then the TagBuilder reset and mutability can be reworked. Point being, if we aim for that then anything that treats the TagBuilder instance as a more stupid thing that needs init on every call, is imho a good thing. Even if it didn't also solve a bug ;)


if ($this->hasArgument('additionalAttributes') && is_array($this->arguments['additionalAttributes'])) {
$this->tag->addAttributes($this->arguments['additionalAttributes']);
}
Expand Down