Created
September 11, 2020 07:20
-
-
Save wowo/521ae30025367c1550cf2422efcc8031 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Example\FooBundle\Service; | |
use Doctrine\ORM\EntityRepository; | |
use Symfony\Component\HttpKernel\Log\LoggerInterface; | |
class FooService | |
{ | |
protected $fooRepository; | |
protected $logger; | |
public function __construct(EntityRepository $fooRepository, | |
LoggerInterface $logger) | |
{ | |
$this->fooRepository = $fooRepository; | |
$this->logger = $logger; | |
} | |
public function query() | |
{ | |
$results = $this->fooRepository->findAll(); | |
$this->logger->info(sprintf('Someone fetched %s foos', | |
count($results))); | |
return $results; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment