From dc9c50aaeae9b97908f452ee3078696137475854 Mon Sep 17 00:00:00 2001 From: Antoine Descamps Date: Thu, 26 Oct 2023 09:49:48 +0200 Subject: [PATCH] Added more context for service's named arguments --- development/naming-conventions/_index.md | 9 ++++++--- modules/concepts/services/_index.md | 6 ++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/development/naming-conventions/_index.md b/development/naming-conventions/_index.md index f52abac55f..877c00ab08 100644 --- a/development/naming-conventions/_index.md +++ b/development/naming-conventions/_index.md @@ -192,8 +192,7 @@ services: ### Named arguments -**Do NOT** use "named argument" syntax in service declaration: - +**Do NOT** use "named argument" syntax in your front services declaration: ```yaml services: @@ -206,9 +205,13 @@ services: wrong_foo_bar: class: 'Foo\Bar' arguments: - - $baz: 'baz' + $baz: 'baz' ``` +If you do try to use named arguments in your front services definition you will end up with the following error: + +> Fatal error: Uncaught Symfony\Component\DependencyInjection\Exception\RuntimeException: Invalid service "wrong_foo_bar": class "Foo\Bar" does not exist. + ## Grid PrestaShop comes with a lot of Grids (Products, Customers, Orders & etc) and keeping consistency between them is very important, thats why it follows these naming conventions: diff --git a/modules/concepts/services/_index.md b/modules/concepts/services/_index.md index 3703df0070..e9bfd1372a 100644 --- a/modules/concepts/services/_index.md +++ b/modules/concepts/services/_index.md @@ -396,6 +396,12 @@ files in sub folders: - `config/admin/services.yml` will define the services accessible in the back office (in legacy environment AND Symfony environment) - `config/front/services.yml` will define the services accessible in the front office +{{% notice warning %}} +**Do not use named arguments for front services definition** + +For more information read the dedicated section in [Naming Conventions]({{< ref "8/development/naming-conventions/#named-arguments" >}}). +{{% /notice %}} + ### Accessing your services You can then access your services from any legacy controllers (in which the container is automatically injected):