@@ -55,7 +55,7 @@ |
||
| 55 | 55 | * @param Request $request |
| 56 | 56 | * @param Response $response |
| 57 | 57 | * @param null|callable $out |
| 58 | - * @return null|Response |
|
| 58 | + * @return Response |
|
| 59 | 59 | */ |
| 60 | 60 | public function __invoke(Request $request, Response $response, callable $out = null): Response |
| 61 | 61 | { |
@@ -63,7 +63,7 @@ |
||
| 63 | 63 | $params = $matchedRoute->getMatchedParams(); |
| 64 | 64 | |
| 65 | 65 | // Determine the language to use based on the lang parameter |
| 66 | - $lang = $params['lang'] ?? 'en'; |
|
| 66 | + $lang = $params[ 'lang' ] ?? 'en'; |
|
| 67 | 67 | $this->translator->setLocale($lang); |
| 68 | 68 | return $out($request, $response); |
| 69 | 69 | } |
@@ -25,6 +25,6 @@ |
||
| 25 | 25 | public function __invoke(ContainerInterface $container, $requestedName, array $options = null): MailOptions |
| 26 | 26 | { |
| 27 | 27 | $config = $container->get('config'); |
| 28 | - return new MailOptions($config['mail'] ?? []); |
|
| 28 | + return new MailOptions($config[ 'mail' ] ?? [ ]); |
|
| 29 | 29 | } |
| 30 | 30 | } |
@@ -32,9 +32,9 @@ discard block |
||
| 32 | 32 | { |
| 33 | 33 | // Create the twig environment |
| 34 | 34 | $twig = new \Twig_Environment(new \Twig_Loader_Filesystem([ |
| 35 | - __DIR__ . '/../../templates' |
|
| 35 | + __DIR__.'/../../templates' |
|
| 36 | 36 | ]), [ |
| 37 | - 'cache' => getenv('APP_ENV') === 'pro' ? __DIR__ . '/../../data/cache' : false, |
|
| 37 | + 'cache' => getenv('APP_ENV') === 'pro' ? __DIR__.'/../../data/cache' : false, |
|
| 38 | 38 | ]); |
| 39 | 39 | |
| 40 | 40 | // Add extensions |
@@ -43,9 +43,9 @@ discard block |
||
| 43 | 43 | $twig->addExtension(new NavigationExtension( |
| 44 | 44 | $container->get('translator'), |
| 45 | 45 | $container->get(RouteAssembler::class), |
| 46 | - $container->get('config')['navigation'] |
|
| 46 | + $container->get('config')[ 'navigation' ] |
|
| 47 | 47 | )); |
| 48 | - $twig->addExtension(new RecaptchaExtension($container->get('config')['recaptcha'])); |
|
| 48 | + $twig->addExtension(new RecaptchaExtension($container->get('config')[ 'recaptcha' ])); |
|
| 49 | 49 | |
| 50 | 50 | return new TwigRenderer($twig); |
| 51 | 51 | } |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | public function __construct( |
| 23 | 23 | TranslatorInterface $translator, |
| 24 | 24 | RouteAssemblerInterface $routeAssembler, |
| 25 | - array $config = [] |
|
| 25 | + array $config = [ ] |
|
| 26 | 26 | ) { |
| 27 | 27 | $this->translator = $translator; |
| 28 | 28 | $this->routeAssembler = $routeAssembler; |
@@ -32,32 +32,32 @@ discard block |
||
| 32 | 32 | public function getFunctions(): array |
| 33 | 33 | { |
| 34 | 34 | return [ |
| 35 | - new \Twig_SimpleFunction('render_menu', [$this, 'renderMenu'], ['is_safe' => ['html']]), |
|
| 36 | - new \Twig_SimpleFunction('render_langs_menu', [$this, 'renderLanguagesMenu'], ['is_safe' => ['html']]), |
|
| 35 | + new \Twig_SimpleFunction('render_menu', [ $this, 'renderMenu' ], [ 'is_safe' => [ 'html' ] ]), |
|
| 36 | + new \Twig_SimpleFunction('render_langs_menu', [ $this, 'renderLanguagesMenu' ], [ 'is_safe' => [ 'html' ] ]), |
|
| 37 | 37 | ]; |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | public function renderMenu(): string |
| 41 | 41 | { |
| 42 | - $pages = isset($this->config['menu']) ? $this->config['menu'] : []; |
|
| 43 | - $listElements = []; |
|
| 42 | + $pages = isset($this->config[ 'menu' ]) ? $this->config[ 'menu' ] : [ ]; |
|
| 43 | + $listElements = [ ]; |
|
| 44 | 44 | $elementPattern = |
| 45 | - '<li class="%s">' . |
|
| 46 | - '<a href="%s" %s><i class="fa %s"></i> %s</a>' . |
|
| 45 | + '<li class="%s">'. |
|
| 46 | + '<a href="%s" %s><i class="fa %s"></i> %s</a>'. |
|
| 47 | 47 | '</li>'; |
| 48 | 48 | $currentRoute = $this->routeAssembler->getCurrentRouteResult(); |
| 49 | 49 | foreach ($pages as $page) { |
| 50 | - $active = isset($page['route']) && $currentRoute->getMatchedRouteName() === $page['route'] ? 'active' : ''; |
|
| 51 | - $target = isset($page['target']) ? 'target="_blank"' : ''; |
|
| 52 | - $route = $page['uri'] ?? $this->routeAssembler->assembleUrl($page['route'], true); |
|
| 50 | + $active = isset($page[ 'route' ]) && $currentRoute->getMatchedRouteName() === $page[ 'route' ] ? 'active' : ''; |
|
| 51 | + $target = isset($page[ 'target' ]) ? 'target="_blank"' : ''; |
|
| 52 | + $route = $page[ 'uri' ] ?? $this->routeAssembler->assembleUrl($page[ 'route' ], true); |
|
| 53 | 53 | |
| 54 | - $listElements[] = sprintf( |
|
| 54 | + $listElements[ ] = sprintf( |
|
| 55 | 55 | $elementPattern, |
| 56 | 56 | $active, |
| 57 | 57 | $route, |
| 58 | 58 | $target, |
| 59 | - $page['icon'], |
|
| 60 | - $this->translator->translate($page['label']) |
|
| 59 | + $page[ 'icon' ], |
|
| 60 | + $this->translator->translate($page[ 'label' ]) |
|
| 61 | 61 | ); |
| 62 | 62 | } |
| 63 | 63 | |
@@ -66,24 +66,24 @@ discard block |
||
| 66 | 66 | |
| 67 | 67 | public function renderLanguagesMenu(): string |
| 68 | 68 | { |
| 69 | - $pages = $this->config['lang_menu'] ?? []; |
|
| 70 | - $listElements = []; |
|
| 69 | + $pages = $this->config[ 'lang_menu' ] ?? [ ]; |
|
| 70 | + $listElements = [ ]; |
|
| 71 | 71 | $elementPattern = |
| 72 | - '<li>' . |
|
| 73 | - '<a href="%s" class="%s">%s</a>' . |
|
| 72 | + '<li>'. |
|
| 73 | + '<a href="%s" class="%s">%s</a>'. |
|
| 74 | 74 | '</li>'; |
| 75 | 75 | $pageResult = $this->routeAssembler->getCurrentRouteResult(); |
| 76 | 76 | |
| 77 | 77 | foreach ($pages as $page) { |
| 78 | 78 | // Inherit current route if it is not an error page |
| 79 | 79 | $routeName = $pageResult->isSuccess() ? null : 'home'; |
| 80 | - $route = $this->routeAssembler->assembleUrl($routeName, $page['params']); |
|
| 80 | + $route = $this->routeAssembler->assembleUrl($routeName, $page[ 'params' ]); |
|
| 81 | 81 | |
| 82 | - $listElements[] = sprintf( |
|
| 82 | + $listElements[ ] = sprintf( |
|
| 83 | 83 | $elementPattern, |
| 84 | 84 | $route, |
| 85 | - $page['class'], |
|
| 86 | - $page['label'] |
|
| 85 | + $page[ 'class' ], |
|
| 86 | + $page[ 'label' ] |
|
| 87 | 87 | ); |
| 88 | 88 | } |
| 89 | 89 | |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | public function getFunctions(): array |
| 20 | 20 | { |
| 21 | 21 | return [ |
| 22 | - new \Twig_SimpleFunction('assemble_url', [$this, 'assembleUrl']) |
|
| 22 | + new \Twig_SimpleFunction('assemble_url', [ $this, 'assembleUrl' ]) |
|
| 23 | 23 | ]; |
| 24 | 24 | } |
| 25 | 25 | |
@@ -32,8 +32,8 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | public function assembleUrl( |
| 34 | 34 | string $name = null, |
| 35 | - $routeParams = [], |
|
| 36 | - $queryParams = [], |
|
| 35 | + $routeParams = [ ], |
|
| 36 | + $queryParams = [ ], |
|
| 37 | 37 | bool $inherit = false |
| 38 | 38 | ): string { |
| 39 | 39 | return $this->routeAssembler->assembleUrl($name, $routeParams, $queryParams, $inherit); |
@@ -16,24 +16,24 @@ |
||
| 16 | 16 | public function getFunctions(): array |
| 17 | 17 | { |
| 18 | 18 | return [ |
| 19 | - new \Twig_SimpleFunction('recaptcha_public', [$this, 'getRecapcthaPublicKey']), |
|
| 20 | - new \Twig_SimpleFunction('recaptcha_input', [$this, 'renderInput'], ['is_safe' => ['html']]), |
|
| 19 | + new \Twig_SimpleFunction('recaptcha_public', [ $this, 'getRecapcthaPublicKey' ]), |
|
| 20 | + new \Twig_SimpleFunction('recaptcha_input', [ $this, 'renderInput' ], [ 'is_safe' => [ 'html' ] ]), |
|
| 21 | 21 | ]; |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | public function getRecapcthaPublicKey(): string |
| 25 | 25 | { |
| 26 | - return $this->config['public_key']; |
|
| 26 | + return $this->config[ 'public_key' ]; |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | public function renderInput(string $lang = 'en'): string |
| 30 | 30 | { |
| 31 | 31 | return ' |
| 32 | 32 | <script |
| 33 | - src="https://www.google.com/recaptcha/api.js?hl=' . $lang . '"> |
|
| 33 | + src="https://www.google.com/recaptcha/api.js?hl=' . $lang.'"> |
|
| 34 | 34 | </script> |
| 35 | 35 | <div class="g-recaptcha" |
| 36 | - data-sitekey="' . $this->getRecapcthaPublicKey() . '" |
|
| 36 | + data-sitekey="' . $this->getRecapcthaPublicKey().'" |
|
| 37 | 37 | data-callback="recaptchaCallaback"> |
| 38 | 38 | </div> |
| 39 | 39 | '; |
@@ -84,10 +84,10 @@ |
||
| 84 | 84 | * @param array $routeParams |
| 85 | 85 | * @return bool |
| 86 | 86 | */ |
| 87 | - protected function isResponseCacheable(Response $resp, array $routeParams = []): bool |
|
| 87 | + protected function isResponseCacheable(Response $resp, array $routeParams = [ ]): bool |
|
| 88 | 88 | { |
| 89 | 89 | return $resp->getStatusCode() === 200 |
| 90 | - && isset($routeParams['cacheable']) |
|
| 91 | - && $routeParams['cacheable'] === true; |
|
| 90 | + && isset($routeParams[ 'cacheable' ]) |
|
| 91 | + && $routeParams[ 'cacheable' ] === true; |
|
| 92 | 92 | } |
| 93 | 93 | } |
@@ -17,8 +17,8 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | public function assembleUrl( |
| 19 | 19 | string $name = null, |
| 20 | - $routeParams = [], |
|
| 21 | - $queryParams = [], |
|
| 20 | + $routeParams = [ ], |
|
| 21 | + $queryParams = [ ], |
|
| 22 | 22 | bool $inherit = false |
| 23 | 23 | ): string; |
| 24 | 24 | |
@@ -41,8 +41,8 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | public function assembleUrl( |
| 43 | 43 | string $name = null, |
| 44 | - $routeParams = [], |
|
| 45 | - $queryParams = [], |
|
| 44 | + $routeParams = [ ], |
|
| 45 | + $queryParams = [ ], |
|
| 46 | 46 | bool $inherit = false |
| 47 | 47 | ): string { |
| 48 | 48 | $routeResult = $this->getCurrentRouteResult(); |
@@ -50,12 +50,12 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | if (is_bool($routeParams)) { |
| 52 | 52 | $inherit = $routeParams; |
| 53 | - $routeParams = []; |
|
| 53 | + $routeParams = [ ]; |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | if (is_bool($queryParams)) { |
| 57 | 57 | $inherit = $queryParams; |
| 58 | - $queryParams = []; |
|
| 58 | + $queryParams = [ ]; |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | if ($inherit) { |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | $queryString = empty($queryParams) ? '' : sprintf('?%s', http_build_query($queryParams)); |
| 67 | - return $this->router->generateUri($name, $routeParams) . $queryString; |
|
| 67 | + return $this->router->generateUri($name, $routeParams).$queryString; |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |