Skip to content

Skip keys with the @Ignore annotation in the FormExtractor #162

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
wants to merge 2 commits into from
Closed
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
11 changes: 6 additions & 5 deletions Translation/Extractor/File/FormExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,10 @@ private function parseDefaultsCall($name, \PHPParser_Node $node)

private function parseItem($item, $domain = null)
{
// get doc comment
$ignore = false;
$desc = $meaning = $docComment = null;


// get doc comment
if ($item->key) {
$docComment = $item->key->getDocComment();
}
Expand All @@ -207,10 +207,11 @@ private function parseItem($item, $domain = null)
// check if the value is explicitly set to false => e.g. for FormField that should be rendered without label
$ignore = $ignore || $item->value->value == false;

if ($ignore) {
return;
}

if (!$item->value instanceof \PHPParser_Node_Scalar_String) {
if ($ignore) {
return;
}

$message = sprintf('Unable to extract translation id for form label/title/placeholder from non-string values, but got "%s" in %s on line %d. Please refactor your code to pass a string, or add "/** @Ignore */".', get_class($item->value), $this->file, $item->value->getLine());
if ($this->logger) {
Expand Down