3 namespace Rapsys\AirBundle\Repository
; 
   5 use Symfony\Component\Translation\TranslatorInterface
; 
   6 use Doctrine\ORM\Query\ResultSetMapping
; 
  11 class SlotRepository 
extends \Doctrine\ORM\EntityRepository 
{ 
  13          * Find slots with translated title 
  15          * @param $translator The TranslatorInterface instance 
  17         public function findAllWithTranslatedTitle(TranslatorInterface 
$translator) { 
  19                 $em = $this->getEntityManager(); 
  22                 $qs = $em->getConfiguration()->getQuoteStrategy(); 
  23                 $dp = $em->getConnection()->getDatabasePlatform(); 
  25                 //Set the request from quoted table name 
  26                 //XXX: this allow to make this code table name independent 
  27                 $req = 'SELECT s.id, s.title FROM '.$qs->getTableName($em->getClassMetadata('RapsysAirBundle:Slot'), $dp).' AS s'; 
  29                 //Get result set mapping instance 
  30                 //XXX: DEBUG: see ../blog.orig/src/Rapsys/BlogBundle/Repository/ArticleRepository.php 
  31                 $rsm = new ResultSetMapping(); 
  34                 //XXX: see vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/Types.php 
  35                 //addScalarResult($sqlColName, $resColName, $type = 'string'); 
  36                 $rsm->addScalarResult('id', 'id', 'integer') 
  37                         ->addScalarResult('title', 'title', 'string') 
  38                         ->addIndexByScalar('id'); 
  42                         ->createNativeQuery($req, $rsm) 
  49                 foreach($res as $data) { 
  51                         $slot = $translator->trans($data['title']); 
  53                         //XXX: ChoiceType use display string as key 
  54                         $ret[$slot] = $data['id'];