You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Follow the prompts to add an action file to your add-on.
27
27
28
28
29
-
This will create an `Actions` folder inside our `Module` folder where will build out the code we want to run when a user hits our `ACT` URL. Inside our `Actions` folder the CLI will create a file with the same name as the method we defined when creating our action.
29
+
This will create an `Actions` folder inside our add-on's folder where will build out the code we want to run when a user hits our `ACT` URL. Inside our `Actions` folder the CLI will create a file with the same name as the method we defined when creating our action.
30
30
31
31
```
32
32
amazing_add_on
33
-
┣ Module
34
-
┃ ┣ Actions
35
-
┃ ┃ ┗ [MethodName].php
33
+
┣ Actions
34
+
┃ ┗ [MethodName].php
36
35
┗...
37
36
```
38
37
@@ -92,7 +91,7 @@ On creation of an action, you can also specify to add it to the database after t
92
91
93
92
## Anatomy of An Action
94
93
95
-
Once we've added an action to our add-on, an `Actions` folder is created inside our add-on's `Module` folder. The CLI will generate a class and respective file for us based on the action name we passed to the CLI when creating our action. In this case we added an action named "ExampleAction" to Amazing Add-on.
94
+
Once we've added an action to our add-on, an `Actions` folder is created for us. The CLI will generate a class and respective file for us based on the action name we passed to the CLI when creating our action. In this case we added an action named "ExampleAction" to Amazing Add-on.
96
95
97
96
```
98
97
php system/ee/eecli.php make:action
@@ -103,21 +102,20 @@ Action created successfully!
103
102
104
103
```
105
104
amazing_add_on
106
-
┣ Module
107
-
┃ ┣ Actions
108
-
┃ ┃ ┗ ExampleAction.php
105
+
┣ Actions
106
+
┃ ┗ ExampleAction.php
109
107
┗...
110
108
```
111
109
112
110
113
111
### class [ActionName]
114
112
115
-
Inside `Module/Actions/ExampleAction.php` we see the following code generated for us:
113
+
Inside `/Actions/ExampleAction.php` we see the following code generated for us:
use ExpressionEngine\Service\Addon\Controllers\Action\AbstractRoute;
123
121
@@ -148,7 +146,7 @@ The `exp_actions` table is comprised of 4 columns:
148
146
149
147
## Cross Site Request Forgery(CSRF) Exemption
150
148
151
-
WARN:**Security Alert:**Setting your action to CSRF EXempt, also makes this endpoint less secure though as you are allowing outside connections to your application.
149
+
WARN:**Security Alert:**Setting your action to CSRF Exempt, also makes this endpoint less secure though as you are allowing outside connections to your application.
152
150
153
151
For security reasons, actions are protected by [Cross Site Request Forgery(CSRF)](/development/guidelines/security.md#cross-site-request-forgery). If you want users to be able to reach this endpoint from outside your site (e.g. using cURL to from another domain or application to reach this endpoint and expect data to be returned ) then you will most likely need to make your action CSRF exempt.
154
152
@@ -195,12 +193,12 @@ This creates our required files.
195
193
196
194
Now we had some functionality to our action which will add the first and last name submitted from a form to our custom database table.
0 commit comments