Commit 6cf036da authored by Avris's avatar Avris

Modernise to 4.0

parent 0dc11148
Avris\Micrus\Doctrine\: Avris\Micrus\Doctrine\:
dir: '%MODULE_DIR%/src/' dir: '%MODULE_DIR%/src/'
Avris\Micrus\Doctrine\Doctrine: Avris\Micrus\Doctrine\DoctrineManager:
arguments: arguments:
$proxyDir: '%CACHE_DIR%/doctrine' $proxyDir: '%CACHE_DIR%/doctrine'
...@@ -10,5 +10,5 @@ Avris\Micrus\Doctrine\DoctrineUserProvider: ...@@ -10,5 +10,5 @@ Avris\Micrus\Doctrine\DoctrineUserProvider:
public: true public: true
Doctrine\ORM\EntityManagerInterface: Doctrine\ORM\EntityManagerInterface:
resolve: '@Avris\Micrus\Doctrine\Doctrine.entityManager' resolve: '@Avris\Micrus\Doctrine\DoctrineManager.entityManager'
public: true public: true
...@@ -5,10 +5,10 @@ use Doctrine\DBAL\Logging\SQLLogger; ...@@ -5,10 +5,10 @@ use Doctrine\DBAL\Logging\SQLLogger;
use Monolog\Logger; use Monolog\Logger;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
class DoctrineLogger implements SQLLogger final class DoctrineLogger implements SQLLogger
{ {
/** @var LoggerInterface */ /** @var LoggerInterface */
protected $logger; private $logger;
public function __construct(LoggerInterface $logger) public function __construct(LoggerInterface $logger)
{ {
......
...@@ -16,7 +16,7 @@ use Psr\Log\LoggerInterface; ...@@ -16,7 +16,7 @@ use Psr\Log\LoggerInterface;
use Doctrine\ORM\Tools\Console\Command as ORMCommand; use Doctrine\ORM\Tools\Console\Command as ORMCommand;
use Doctrine\DBAL\Tools\Console\Command as DBALCommand; use Doctrine\DBAL\Tools\Console\Command as DBALCommand;
class Doctrine implements EventSubscriberInterface final class DoctrineManager implements EventSubscriberInterface
{ {
/** @var EntityManager */ /** @var EntityManager */
private $entityManager; private $entityManager;
...@@ -29,7 +29,8 @@ class Doctrine implements EventSubscriberInterface ...@@ -29,7 +29,8 @@ class Doctrine implements EventSubscriberInterface
LoggerInterface $logger, LoggerInterface $logger,
DoctrineLogger $doctrineLogger, DoctrineLogger $doctrineLogger,
Cache $cache = null Cache $cache = null
) { )
{
$dirs = []; $dirs = [];
/** @var ModuleInterface $module */ /** @var ModuleInterface $module */
foreach (array_reverse($modules) as $module) { foreach (array_reverse($modules) as $module) {
......
...@@ -8,7 +8,7 @@ use Doctrine\ORM\EntityManager; ...@@ -8,7 +8,7 @@ use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Mapping\MappingException; use Doctrine\ORM\Mapping\MappingException;
class DoctrineMatchProvider implements MatchProvider final class DoctrineMatchProvider implements MatchProvider
{ {
/** @var EntityManager */ /** @var EntityManager */
private $em; private $em;
......
...@@ -5,7 +5,7 @@ use Avris\Micrus\Bootstrap\ModuleInterface; ...@@ -5,7 +5,7 @@ use Avris\Micrus\Bootstrap\ModuleInterface;
use Avris\Micrus\Bootstrap\ModuleTrait; use Avris\Micrus\Bootstrap\ModuleTrait;
use Avris\Micrus\Tool\Config\ParametersProvider; use Avris\Micrus\Tool\Config\ParametersProvider;
class DoctrineModule implements ModuleInterface, ParametersProvider final class DoctrineModule implements ModuleInterface, ParametersProvider
{ {
use ModuleTrait; use ModuleTrait;
......
...@@ -5,25 +5,27 @@ use Avris\Micrus\Model\User\UserProviderInterface; ...@@ -5,25 +5,27 @@ use Avris\Micrus\Model\User\UserProviderInterface;
use Avris\Micrus\Model\User\UserInterface; use Avris\Micrus\Model\User\UserInterface;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
class DoctrineUserProvider implements UserProviderInterface final class DoctrineUserProvider implements UserProviderInterface
{ {
/** @var EntityManagerInterface */ /** @var EntityManagerInterface */
protected $em; private $em;
/** @var string */ /** @var string */
protected $column; private $entity;
public function __construct(EntityManagerInterface $em, $column = 'email') /** @var string */
private $column;
public function __construct(EntityManagerInterface $em, $entity = 'App\Entity\User', $column = 'email')
{ {
$this->em = $em; $this->em = $em;
$this->entity = $entity;
$this->column = $column; $this->column = $column;
} }
public function getUser(string $identifier): ?UserInterface public function getUser(string $identifier): ?UserInterface
{ {
$this->column = 'username'; // TODO return $this->em->getRepository($this->entity)
return $this->em->getRepository('App\Entity\User') // TODO
->findOneBy([$this->column => $identifier]); ->findOneBy([$this->column => $identifier]);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment