Skip to content

Commit

Permalink
added validator trans + psr2
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxandreOgeret committed May 19, 2019
1 parent b422876 commit a90f5d0
Show file tree
Hide file tree
Showing 14 changed files with 53 additions and 16 deletions.
9 changes: 5 additions & 4 deletions src/Controller/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@ public function homeNoLocale(Request $request)

$request->setLocale($locale);

return new RedirectResponse($this->generateUrl('app_main_route_withlang', ['_locale' => $locale]), 302, ['_locale' => $locale]);

return $this->redirectToRoute('app_main_route_withlang', ['_locale' => $locale]);

return new RedirectResponse(
$this->generateUrl('app_main_route_withlang', ['_locale' => $locale]),
302,
['_locale' => $locale]
);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/EventSubscriber/LocaleSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ public static function getSubscribedEvents()
KernelEvents::REQUEST => [['onKernelRequest', 20]],
];
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ public static function getSubscribedEvents()
SecurityEvents::INTERACTIVE_LOGIN => 'onInteractiveLogin',
];
}
}
}
18 changes: 16 additions & 2 deletions src/Form/UserType.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,22 @@ public function buildForm(FormBuilderInterface $builder, array $options)
RepeatedType::class,
[
'type' => PasswordType::class,
'first_options' => ['attr' => ['placeholder'=> 'app.signup.form.placeholer.password', 'class' => 'stylish-input',]],
'second_options' => ['attr' => ['placeholder'=> 'app.signup.form.placeholer.repeatpassword', 'class' => 'stylish-input',]],
'first_options' =>
[
'attr' =>
[
'placeholder' => 'app.signup.form.placeholer.password',
'class' => 'stylish-input',
]
],
'second_options' =>
[
'attr' =>
[
'placeholder' => 'app.signup.form.placeholer.repeatpassword',
'class' => 'stylish-input',
]
],
'options' =>
[
'label_attr' => ['style' => 'display : none;',],
Expand Down
2 changes: 1 addition & 1 deletion src/Service/UserManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ public function getLocalesArray()
{
return explode('|', $this->locales);
}
}
}
2 changes: 1 addition & 1 deletion src/Validator/Constraints/NoRedirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
*/
class NoRedirect extends Constraint
{
public $message = "Links performing a redirection are forbidden.";
public $message = "app.validator.redirect";
}
2 changes: 1 addition & 1 deletion src/Validator/Constraints/Safebrowsing.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
*/
class Safebrowsing extends Constraint
{
public $message = "This link is banned.";
public $message = "app.validator.sb.banned";
}
4 changes: 2 additions & 2 deletions src/Validator/Constraints/ValidLessnLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
*/
class ValidLessnLink extends Constraint
{
public $message = 'This value is not a valid LESSn URL.';
public $messageEmpty = 'This LESSn URL doesn\'t exist.';
public $message = 'app.validator.lessn.notvalid';
public $messageEmpty = 'app.validator.lessn.nolink';
}
2 changes: 0 additions & 2 deletions templates/home/homeForm.html.twig
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{{ form_start(linkForm) }}


{#<div class="row">{{ form_label(linkForm.URL) }}</div>#}
<div class="row">{{ form_widget(linkForm.URL) }}
<button type="submit" class="btn btn-link link"><i class="fas fa-arrow-right"></i></button>
</div>
Expand Down
2 changes: 1 addition & 1 deletion translations/messages.et.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ app.linkmanager.table.uuid: 'Unikaalne ID'
app.linkmanager.table.url: 'URL'
app.linkmanager.createdon: 'Loodud'
app.linkmanager.visited: 'Külastatud'

app.linkmanager.nolink: "Linke pole."

app.linkmanager.error.notvalid: 'Sisesta korrektne URL'
app.linkmanager.error.uuidletters: 'Unikaalne ID võib sisaldada ainult'
Expand Down
6 changes: 6 additions & 0 deletions translations/validators.de.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
app.validator.sb.banned: "Diese URL ist verboten."
app.validator.lessn.notvalid: "Diese Eingabe ist nicht gültig."
app.validator.lessn.nolink: "Dieser Link existiert nicht."
app.validator.redirect: "Links zur Weiterleitung sind verboten."
app.validator.uuid.chars: "UUID sollte nur '-', '_', und '~' beinhalten."
app.validator.uuid.forbidden: "Diese Eingabe ist verboten."
6 changes: 6 additions & 0 deletions translations/validators.en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
app.validator.sb.banned: "This URL is banned."
app.validator.lessn.notvalid: "This value is not a valid LESSn URL."
app.validator.lessn.nolink: "This link doesn't exist."
app.validator.redirect: "Links performing a redirection are forbidden."
app.validator.uuid.chars: "UUID should contain only letters and '-', '_', '~'"
app.validator.uuid.forbidden: "This value is forbidden."
6 changes: 6 additions & 0 deletions translations/validators.et.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
app.validator.sb.banned: "See URL on keelatud."
app.validator.lessn.notvalid: "See ei ole sobiv LESSn URL."
app.validator.lessn.nolink: "Seda linki ei eksisteeri."
app.validator.redirect: "Ümbersuunavad lingid ei ole lubatud."
app.validator.uuid.chars: "UUID tohib sisaldada ainult tähti ja märke '-', '_', '~'"
app.validator.uuid.forbidden: "See väärtus ei ole lubatud."
6 changes: 6 additions & 0 deletions translations/validators.fr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
app.validator.sb.banned: "Cette URL est bannie"
app.validator.lessn.notvalid: "Cette valeur n'est pas un lien LESSn."
app.validator.lessn.nolink: "Ce lien n'existe pas."
app.validator.redirect: "Les liens faisant des redirections sont interdits."
app.validator.uuid.chars: "L'ID unique ne doit contenir que des lettres et '-', '_', '~'"
app.validator.uuid.forbidden: "Cette valeur est interdite."

0 comments on commit a90f5d0

Please sign in to comment.