Your colleague installed KnpTimeBundle into your app to use |ago
Twig filter in templates. You also want to leverage this "ago" format but inside a controller. In the bundle's docs you found that you can do it by calling formatDiff()
method on the time.datetime_formatter
service.
How could you inject that service into your controller if the output of bin/console debug:autowiring
command is the next:
Autowirable Types
=================
The following classes & interfaces can be used as type-hints when autowiring:
App\Kernel (kernel)
EntityManager interface
Doctrine\ORM\EntityManagerInterface (doctrine.orm.default_entity_manager)
Doctrine\ORM\EntityManagerInterface $defaultEntityManager (doctrine.orm.default_entity_manager)
Knp\Bundle\TimeBundle\DateTimeFormatter (time.datetime_formatter)
PaginatorInterface
Knp\Component\Pager\PaginatorInterface (knp_paginator)
Describes a logger instance.
Psr\Log\LoggerInterface (monolog.logger)
Interface for mailers able to send emails synchronous and/or asynchronous.
Symfony\Component\Mailer\MailerInterface (mailer.mailer)
Symfony\Component\Serializer\SerializerInterface (debug.serializer)
Stores the Twig configuration and renders templates.
Twig\Environment (twig)
...
725 more concrete services would be displayed when adding the "--all" option.