Skip to content

Commit

Permalink
Merge pull request #1739 from devantoine/patch-1
Browse files Browse the repository at this point in the history
Added more context for services named arguments
  • Loading branch information
matthieu-rolland authored Oct 26, 2023
2 parents ccce7fd + dc9c50a commit 80ef7ff
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 80ef7ff

Please sign in to comment.