Skip to content

Commit

Permalink
FormMacros: removed deprecated $_form
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Jan 19, 2021
1 parent 5378502 commit 8cab472
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
8 changes: 4 additions & 4 deletions src/Bridges/FormsLatte/FormMacros.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static function install(Latte\Compiler $compiler): void
$me = new static($compiler);
$me->addMacro('form', [$me, 'macroForm'], 'echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack));');
$me->addMacro('formContext', [$me, 'macroFormContext'], 'array_pop($this->global->formsStack);');
$me->addMacro('formContainer', [$me, 'macroFormContainer'], 'array_pop($this->global->formsStack); $formContainer = $_form = end($this->global->formsStack)');
$me->addMacro('formContainer', [$me, 'macroFormContainer'], 'array_pop($this->global->formsStack); $formContainer = end($this->global->formsStack)');
$me->addMacro('label', [$me, 'macroLabel'], [$me, 'macroLabelEnd'], null, self::AUTO_EMPTY);
$me->addMacro('input', [$me, 'macroInput']);
$me->addMacro('name', [$me, 'macroName'], [$me, 'macroNameEnd'], [$me, 'macroNameAttr']);
Expand Down Expand Up @@ -64,7 +64,7 @@ public function macroForm(MacroNode $node, PhpWriter $writer)
$node->tokenizer->reset();
return $writer->write(
"/* line $node->startLine */\n"
. 'echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form = $_form = $this->global->formsStack[] = '
. 'echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form = $this->global->formsStack[] = '
. ($name[0] === '$' ? 'is_object(%node.word) ? %node.word : ' : '')
. '$this->global->uiControl[%node.word], %node.array);'
);
Expand Down Expand Up @@ -109,7 +109,7 @@ public function macroFormContainer(MacroNode $node, PhpWriter $writer)
}
$node->tokenizer->reset();
return $writer->write(
'$this->global->formsStack[] = $formContainer = $_form = '
'$this->global->formsStack[] = $formContainer = '
. ($name[0] === '$' ? 'is_object(%node.word) ? %node.word : ' : '')
. 'end($this->global->formsStack)[%node.word];'
);
Expand Down Expand Up @@ -197,7 +197,7 @@ public function macroNameAttr(MacroNode $node, PhpWriter $writer)

if ($tagName === 'form') {
$node->openingCode = $writer->write(
'<?php $form = $_form = $this->global->formsStack[] = '
'<?php $form = $this->global->formsStack[] = '
. ($name[0] === '$' ? 'is_object(%0.word) ? %0.word : ' : '')
. '$this->global->uiControl[%0.word]; ?>',
$name
Expand Down
2 changes: 1 addition & 1 deletion tests/Forms.Latte/expected/FormMacros.button.phtml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
%A%
$form = $_form = $this->global->formsStack[] = $this->global->uiControl["myForm"];
$form = $this->global->formsStack[] = $this->global->uiControl["myForm"];
echo '<form';
echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin(end($this->global->formsStack), [], false);
echo '>
Expand Down
18 changes: 9 additions & 9 deletions tests/Forms.Latte/expected/FormMacros.formContainer.phtml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
%A%
/* line 1 */
echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form = $_form = $this->global->formsStack[] = $this->global->uiControl["myForm"], []);
echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form = $this->global->formsStack[] = $this->global->uiControl["myForm"], []);
echo '
<table>
<tr>
Expand All @@ -13,7 +13,7 @@
echo '</td>
</tr>
';
$this->global->formsStack[] = $formContainer = $_form = end($this->global->formsStack)["cont1"];
$this->global->formsStack[] = $formContainer = end($this->global->formsStack)["cont1"];
echo ' <tr>
<th>';
if ($_label = end($this->global->formsStack)["input2"]->getLabel()) echo $_label;
Expand All @@ -34,7 +34,7 @@
<th>Checkboxes</th>
<td>
';
$this->global->formsStack[] = $formContainer = $_form = end($this->global->formsStack)["cont2"];
$this->global->formsStack[] = $formContainer = end($this->global->formsStack)["cont2"];
echo ' <ol>
';
$iterations = 0;
Expand All @@ -49,7 +49,7 @@
echo ' </ol>
';
array_pop($this->global->formsStack);
$formContainer = $_form = end($this->global->formsStack);
$formContainer = end($this->global->formsStack);
echo ' </td>
</tr>
<tr>
Expand All @@ -62,8 +62,8 @@
</tr>
';
array_pop($this->global->formsStack);
$formContainer = $_form = end($this->global->formsStack);
$this->global->formsStack[] = $formContainer = $_form = end($this->global->formsStack)["items"];
$formContainer = end($this->global->formsStack);
$this->global->formsStack[] = $formContainer = end($this->global->formsStack)["items"];
echo ' <tr>
<th>Items</th>
<td>
Expand All @@ -72,19 +72,19 @@
$iterations = 0;
foreach ($items as $item) {
if (!isset($formContainer[$item])) continue;
$this->global->formsStack[] = $formContainer = $_form = is_object($item) ? $item : end($this->global->formsStack)[$item];
$this->global->formsStack[] = $formContainer = is_object($item) ? $item : end($this->global->formsStack)[$item];
echo ' ';
echo end($this->global->formsStack)["input"]->getControl() /* line 37 */;
echo "\n";
array_pop($this->global->formsStack);
$formContainer = $_form = end($this->global->formsStack);
$formContainer = end($this->global->formsStack);
$iterations++;
}
echo ' </td>
</tr>
';
array_pop($this->global->formsStack);
$formContainer = $_form = end($this->global->formsStack);
$formContainer = end($this->global->formsStack);
echo ' <tr>
<th>';
if ($_label = end($this->global->formsStack)["input8"]->getLabel()) echo $_label;
Expand Down
12 changes: 6 additions & 6 deletions tests/Forms.Latte/expected/FormMacros.forms.phtml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
%A%
echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form = $_form = $this->global->formsStack[] = $this->global->uiControl["myForm"], ['id' => 'myForm', 'class'=>"ajax"]);
echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form = $this->global->formsStack[] = $this->global->uiControl["myForm"], ['id' => 'myForm', 'class'=>"ajax"]);
echo "\n";
$iterations = 0;
foreach (['id', 'username', 'select', 'area', 'send'] as $name) {
Expand Down Expand Up @@ -77,13 +77,13 @@
';
/* line 27 */
echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form = $_form = $this->global->formsStack[] = $this->global->uiControl["myForm"], []);
echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form = $this->global->formsStack[] = $this->global->uiControl["myForm"], []);
echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack));
echo '
';
/* line 29 */
echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form = $_form = $this->global->formsStack[] = $this->global->uiControl["myForm"], []);
echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form = $this->global->formsStack[] = $this->global->uiControl["myForm"], []);
echo "\n";
$iterations = 0;
foreach ($form['sex']->items as $key => $label) {
Expand Down Expand Up @@ -198,7 +198,7 @@
';
$form = $_form = $this->global->formsStack[] = $this->global->uiControl["myForm"];
$form = $this->global->formsStack[] = $this->global->uiControl["myForm"];
if (1) {
echo '<form id="myForm" class="ajax"';
echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin(end($this->global->formsStack), ['id' => null, 'class' => null], false);
Expand All @@ -215,7 +215,7 @@
echo '
';
$form = $_form = $this->global->formsStack[] = $this->global->uiControl["myForm"];
$form = $this->global->formsStack[] = $this->global->uiControl["myForm"];
echo '<form';
echo ($ʟ_tmp = array_filter(['nclass'])) ? ' class="' . LR\Filters::escapeHtmlAttr(implode(" ", array_unique($ʟ_tmp))) . '"' : "";
echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin(end($this->global->formsStack), ['class' => null], false);
Expand All @@ -231,7 +231,7 @@
';
$form = $_form = $this->global->formsStack[] = is_object($this->global->uiControl['myForm']) ? $this->global->uiControl['myForm'] : $this->global->uiControl[$this->global->uiControl['myForm']];
$form = $this->global->formsStack[] = is_object($this->global->uiControl['myForm']) ? $this->global->uiControl['myForm'] : $this->global->uiControl[$this->global->uiControl['myForm']];
echo '<FORM';
echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin(end($this->global->formsStack), [], false);
echo '>
Expand Down
4 changes: 2 additions & 2 deletions tests/Forms.Latte/expected/FormMacros.get.phtml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php
%A%
echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form = $_form = $this->global->formsStack[] = $this->global->uiControl["myForm"], []);
echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form = $this->global->formsStack[] = $this->global->uiControl["myForm"], []);
echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack));
echo '
';
$form = $_form = $this->global->formsStack[] = $this->global->uiControl["myForm"];
$form = $this->global->formsStack[] = $this->global->uiControl["myForm"];
echo '<form';
echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin(end($this->global->formsStack), [], false);
echo '>
Expand Down

0 comments on commit 8cab472

Please sign in to comment.