@@ 21-54 (lines=34) @@ | ||
18 | /** |
|
19 | * @author Tobias Nyholm <[email protected]> |
|
20 | */ |
|
21 | final class ContainerAwareTrans extends BasePHPVisitor implements NodeVisitor |
|
22 | { |
|
23 | public function beforeTraverse(array $nodes) |
|
24 | { |
|
25 | } |
|
26 | ||
27 | public function enterNode(Node $node) |
|
28 | { |
|
29 | if (!$node instanceof Node\Expr\MethodCall) { |
|
30 | return; |
|
31 | } |
|
32 | ||
33 | if (!is_string($node->name) && !$node->name instanceof Node\Identifier) { |
|
34 | return; |
|
35 | } |
|
36 | $name = (string) $node->name; |
|
37 | ||
38 | //If $this->get('translator')->trans('foobar') |
|
39 | if ('trans' === $name) { |
|
40 | $label = $this->getStringArgument($node, 0); |
|
41 | $domain = $this->getStringArgument($node, 2); |
|
42 | ||
43 | $this->addLocation($label, $node->getAttribute('startLine'), $node, ['domain' => $domain]); |
|
44 | } |
|
45 | } |
|
46 | ||
47 | public function leaveNode(Node $node) |
|
48 | { |
|
49 | } |
|
50 | ||
51 | public function afterTraverse(array $nodes) |
|
52 | { |
|
53 | } |
|
54 | } |
|
55 |
@@ 21-54 (lines=34) @@ | ||
18 | /** |
|
19 | * @author Tobias Nyholm <[email protected]> |
|
20 | */ |
|
21 | final class ContainerAwareTransChoice extends BasePHPVisitor implements NodeVisitor |
|
22 | { |
|
23 | public function beforeTraverse(array $nodes) |
|
24 | { |
|
25 | } |
|
26 | ||
27 | public function enterNode(Node $node) |
|
28 | { |
|
29 | if (!$node instanceof Node\Expr\MethodCall) { |
|
30 | return; |
|
31 | } |
|
32 | ||
33 | if (!is_string($node->name) && !$node->name instanceof Node\Identifier) { |
|
34 | return; |
|
35 | } |
|
36 | $name = (string) $node->name; |
|
37 | ||
38 | //If $this->get('translator')->trans('foobar') |
|
39 | if ('transChoice' === $name) { |
|
40 | $label = $this->getStringArgument($node, 0); |
|
41 | $domain = $this->getStringArgument($node, 3); |
|
42 | ||
43 | $this->addLocation($label, $node->getAttribute('startLine'), $node, ['domain' => $domain]); |
|
44 | } |
|
45 | } |
|
46 | ||
47 | public function leaveNode(Node $node) |
|
48 | { |
|
49 | } |
|
50 | ||
51 | public function afterTraverse(array $nodes) |
|
52 | { |
|
53 | } |
|
54 | } |
|
55 |