-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FrameworkExtraBundle] Support for odm/orm manager registry
- Loading branch information
Showing
14 changed files
with
634 additions
and
2 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace App\Controller\Api; | ||
|
||
use App\Document\TestDocument; | ||
use Doctrine\Persistence\ManagerRegistry; | ||
use Draw\Component\OpenApi\Request\ValueResolver\RequestBody; | ||
use Symfony\Component\Routing\Attribute\Route; | ||
|
||
#[Route('/test-documents', name: 'testDocument')] | ||
class TestDocumentController | ||
{ | ||
public function __construct(private ManagerRegistry $odmManagerRegistry) | ||
{ | ||
} | ||
|
||
#[Route(name: 'Create', methods: ['POST'])] | ||
public function create( | ||
#[RequestBody] | ||
TestDocument $testDocument, | ||
): TestDocument { | ||
$manager = $this->odmManagerRegistry->getManagerForClass(TestDocument::class); | ||
|
||
$manager->persist($testDocument); | ||
|
||
$manager->flush(); | ||
|
||
return $testDocument; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
namespace App\Document; | ||
|
||
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; | ||
|
||
#[ODM\Document] | ||
class TestDocument | ||
{ | ||
#[ODM\Id] | ||
public string $id; | ||
} |
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
Oops, something went wrong.