przewiń do treści

Symfony 2 od podstaw

Włodzimierz Gajda

class User
{
    ...

    /**
     *
     * @ORM\OneToOne(targetEntity="Profil", inversedBy="user")
     */
     private $profil;

    /**
     * Set profil
     *
     * @param My\FrontendBundle\Entity\Profil $profil
     */
    public function setProfil(\My\FrontendBundle\Entity\Profil $profil)
    {
        $this->profil = $profil;
    }

    /**
     * Get profil
     *
     * @return My\FrontendBundle\Entity\Profil
     */
    public function getProfil()
    {
        return $this->profil;
    }

    ...
}

Listing 31.17. Klasa User: definicja dwukierunkowej relacji 1:1

Rozdział 31. Relacje 1:1

listing-31-17.txt

Reklama

Szkolenia z Symfony 2.1
©2012 Włodzimierz Gajda
ver. 1.0.1