Please see for this class, this is manyToMany  between School and Plan.

Tell me if there is something different, find strange is accepting 
duplicity, I think I'm doing something wrong



<?php

namespace SystemContract\Entity;

use Doctrine\ORM\Mapping as ORM;
use Zend\Stdlib\Hydrator;

/**
 * Contracts
 * @ORM\Table(name="system_contract")
 * @ORM\Entity
 * @ORM\Entity(repositoryClass="JCCore\Entity\Repository")
 */
class SystemContractForum {

    /**
     * @var integer
     *
     * @ORM\Column(name="contract_id", type="integer", nullable=false)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private $contractId;

    /**
     * 
     * @ORM\ManyToOne(targetEntity="\School\Entity\School" , 
inversedBy="contract")   
     * @ORM\JoinColumns({
     * @ORM\JoinColumn(name="school", referencedColumnName="scl_id")
     * })
     */
    private $school;

    /**
     * 
     * @ORM\ManyToOne(targetEntity="\SystemPlan\Entity\SystemPlan" , 
inversedBy="systemContract")   
     * @ORM\JoinColumns({
     * @ORM\JoinColumn(name="plan", referencedColumnName="plan_id")
     * })
     */
    private $plan;

    /**
     * Constructor
     */
    public function __construct(array $options = array()) {
        $hydrator = new Hydrator\ClassMethods;
        $hydrator->hydrate($options, $this);
    }

    public function getContractId() {
        return $this->contractId;
    }

    public function getSchool() {
        return $this->school;
    }

    public function getPlan() {
        return $this->plan;
    }

    public function setContractId($contractId) {
        $this->contractId = $contractId;
        return $this;
    }

    public function setSchool($school) {
        if (!($school instanceof \School\Entity\School)):
            throw new \InvalidArgumentException('Typo de variável não 
corresponde ao esperado. Esperado:\School\Entity\School.', 10601);
        endif;

        $this->school = $school;
        return $this;
    }

    public function setPlan($plan) {

        if (!($plan instanceof \SystemPlan\Entity\SystemPlan)):
            throw new \InvalidArgumentException('Typo de variável não 
corresponde ao esperado. Esperado:\SystemPlan\Entity\SystemPlan.', 10601);
        endif;

        $this->plan = $plan;
        return $this;
    }

    public function toArray() {
        $hydrator = new Hydrator\ClassMethods;
        $arr = $hydrator->extract($this);

        if (!empty($arr['school'])):
            $arr['school'] = $this->getSchool()->getSclId();
        endif;

        if (!empty($arr['plan'])):
            $arr['plan'] = $this->getPlan()->getPlanId();
        endif;
        return $arr;
    }

}




-- 
You received this message because you are subscribed to the Google Groups 
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to