Rajout de doctrine/orm
[zf2.biz/galerie.git] / vendor / doctrine / orm / tests / Doctrine / Tests / Models / Company / CompanyContract.php
1 <?php
2
3 namespace Doctrine\Tests\Models\Company;
4
5 /**
6  * @Entity
7  * @Table(name="company_contracts")
8  * @InheritanceType("SINGLE_TABLE")
9  * @DiscriminatorColumn(name="discr", type="string")
10  * @DiscriminatorMap({
11  *     "fix"       = "CompanyFixContract",
12  *     "flexible"  = "CompanyFlexContract",
13  *     "flexultra" = "CompanyFlexUltraContract"
14  * })
15  *
16  * @NamedNativeQueries({
17  *      @NamedNativeQuery(
18  *          name           = "all-contracts",
19  *          resultClass    = "__CLASS__",
20  *          query          = "SELECT id, completed, discr FROM company_contracts"
21  *      ),
22  *      @NamedNativeQuery(
23  *          name           = "all",
24  *          resultClass    = "__CLASS__",
25  *          query          = "SELECT id, completed, discr FROM company_contracts"
26  *      ),
27  * })
28  *
29  * @SqlResultSetMappings({
30  *      @SqlResultSetMapping(
31  *          name    = "mapping-all-contracts",
32  *          entities= {
33  *              @EntityResult(
34  *                  entityClass         = "__CLASS__",
35  *                  discriminatorColumn = "discr",
36  *                  fields              = {
37  *                      @FieldResult("id"),
38  *                      @FieldResult("completed"),
39  *                  }
40  *              )
41  *          }
42  *      ),
43  *      @SqlResultSetMapping(
44  *          name    = "mapping-all",
45  *          entities= {
46  *              @EntityResult(
47  *                  entityClass         = "__CLASS__",
48  *                  discriminatorColumn = "discr",
49  *                  fields              = {
50  *                      @FieldResult("id"),
51  *                      @FieldResult("completed"),
52  *                  }
53  *              )
54  *          }
55  *      ),
56  * })
57  */
58 abstract class CompanyContract
59 {
60     /**
61      * @Id @column(type="integer") @GeneratedValue
62      */
63     private $id;
64
65     /**
66      * @ManyToOne(targetEntity="CompanyEmployee", inversedBy="soldContracts")
67      */
68     private $salesPerson;
69
70     /**
71      * @Column(type="boolean")
72      * @var bool
73      */
74     private $completed = false;
75
76     /**
77      * @ManyToMany(targetEntity="CompanyEmployee", inversedBy="contracts")
78      * @JoinTable(name="company_contract_employees",
79      *    joinColumns={@JoinColumn(name="contract_id", referencedColumnName="id", onDelete="CASCADE")},
80      *    inverseJoinColumns={@JoinColumn(name="employee_id", referencedColumnName="id")}
81      * )
82      */
83     private $engineers;
84
85     public function __construct()
86     {
87         $this->engineers = new \Doctrine\Common\Collections\ArrayCollection;
88     }
89
90     public function getId()
91     {
92         return $this->id;
93     }
94
95     public function markCompleted()
96     {
97         $this->completed = true;
98     }
99
100     public function isCompleted()
101     {
102         return $this->completed;
103     }
104
105     public function getSalesPerson()
106     {
107         return $this->salesPerson;
108     }
109
110     public function setSalesPerson(CompanyEmployee $salesPerson)
111     {
112         $this->salesPerson = $salesPerson;
113     }
114
115     public function getEngineers()
116     {
117         return $this->engineers;
118     }
119
120     public function addEngineer(CompanyEmployee $engineer)
121     {
122         $this->engineers[] = $engineer;
123     }
124
125     public function removeEngineer(CompanyEmployee $engineer)
126     {
127         $this->engineers->removeElement($engineer);
128     }
129
130     abstract public function calculatePrice();
131 }