Skip to content

Commit 333d589

Browse files
committed
minor #9720 Removed all remaining Action() method suffixes (javiereguiluz)
This PR was merged into the 4.0 branch. Discussion ---------- Removed all remaining Action() method suffixes This is a continuation of #9703 and removes all the remaining `Action()` suffixes in controller actions. Commits ------- 0adb9aa Removed all remaining Action() method suffixes
2 parents 40e2222 + 0adb9aa commit 333d589

19 files changed

+41
-41
lines changed

configuration/micro_kernel_trait.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ Next, create an ``index.php`` file that defines the kernel class and executes it
5555
{
5656
// kernel is a service that points to this class
5757
// optional 3rd argument is the route name
58-
$routes->add('/random/{limit}', 'kernel:randomAction');
58+
$routes->add('/random/{limit}', 'kernel:randomNumber');
5959
}
6060

61-
public function randomAction($limit)
61+
public function randomNumber($limit)
6262
{
6363
return new JsonResponse(array(
6464
'number' => rand(0, $limit)
@@ -257,7 +257,7 @@ has one file in it::
257257
/**
258258
* @Route("/random/{limit}")
259259
*/
260-
public function randomAction($limit)
260+
public function randomNumber($limit)
261261
{
262262
$number = rand(0, $limit);
263263

console/command_in_controller.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Run this command from inside your controller via::
3636

3737
class SpoolController extends Controller
3838
{
39-
public function sendSpoolAction($messages = 10, KernelInterface $kernel)
39+
public function sendSpool($messages = 10, KernelInterface $kernel)
4040
{
4141
$application = new Application($kernel);
4242
$application->setAutoExit(false);
@@ -87,7 +87,7 @@ Now, use it in your controller::
8787

8888
class SpoolController extends Controller
8989
{
90-
public function sendSpoolAction($messages = 10)
90+
public function sendSpool($messages = 10)
9191
{
9292
// ...
9393
$output = new BufferedOutput(

controller.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ Streaming File Responses
616616
You can use the :method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller::file`
617617
helper to serve a file from inside a controller::
618618

619-
public function fileAction()
619+
public function download()
620620
{
621621
// send the file contents and force the browser to download it
622622
return $this->file('/path/to/some_file.pdf');
@@ -627,7 +627,7 @@ The ``file()`` helper provides some arguments to configure its behavior::
627627
use Symfony\Component\HttpFoundation\File\File;
628628
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
629629

630-
public function fileAction()
630+
public function download()
631631
{
632632
// load the file from the filesystem
633633
$file = new File('/path/to/some_file.pdf');

create_framework/http_kernel_controller_resolver.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class::
1010

1111
class LeapYearController
1212
{
13-
public function indexAction($request)
13+
public function index($request)
1414
{
1515
if (is_leap_year($request->attributes->get('year'))) {
1616
return new Response('Yep, this is a leap year!');
@@ -99,39 +99,39 @@ following interface::
9999
public function getArguments(Request $request, $controller);
100100
}
101101

102-
The ``indexAction()`` method needs the Request object as an argument.
102+
The ``index()`` method needs the Request object as an argument.
103103
``getArguments()`` knows when to inject it properly if it is type-hinted
104104
correctly::
105105

106-
public function indexAction(Request $request)
106+
public function index(Request $request)
107107

108108
// won't work
109-
public function indexAction($request)
109+
public function index($request)
110110

111111
More interesting, ``getArguments()`` is also able to inject any Request
112112
attribute; the argument just needs to have the same name as the corresponding
113113
attribute::
114114

115-
public function indexAction($year)
115+
public function index($year)
116116

117117
You can also inject the Request and some attributes at the same time (as the
118118
matching is done on the argument name or a type hint, the arguments order does
119119
not matter)::
120120

121-
public function indexAction(Request $request, $year)
121+
public function index(Request $request, $year)
122122

123-
public function indexAction($year, Request $request)
123+
public function index($year, Request $request)
124124

125125
Finally, you can also define default values for any argument that matches an
126126
optional attribute of the Request::
127127

128-
public function indexAction($year = 2012)
128+
public function index($year = 2012)
129129

130130
Let's just inject the ``$year`` request attribute for our controller::
131131

132132
class LeapYearController
133133
{
134-
public function indexAction($year)
134+
public function index($year)
135135
{
136136
if (is_leap_year($year)) {
137137
return new Response('Yep, this is a leap year!');

create_framework/http_kernel_httpkernel_class.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ The error controller reads as follows::
9696

9797
class ErrorController
9898
{
99-
public function exceptionAction(FlattenException $exception)
99+
public function exception(FlattenException $exception)
100100
{
101101
$msg = 'Something went wrong! ('.$exception->getMessage().')';
102102

@@ -134,7 +134,7 @@ instead of a full Response object::
134134

135135
class LeapYearController
136136
{
137-
public function indexAction(Request $request, $year)
137+
public function index(Request $request, $year)
138138
{
139139
$leapYear = new LeapYear();
140140
if ($leapYear->isLeapYear($year)) {

create_framework/http_kernel_httpkernelinterface.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ PHP; it implements ``HttpKernelInterface`` and wraps another
5454
``HttpKernelInterface`` instance::
5555

5656
// example.com/web/front.php
57-
57+
5858
// ..
5959

6060
$framework = new Simplex\Framework($dispatcher, $matcher, $controllerResolver, $argumentResolver);
@@ -74,7 +74,7 @@ to cache a response for 10 seconds, use the ``Response::setTtl()`` method::
7474
// example.com/src/Calendar/Controller/LeapYearController.php
7575

7676
// ...
77-
public function indexAction(Request $request, $year)
77+
public function index(Request $request, $year)
7878
{
7979
$leapYear = new LeapYear();
8080
if ($leapYear->isLeapYear($year)) {

create_framework/separation_of_concerns.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ Move the controller to ``Calendar\Controller\LeapYearController``::
106106

107107
class LeapYearController
108108
{
109-
public function indexAction(Request $request, $year)
109+
public function index(Request $request, $year)
110110
{
111111
$leapYear = new LeapYear();
112112
if ($leapYear->isLeapYear($year)) {

doctrine.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ be able to go to ``/product/1`` to see your new product::
402402
/**
403403
* @Route("/product/{id}", name="product_show")
404404
*/
405-
public function showAction($id)
405+
public function show($id)
406406
{
407407
$product = $this->getDoctrine()
408408
->getRepository(Product::class)
@@ -491,7 +491,7 @@ Now, simplify your controller::
491491
/**
492492
* @Route("/product/{id}", name="product_show")
493493
*/
494-
public function showAction(Product $product)
494+
public function show(Product $product)
495495
{
496496
// use the Product!
497497
// ...
@@ -510,7 +510,7 @@ Once you've fetched an object from Doctrine, updating it is easy::
510510
/**
511511
* @Route("/product/edit/{id}")
512512
*/
513-
public function updateAction($id)
513+
public function update($id)
514514
{
515515
$entityManager = $this->getDoctrine()->getManager();
516516
$product = $entityManager->getRepository(Product::class)->find($id);

doctrine/associations.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ did before. First, fetch a ``$product`` object and then access its related
370370
use App\Entity\Product;
371371
// ...
372372

373-
public function showAction($id)
373+
public function show($id)
374374
{
375375
$product = $this->getDoctrine()
376376
->getRepository(Product::class)
@@ -400,7 +400,7 @@ the category (i.e. it's "lazily loaded").
400400
Because we mapped the optional ``OneToMany`` side, you can also query in the other
401401
direction::
402402

403-
public function showProductsAction($id)
403+
public function showProducts($id)
404404
{
405405
$category = $this->getDoctrine()
406406
->getRepository(Category::class)
@@ -481,7 +481,7 @@ This will *still* return an array of ``Product`` objects. But now, when you call
481481
Now, you can use this method in your controller to query for a ``Product``
482482
object and its related ``Category`` with just one query::
483483

484-
public function showAction($id)
484+
public function show($id)
485485
{
486486
$product = $this->getDoctrine()
487487
->getRepository(Product::class)

doctrine/dbal.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ object::
4747

4848
class UserController extends Controller
4949
{
50-
public function indexAction(Connection $connection)
50+
public function index(Connection $connection)
5151
{
5252
$users = $connection->fetchAll('SELECT * FROM users');
5353

0 commit comments

Comments
 (0)