Created
September 22, 2015 17:57
-
-
Save pedrorvidal/7d1a8b4710684266f7a0 to your computer and use it in GitHub Desktop.
Get background funcionando
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * | |
| * @return \Entity\BackgroundHome | |
| */ | |
| public function getBackgroundHome() | |
| { | |
| $hash = $this->getParam()->get('hash'); | |
| $backgroundId = $this->getParam()->getInt('id'); | |
| $isBackgroundPreview = ($this->getParam()->get('preview') == 'background'); | |
| if ($isBackgroundPreview) { | |
| if ($this->verifyHash($hash)) { | |
| $this->getTpl()->addGlobal('pre_visualizacao_bg', true); | |
| return $this->getEm() | |
| ->getRepository('Entity\BackgroundHome') | |
| ->find($backgroundId); | |
| } else { | |
| throw new \Exception\NotFoundException; | |
| } | |
| } | |
| return $this->getEm() | |
| ->getRepository('Entity\BackgroundHome') | |
| ->getBackgroundHomeFunc(1); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * | |
| * @return object | |
| */ | |
| public function getBackgroundHomeFunc() | |
| { | |
| return $this->getEntityManager() | |
| ->createQueryBuilder() | |
| ->select('b') | |
| ->from('Entity\BackgroundHome', 'b') | |
| ->andWhere('b.publicado = 1') | |
| ->andWhere('b.dataInicial < CURRENT_DATE()') | |
| ->andWhere('b.dataFinal > CURRENT_DATE() OR b.dataFinal IS NULL') | |
| ->getQuery() | |
| ->setMaxResults(1)->getOneOrNullResult(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment