Symfony Service : Service is any PHP object that performs some sort of “global” task.
To access service in twig , you need to define service in config.yml files. Following is the example how to defined servies in config.yml :
twig: globals: test_service: "@test.service"
Now you service is globally accessible in twig, you can use service by simply
using the following statement:
{% set id = test_serive.getTestId() %}
Be the first to comment.