@@ -224,7 +224,49 @@ $loader = new Psr4ClassLoader();
224
224
$loader->addPrefix('Ajax\\', __DIR__.'/lib/phpmv/php-mv-ui/Ajax');
225
225
$loader->register();
226
226
```
227
- #### Injection of the service
227
+
228
+
229
+ #### Symfony 4
230
+
231
+ Create a service inheriting from ` JquerySemantic `
232
+ ``` php
233
+ namespace App\Services\semantic;
234
+
235
+ use Ajax\php\symfony\JquerySemantic;
236
+
237
+ class SemanticGui extends JquerySemantic{
238
+ }
239
+ ```
240
+ Check that autowiring is activated in ** config/services.yml** :
241
+ ``` yml
242
+ services :
243
+ # default configuration for services in *this* file
244
+ _defaults :
245
+ autowire : true # Automatically injects dependencies in your services.
246
+ ` ` `
247
+ You can then use dependency injection on properties, constructors or setters:
248
+
249
+ ` ` ` php
250
+ namespace App\Controller;
251
+
252
+ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
253
+ use App\Services\semantic\SemanticGui;
254
+
255
+ BarController extends AbstractController{
256
+ /**
257
+ * @var SemanticGui
258
+ */
259
+ protected $gui;
260
+
261
+ public function loadViewWithAjaxButtonAction(){
262
+ $bt=$this->gui->semantic()->htmlButton('button1','a button');
263
+ $bt->getOnClick("/url",'#responseElement');
264
+ return $this->gui->renderView("barView.html.twig");
265
+ }
266
+ }
267
+ ```
268
+ #### Symfony 3
269
+ ##### Injection of the service
228
270
Create 2 services in the ** app/config/services.yml** file :
229
271
* The first for the JsUtils instance
230
272
* The second for the controller
0 commit comments