kdyby / doctrinemoney Goto Github PK
View Code? Open in Web Editor NEW[DEPRECATED]
Home Page: https://packagist.org/packages/kdyby/doctrine-money
License: Other
[DEPRECATED]
Home Page: https://packagist.org/packages/kdyby/doctrine-money
License: Other
Lets have entities Test and its children Test1 and Test2. Test class have money field. Now lets have entity ClassWithRelation that has relation to Test class. In this case, when we try to load ClassWithRelation entity and we try to access money field using association, its int value, not money value.
If we change relation from "Test" to "Test1", it works perfectly.
Tested dependencies:
"kdyby/events": "~2.3",
"kdyby/doctrine": "~2.3",
"kdyby/money": "@dev",
"kdyby/doctrine-money": "@dev"
Tested entities:
namespace App\Entities;
use Doctrine\ORM\Mapping as ORM;
use Kdyby\Doctrine\Entities\BaseEntity;
use Kdyby\Money\Currency;
use Kdyby\Money\Money;
/**
* @ORM\Entity
* @ORM\Table(name="test_base")
* @ORM\InheritanceType("SINGLE_TABLE")
* @ORM\DiscriminatorColumn(name="type", type="string")
* @ORM\DiscriminatorMap({"test_1" = "Test1", "test_2" = "Test2"})
*/
abstract class Test extends BaseEntity {
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue
* @var integer
*/
protected $id;
/**
* @ORM\Column(type="money", options={"currency":"currency"})
* @var Money
*/
protected $amount;
/**
* @ORM\ManyToOne(targetEntity="Kdyby\Money\Currency")
* @ORM\JoinColumn(nullable=false, referencedColumnName="code")
* @var Currency
*/
protected $currency;
}
/**
* @ORM\Entity
*/
class Test1 extends Test {
}
/**
* @ORM\Entity
*/
class Test2 extends Test {
}
/**
* @ORM\Entity
* @ORM\Table(name="test_rel")
*/
class ClassWithRelation extends BaseEntity {
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue
* @var integer
*/
protected $id;
/**
* @ORM\OneToOne(targetEntity="App\Entities\Test")
* @ORM\JoinColumn(nullable=true)
* @var Test
*/
protected $test;
}
var_dump($this->em->find(ClassWithRelation::class, 1)->test->amount); // result is int
var_dump($this->em->find(Test1::class, 1)->amount); // result is Money
[Doctrine\ORM\Mapping\MappingException]
Entity Listener "Kdyby\DoctrineMoney\Mapping\MoneyObjectHydrationListener" declared on "MyClassWithMoneyField has no method "Doctrine\ORM\Event::postLoadRelations".
Since this commit Kdyby/Doctrine@5c416e3, events are namespaced. This is OK, but Kdyby\Doctrine\Events::postLoadRelations constant is used also for local method name (3rd parameter) in https://github.com/Kdyby/DoctrineMoney/blob/master/src/Kdyby/DoctrineMoney/Mapping/MoneyObjectHydrationListener.php#L201 .
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.