Skip to content

[TwigBridge] Remove "transchoice" from the code base #38686

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

Merged
merged 1 commit into from
Oct 23, 2020
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,18 @@ protected function doEnterNode(Node $node, Environment $env): Node
return $node;
}

if ($node instanceof FilterExpression && \in_array($node->getNode('filter')->getAttribute('value'), ['trans', 'transchoice'])) {
if ($node instanceof FilterExpression && 'trans' === $node->getNode('filter')->getAttribute('value')) {
$arguments = $node->getNode('arguments');
$ind = 'trans' === $node->getNode('filter')->getAttribute('value') ? 1 : 2;
if ($this->isNamedArguments($arguments)) {
if (!$arguments->hasNode('domain') && !$arguments->hasNode($ind)) {
if (!$arguments->hasNode('domain') && !$arguments->hasNode(1)) {
$arguments->setNode('domain', $this->scope->get('domain'));
}
} else {
if (!$arguments->hasNode($ind)) {
if (!$arguments->hasNode($ind - 1)) {
$arguments->setNode($ind - 1, new ArrayExpression([], $node->getTemplateLine()));
}

$arguments->setNode($ind, $this->scope->get('domain'));
} elseif (!$arguments->hasNode(1)) {
if (!$arguments->hasNode(0)) {
$arguments->setNode(0, new ArrayExpression([], $node->getTemplateLine()));
}

$arguments->setNode(1, $this->scope->get('domain'));
}
} elseif ($node instanceof TransNode) {
if (!$node->hasNode('domain')) {
Expand Down
10 changes: 0 additions & 10 deletions src/Symfony/Bridge/Twig/NodeVisitor/TranslationNodeVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,6 @@ protected function doEnterNode(Node $node, Environment $env): Node
$node->getNode('node')->getAttribute('value'),
$this->getReadDomainFromArguments($node->getNode('arguments'), 1),
];
} elseif (
$node instanceof FilterExpression &&
'transchoice' === $node->getNode('filter')->getAttribute('value') &&
$node->getNode('node') instanceof ConstantExpression
) {
// extract constant nodes with a trans filter
$this->messages[] = [
$node->getNode('node')->getAttribute('value'),
$this->getReadDomainFromArguments($node->getNode('arguments'), 2),
];
} elseif ($node instanceof TransNode) {
// extract trans nodes
$this->messages[] = [
Expand Down
1 change: 0 additions & 1 deletion src/Symfony/Bridge/Twig/UndefinedCallableHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class UndefinedCallableHandler
private static $filterComponents = [
'humanize' => 'form',
'trans' => 'translation',
'transchoice' => 'translation',
'yaml_encode' => 'yaml',
'yaml_dump' => 'yaml',
];
Expand Down