Skip to content

Commit b091697

Browse files
committed
minor #9152 Fix action name in controller (orions)
This PR was merged into the master branch. Discussion ---------- Fix action name in controller Fix action name in controller according to best practices of Symfony 4.0 Commits ------- 9154bc1 Fix action name in controller
2 parents 43fff9b + 9154bc1 commit b091697

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

controller.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ and ``redirect()`` methods::
145145
use Symfony\Component\HttpFoundation\RedirectResponse;
146146

147147
// ...
148-
public function indexAction()
148+
public function index()
149149
{
150150
// redirect to the "homepage" route
151151
return $this->redirectToRoute('homepage');
@@ -209,7 +209,7 @@ If you need a service in a controller, just type-hint an argument with its class
209209
/**
210210
* @Route("/lucky/number/{max}")
211211
*/
212-
public function numberAction($max, LoggerInterface $logger)
212+
public function number($max, LoggerInterface $logger)
213213
{
214214
$logger->info('We are logging!');
215215
// ...
@@ -303,7 +303,7 @@ special type of exception::
303303
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
304304

305305
// ...
306-
public function indexAction()
306+
public function index()
307307
{
308308
// retrieve the object from database
309309
$product = ...;
@@ -348,7 +348,7 @@ object. To get it in your controller, just add it as an argument and
348348

349349
use Symfony\Component\HttpFoundation\Request;
350350

351-
public function indexAction(Request $request, $firstName, $lastName)
351+
public function index(Request $request, $firstName, $lastName)
352352
{
353353
$page = $request->query->get('page', 1);
354354

@@ -392,7 +392,7 @@ To get the session, add an argument and type-hint it with
392392

393393
use Symfony\Component\HttpFoundation\Session\SessionInterface;
394394

395-
public function indexAction(SessionInterface $session)
395+
public function index(SessionInterface $session)
396396
{
397397
// store an attribute for reuse during a later user request
398398
$session->set('foo', 'bar');
@@ -432,7 +432,7 @@ For example, imagine you're processing a :doc:`form </forms>` submission::
432432

433433
use Symfony\Component\HttpFoundation\Request;
434434

435-
public function updateAction(Request $request)
435+
public function update(Request $request)
436436
{
437437
// ...
438438

@@ -524,7 +524,7 @@ the ``Request`` class::
524524

525525
use Symfony\Component\HttpFoundation\Request;
526526

527-
public function indexAction(Request $request)
527+
public function index(Request $request)
528528
{
529529
$request->isXmlHttpRequest(); // is it an Ajax request?
530530

@@ -579,7 +579,7 @@ To return JSON from a controller, use the ``json()`` helper method. This returns
579579
special ``JsonResponse`` object that encodes the data automatically::
580580

581581
// ...
582-
public function indexAction()
582+
public function index()
583583
{
584584
// returns '{"username":"jane.doe"}' and sets the proper Content-Type header
585585
return $this->json(array('username' => 'jane.doe'));

0 commit comments

Comments
 (0)