master
Xantxo COQUILLARD 3 years ago
parent 3c646640dc
commit c8c3b42b0e

@ -7,15 +7,19 @@
"php": ">=8.0.2", "php": ">=8.0.2",
"ext-ctype": "*", "ext-ctype": "*",
"ext-iconv": "*", "ext-iconv": "*",
"doctrine/annotations": "^1.13",
"doctrine/doctrine-bundle": "^2.6",
"doctrine/doctrine-migrations-bundle": "^3.2",
"doctrine/orm": "^2.11",
"symfony/console": "6.0.*", "symfony/console": "6.0.*",
"symfony/dotenv": "6.0.*", "symfony/dotenv": "6.0.*",
"symfony/expression-language": "6.0.*",
"symfony/flex": "^2", "symfony/flex": "^2",
"symfony/framework-bundle": "6.0.*", "symfony/framework-bundle": "6.0.*",
"symfony/proxy-manager-bridge": "6.0.*",
"symfony/runtime": "6.0.*", "symfony/runtime": "6.0.*",
"symfony/yaml": "6.0.*" "symfony/yaml": "6.0.*"
}, },
"require-dev": {
},
"config": { "config": {
"allow-plugins": { "allow-plugins": {
"composer/package-versions-deprecated": true, "composer/package-versions-deprecated": true,
@ -66,5 +70,8 @@
"allow-contrib": false, "allow-contrib": false,
"require": "6.0.*" "require": "6.0.*"
} }
},
"require-dev": {
"symfony/maker-bundle": "^1.38"
} }
} }

1975
composer.lock generated

File diff suppressed because it is too large Load Diff

@ -12,7 +12,7 @@ doctrine:
mappings: mappings:
App: App:
is_bundle: false is_bundle: false
dir: '%kernel.project_dir%/src/App/Composant' dir: '%kernel.project_dir%/src/Composant'
prefix: 'App\Composant' prefix: 'App\Composant'
alias: App alias: App

@ -1,5 +1,5 @@
controllers: controllers:
resource: ../src/App/Controller/ resource: ../src/Controller/
type: annotation type: annotation
kernel: kernel:

@ -3,6 +3,7 @@
namespace App\Composant\User\Domain; namespace App\Composant\User\Domain;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
/** /**
* @ORM\Entity * @ORM\Entity
* @ORM\Table(name="users") * @ORM\Table(name="users")

@ -4,8 +4,8 @@ namespace App\Composant\User\Infrastructure;
use App\Composant\User\Domain\User; use App\Composant\User\Domain\User;
use App\Composant\User\Domain\UserDataMapper; use App\Composant\User\Domain\UserDataMapper;
use Doctrine\Persistence\ManagerRegistry;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
use Exception; use Exception;
class DoctrineUser extends ServiceEntityRepository implements UserDataMapper class DoctrineUser extends ServiceEntityRepository implements UserDataMapper
@ -18,15 +18,16 @@ class DoctrineUser extends ServiceEntityRepository implements UserDataMapper
public function findById(int $id): User public function findById(int $id): User
{ {
$entityManager = $this->getEntityManager(); $user = $this->find($id);
$User = $entityManager->getRepository(User::class)->find($id);
if (!$User) { if (!$user)
{
throw new Exception( throw new Exception(
'L\'utilisateur n\'existe pas' 'L\'utilisateur n\'existe pas'
); );
} }
return $User; return $user;
} }
public function findAll(): array public function findAll(): array

@ -2,12 +2,11 @@
namespace App\Controller; namespace App\Controller;
use App\Composant\User\Domain\User;
use App\Composant\User\Infrastructure\DoctrineUser; use App\Composant\User\Infrastructure\DoctrineUser;
use Doctrine\Persistence\ManagerRegistry; use Doctrine\Persistence\ManagerRegistry;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use function dd;
class test extends AbstractController class test extends AbstractController
{ {
@ -16,16 +15,7 @@ class test extends AbstractController
{ {
} }
/** #[Route('/foo', name: 'contact')]
* @Route(
* "/contact",
* name="contact",
* condition="context.getMethod() in ['GET', 'HEAD'] and request.headers.get('User-Agent') matches '/firefox/i'"
* )
*
* expressions can also include configuration parameters:
* condition: "request.headers.get('User-Agent') matches '%app.allowed_browsers%'"
*/
public function index(ManagerRegistry $registry): Response public function index(ManagerRegistry $registry): Response
{ {
$DoctrineUser = new DoctrineUser($registry); $DoctrineUser = new DoctrineUser($registry);
Loading…
Cancel
Save