Skip to content

Commit

Permalink
[ci skip] Update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
mbabker committed Aug 17, 2023
1 parent 9036d2c commit 2d2e8d4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 27 deletions.
21 changes: 8 additions & 13 deletions docs/doctrine.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ When used with an application where the [Doctrine MongoDB ODM](https://www.doctr

All that is required is to define a field on your document as an embedded field with the `Money\Money` type, such as the below example document:

<div class="docs-note docs-note--tip">The below example uses PHP 8 Attributes, but you can use any of the ODM's mapping drivers in your application.</div>

```php
<?php

Expand All @@ -14,14 +16,10 @@ namespace App\Document;
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
use Money\Money;

/**
* @ODM\Document()
*/
#[ODM\Document]
class Invoice
{
/**
* @ODM\EmbedOne(targetDocument="Money\Money")
*/
#[ODM\EmbedOne(targetDocument: Money::class)]
public Money $tax_due;

public function __construct()
Expand All @@ -37,6 +35,8 @@ When used with an application where the [Doctrine ORM](https://www.doctrine-proj

All that is required is to define a field on your entity as an embedded field with the `Money\Money` type, such as the below example entity:

<div class="docs-note docs-note--tip">The below example uses PHP 8 Attributes, but you can use any of the ORM's mapping drivers in your application.</div>

```php
<?php

Expand All @@ -45,15 +45,10 @@ namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Money\Money;

/**
* @ORM\Entity()
* @ORM\Table()
*/
#[ORM\Entity]
class Invoice
{
/**
* @ORM\Embedded(class="Money\Money")
*/
#[ORM\Embedded(class: Money::class)]
public Money $tax_due;

public function __construct()
Expand Down
4 changes: 1 addition & 3 deletions docs/serializer.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ use Symfony\Component\Routing\Annotation\Route;

final class MoneyCalculatorController extends AbstractController
{
/**
* @Route("/api/money/add", name="app_api_add_money", methods={"POST"})
*/
#[Route(path: '/api/money/add', name: 'app_api_add_money', methods: ['POST'])]
public function apiAddValues(Request $request): JsonResponse
{
$firstValue = $request->request->getInt('first_value');
Expand Down
12 changes: 1 addition & 11 deletions docs/validator.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ use Money\Money;

/**
* @ORM\Entity()
* @ORM\Table()
*/
class Invoice
{
Expand Down Expand Up @@ -95,7 +94,6 @@ use Doctrine\ORM\Mapping as ORM;
use Money\Money;

#[ORM\Entity]
#[ORM\Table]
class Invoice
{
#[ORM\Embedded(class: Money::class]
Expand All @@ -114,22 +112,14 @@ class Invoice
```php
<?php

namespace App\Entity;
namespace App\Model;

use BabDev\MoneyBundle\Validator\Constraints as MoneyAssert;
use Doctrine\ORM\Mapping as ORM;
use Money\Money;
use Symfony\Component\Validator\Mapping\ClassMetadata;

/**
* @ORM\Entity()
* @ORM\Table()
*/
class Invoice
{
/**
* @ORM\Embedded(class="Money\Money")
*/
public Money $tax_due;

public function __construct()
Expand Down

0 comments on commit 2d2e8d4

Please sign in to comment.