Skip to content

Instantly share code, notes, and snippets.

@wowo
Created September 11, 2020 06:56
Show Gist options
  • Save wowo/df4d044143260ee70dbe7dc8c58924a4 to your computer and use it in GitHub Desktop.
Save wowo/df4d044143260ee70dbe7dc8c58924a4 to your computer and use it in GitHub Desktop.
<?php
namespace Example\FooBundle\Service;
use Doctrine\ORM\EntityRepository;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
class FooService
{
protected $fooRepository;
protected $logger;
public function __construct(
FooRepositoryInterface $fooRepository,
LoggerInterface $logger
) {
$this->fooRepository = $fooRepository;
$this->logger = $logger;
}
public function query()
{
$results = $this->fooRepository->fetchLatest();
$this->logger->info(
sprintf('Someone fetched %d foos',
count($results)));
return $results;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment