Git Product home page Git Product logo

doctrinemoney's People

Contributors

fprochazka avatar lm avatar mishak87 avatar stekycz avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

doctrinemoney's Issues

Money class is not processed - postLoadRelations is not called when abstract relation is used

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

Method not found after Kdyby/Doctrine update (namespace issue)

[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 .

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.