File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed
Filter options
Expand file tree Collapse file tree 1 file changed +5
-4
lines changed
Original file line number Diff line number Diff line change @@ -81,7 +81,7 @@ Next, define a new service for that class.
81
81
# app/config/services.yml
82
82
services :
83
83
# keep your service names short
84
- slugger :
84
+ app. slugger :
85
85
class : AppBundle\Utils\Slugger
86
86
87
87
Traditionally, the naming convention for a service involved following the
@@ -92,7 +92,8 @@ your code will be easier to read and use.
92
92
.. best-practice ::
93
93
94
94
The name of your application's services should be as short as possible,
95
- ideally just one simple word.
95
+ but unique enough that you can search your project for the service if
96
+ you ever need to.
96
97
97
98
Now you can use the custom slugger in any controller class, such as the
98
99
``AdminController ``:
@@ -104,7 +105,7 @@ Now you can use the custom slugger in any controller class, such as the
104
105
// ...
105
106
106
107
if ($form->isSubmitted() && $form->isValid()) {
107
- $slug = $this->get('slugger')->slugify($post->getTitle());
108
+ $slug = $this->get('app. slugger')->slugify($post->getTitle());
108
109
$post->setSlug($slug);
109
110
110
111
// ...
@@ -143,7 +144,7 @@ the class namespace as a parameter:
143
144
slugger.class : AppBundle\Utils\Slugger
144
145
145
146
services :
146
- slugger :
147
+ app. slugger :
147
148
class : " %slugger.class%"
148
149
149
150
This practice is cumbersome and completely unnecessary for your own services:
You can’t perform that action at this time.
0 commit comments