<?php

namespace OfficeBrain\Bundle\CouponBundle\Entity;

use Doctrine\ORM\EntityRepository;

/**
 *  @author OfficeBrain 4835 <info@officebrain.com>
 *  CouponLanguageRepository
 *
 * This class was generated by the Doctrine ORM. Add your own custom
 * repository methods below.
 */
class CouponLanguageRepository extends EntityRepository
{
    public function setData($coupon)
    {
        return $this->commit($coupon);
    }

    public function find($id, $lockMode = NULL, $lockVersion = NULL)
    {
        return $this->createQueryBuilder('s')
                        ->select('s')
                        ->where('s.id = :id')
                        ->setParameter(':id', $id)
                        ->getQuery()
                        ->getSingleResult();
    }

    /**
     * Commit entity.
     */
    private function commit($entity)
    {
        $this->_em->persist($entity);
        $this->_em->flush();
        $this->_em->clear();

        return $entity->getId();
    }
    
    
}
