So Far, I've figured out two ways to inject services
Method A:
public function __construct($entityManager, $mailer, $templating,$notificationManager,$taskManager,$leadNotificationManager,$dealNotificationManager,$taskNotificationManager)
{
$this->mailer = $mailer;
$this->em = $entityManager;
$this->templating = $templating;
$this->notificationManager = $notificationManager;
$this->taskManager= $taskManager;
$this->leadNotificationManager = $leadNotificationManager;
$this->dealNotificationManager = $dealNotificationManager;
$this->taskNotificationManager = $notificationManager;
}
in that case I'll use the service as below
$this->mailer->send($message);
Method B:
public function __construct(ContainerInterface $container)
{
$this->container = $container;
}
and use it as below
$this->container->get('crm_sandbox_google_calendar')->markDone($entity)
method A looks more specific, but it limits the dependancy as Serivce A cant Include service B if service B includes service A [cycle]
Can someone explain the difference?