-
Notifications
You must be signed in to change notification settings - Fork 231
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add DocumentValueResolver and MapDocument (#774)
* Add Symfony 6.3 to the test matrix * Introduce DocumentValueResolver and MapDocument
- Loading branch information
Showing
14 changed files
with
560 additions
and
51 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\Bundle\MongoDBBundle\ArgumentResolver; | ||
|
||
use Symfony\Bridge\Doctrine\ArgumentResolver\EntityValueResolver; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpKernel\Controller\ValueResolverInterface; | ||
use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata; | ||
|
||
/** @internal */ | ||
final class DocumentValueResolver implements ValueResolverInterface | ||
{ | ||
public function __construct( | ||
private EntityValueResolver $entityValueResolver, | ||
) { | ||
} | ||
|
||
public function resolve(Request $request, ArgumentMetadata $argument): array | ||
{ | ||
return $this->entityValueResolver->resolve($request, $argument); | ||
} | ||
} |
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,27 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\Bundle\MongoDBBundle\Attribute; | ||
|
||
use Attribute; | ||
use Doctrine\Bundle\MongoDBBundle\ArgumentResolver\DocumentValueResolver; | ||
use Symfony\Bridge\Doctrine\Attribute\MapEntity; | ||
|
||
#[Attribute(Attribute::TARGET_PARAMETER)] | ||
class MapDocument extends MapEntity | ||
{ | ||
public function __construct( | ||
public ?string $class = null, | ||
public ?string $objectManager = null, | ||
public ?string $expr = null, | ||
public ?array $mapping = null, | ||
public ?array $exclude = null, | ||
public ?bool $stripNull = null, | ||
public array|string|null $id = null, | ||
bool $disabled = false, | ||
string $resolver = DocumentValueResolver::class, | ||
) { | ||
parent::__construct($class, $objectManager, $expr, $mapping, $exclude, $stripNull, $id, null, $disabled, $resolver); | ||
} | ||
} |
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,20 @@ | ||
<?xml version="1.0" ?> | ||
|
||
<container xmlns="http://symfony.com/schema/dic/services" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> | ||
|
||
<services> | ||
<service id="doctrine_mongodb.odm.entity_value_resolver" class="Symfony\Bridge\Doctrine\ArgumentResolver\EntityValueResolver"> | ||
<argument type="service" id="doctrine_mongodb" /> | ||
<argument type="service" id="doctrine_mongodb.odm.document_value_resolver.expression_language" on-invalid="ignore" /> | ||
</service> | ||
|
||
<service id="doctrine_mongodb.odm.document_value_resolver.expression_language" class="Symfony\Component\ExpressionLanguage\ExpressionLanguage" /> | ||
|
||
<service id="doctrine_mongodb.odm.document_value_resolver" class="Doctrine\Bundle\MongoDBBundle\ArgumentResolver\DocumentValueResolver"> | ||
<argument type="service" id="doctrine_mongodb.odm.entity_value_resolver" /> | ||
<tag name="Doctrine\Bundle\MongoDBBundle\ArgumentResolver\DocumentValueResolver" priority="110">controller.argument_value_resolver</tag> | ||
</service> | ||
</services> | ||
</container> |
Oops, something went wrong.