Rajout de doctrine/orm
[zf2.biz/application_blanche.git] / vendor / doctrine / orm / tests / Doctrine / Tests / Models / StockExchange / Bond.php
diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/StockExchange/Bond.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/StockExchange/Bond.php
new file mode 100644 (file)
index 0000000..c8d6617
--- /dev/null
@@ -0,0 +1,48 @@
+<?php
+namespace Doctrine\Tests\Models\StockExchange;
+
+use Doctrine\Common\Collections\ArrayCollection;
+
+/**
+ * Bonds have many stocks. This uses a many to many assocation and fails to model how many of a
+ * particular stock a bond has. But i Need a many-to-many assocation, so please bear with my modelling skills ;)
+ *
+ * @Entity
+ * @Table(name="exchange_bonds")
+ */
+class Bond
+{
+    /**
+     * @Id @GeneratedValue @column(type="integer")
+     * @var int
+     */
+    private $id;
+
+    /**
+     * @column(type="string")
+     * @var string
+     */
+    private $name;
+
+    /**
+     * @ManyToMany(targetEntity="Stock", indexBy="symbol")
+     * @JoinTable(name="exchange_bonds_stocks")
+     * @var Stock[]
+     */
+    public $stocks;
+
+    public function __construct($name)
+    {
+        $this->name = $name;
+    }
+
+    public function getId()
+    {
+        return $this->id;
+    }
+
+    public function addStock(Stock $stock)
+    {
+        $this->stocks[$stock->getSymbol()] = $stock;
+    }
+}
\ No newline at end of file