April 2016
Intermediate to advanced
290 pages
5h 51m
English
We have called a service in our project before. To know the answer, open mava/src/AppBundle/Controller/DashboardController.php and note two things:
<?php
namespace AppBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class DashboardController extends Controller
{
public function indexAction()
{
$uId = $this->getUser()->getId();
$util = $this->get('mava_util');
//...
}
}First, this class extends Symfony's Controller class. Secondly, spot the get(mava_util) method at line 9. This method is in charge of calling services and is defined in the Controller.php class as follows:
/** * Gets a container service by its id. * @param string $id The service id * @return object The service */ public function get($id) ...