public function persist(PersistableInterface $persistable, $remember = false)
    {
        try
        {
            if ($this->single)
            {
                $this->flush($persistable);
            }

            $code = $persistable->generatePersistenceCode();

            $this->session->put($code);

            if ($remember === true) {
                $this->cookie->put($code);
            }

            $persistence = $this->create($persistable, $code);

            $entityManager = $this->getEntityManager();
            $entityManager->persist($persistence);
            $entityManager->flush();

            return true;
        }
        catch (\Exception $e)
        {
            return false;
        }
    }
public function persist(PersistableInterface $persistable, $remember = false)
    {
        try
        {
            if ($this->single)
            {
                $this->flush($persistable);
            }

            $code = $persistable->generatePersistenceCode();

            $this->session->put($code);

            if ($remember === true) {
                $this->cookie->put($code);
            }

            $persistence = $this->create($persistable, $code);

            $entityManager = $this->getEntityManager();
            $entityManager->persist($persistence);
            $entityManager->flush();

            return true;
        }
        catch (\Exception $e)
        {
            return false;
        }
    }
public function persist ( PersistableInterface $ persistable , $ remember = false ) { try { if ( $ this -> single ) { $ this -> flush ( $ persistable ) ; } $ code = $ persistable -> generatePersistenceCode ( ) ; $ this -> session -> put ( $ code ) ; if ( $ remember === true ) { $ this -> cookie -> put ( $ code ) ; } $ persistence = $ this -> create ( $ persistable , $ code ) ; $ entityManager = $ this -> getEntityManager ( ) ; $ entityManager -> persist ( $ persistence ) ; $ entityManager -> flush ( ) ; return true ; } catch ( \ Exception $ e ) { return false ; } }
Adds a new user persistence to the current session and attaches the user.

@param User $persistable
@param bool $remember
@return bool
Adds a new user persistence to the current session and attaches the user .