Skip to content

Commit a4d4787

Browse files
committed
Embed money objects
1 parent 074f836 commit a4d4787

File tree

8 files changed

+72
-50
lines changed

8 files changed

+72
-50
lines changed

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
"doctrine/doctrine-bundle": "^1.8",
2929
"doctrine/orm": "^2.3",
3030
"friendsofphp/php-cs-fixer": "^2.8",
31-
"moneyphp/money": "^3.2",
3231
"symfony/phpunit-bridge": "^3.4|^4.0",
3332
"symfony/process": "^3.4|^4.0",
3433
"symfony/yaml": "^3.4|^4.0"

tests/Maker/FunctionalTest.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,16 +1144,6 @@ public function getCommandEntityTests()
11441144
])
11451145
->setArgumentsString('--regenerate')
11461146
->setFixtureFilesPath(__DIR__.'/../fixtures/MakeEntityRegenerateEmbeddableObject')
1147-
->addReplacement(
1148-
'config/packages/doctrine.yaml',
1149-
'type: annotation',
1150-
'type: xml'
1151-
)
1152-
->addReplacement(
1153-
'config/packages/doctrine.yaml',
1154-
"dir: '%kernel.project_dir%/src/Entity'",
1155-
"dir: '%kernel.project_dir%/config/doctrine'"
1156-
)
11571147
->configureDatabase()
11581148
->setRequiredPhpVersion(70100)
11591149
];

tests/fixtures/MakeEntityRegenerateEmbeddableObject/config/doctrine/Currency.orm.xml

Lines changed: 0 additions & 13 deletions
This file was deleted.

tests/fixtures/MakeEntityRegenerateEmbeddableObject/config/doctrine/Invoice.orm.xml

Lines changed: 0 additions & 15 deletions
This file was deleted.

tests/fixtures/MakeEntityRegenerateEmbeddableObject/config/doctrine/Money.orm.xml

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
namespace App\Entity;
4+
5+
use Doctrine\ORM\Mapping as ORM;
6+
7+
/**
8+
* @ORM\Embeddable()
9+
*/
10+
class Currency
11+
{
12+
/**
13+
* @var string
14+
*
15+
* @ORM\Column(name="currency", type="string")
16+
*/
17+
private $currency;
18+
19+
public function __construct($currency)
20+
{
21+
$this->currency = $currency;
22+
}
23+
24+
/**
25+
* @return string
26+
*/
27+
public function getCurrency()
28+
{
29+
return $this->currency;
30+
}
31+
32+
/**
33+
* @param string $currency
34+
* @return Currency
35+
*/
36+
public function setCurrency($currency)
37+
{
38+
$this->currency = $currency;
39+
return $this;
40+
}
41+
42+
43+
}

tests/fixtures/MakeEntityRegenerateEmbeddableObject/src/Entity/Invoice.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Invoice
2222
private $title;
2323

2424
/**
25-
* @ORM\Embedded(class="Money\Money")
25+
* @ORM\Embedded(class="App\Entity\Money")
2626
*/
2727
private $total;
2828
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace App\Entity;
4+
5+
use Doctrine\ORM\Mapping as ORM;
6+
7+
class Money
8+
{
9+
/**
10+
* @var Currency
11+
*
12+
* @ORM\Embedded(class="App\Entity\Currency")
13+
*/
14+
private $currency;
15+
16+
/**
17+
* @var int
18+
*
19+
* @ORM\Column(name="amount", type="integer")
20+
*/
21+
private $amount;
22+
23+
public function __construct($amount, Currency $currency)
24+
{
25+
$this->amount = $amount;
26+
$this->currency = $currency;
27+
}
28+
}

0 commit comments

Comments
 (0)