Skip to content

Commit

Permalink
Added more context for service's named arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
devantoine committed Oct 26, 2023
1 parent ccce7fd commit dc9c50a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
9 changes: 6 additions & 3 deletions development/naming-conventions/_index.md
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
6 changes: 6 additions & 0 deletions modules/concepts/services/_index.md
Expand Up @@ -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):
Expand Down

0 comments on commit dc9c50a

Please sign in to comment.