Created
November 4, 2011 17:59
-
-
Save j/1340020 to your computer and use it in GitHub Desktop.
This file contains 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
<?php | |
// This class gets the randomly generated pages from the session from the database to send it's data to the view | |
class LayoutRender { | |
[...] | |
private function setupSignupPath() | |
{ | |
$path = $this->session->get('path'); | |
if (null === $path || empty($path[$this->type]['pages'][$this->page])) { | |
return false; | |
} | |
//$this->path = $this->entityManager->getRepository('ZGOffersMainBundle:Path')->findOneBy(array('url' => $this->pathUrl)); | |
$qb = $this->entityManager->createQueryBuilder(); | |
$qb | |
->select('p, t, s, s2') | |
->from('JStout:Path', 'p') | |
->join('p.templates', 't') | |
->join('p.signupFlows', 's') | |
->join('s.pages', 's2') | |
->where('p.url = :path_url') | |
->andWhere('t.id = :template_id') | |
->andWhere('s.id = :signupflow_id') | |
->andWhere('s2.id = :page_id') | |
->setParameter('path_url', $this->pathUrl) | |
->setParameter('template_id', $path['template']) | |
->setParameter('signupflow_id', $path[$this->type]['flow']) | |
->setParameter('page_id', $path[$this->type]['pages'][$this->page]) | |
; | |
try { | |
$result = $qb->getQuery()->getResult(); | |
} catch (NoResultException $e) { | |
throw new NotFoundHttpException('Path ' . $this->pathUrl . ' does not exist or is missing children!'); | |
} | |
$this->path = $result; | |
$templates = $result[0]->getTemplates(); | |
var_dump($path['template']); | |
var_dump($templates[0]->getId()); exit; // these don't match on first page load but do on second, why? | |
} | |
[...] | |
} |
This file contains 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
<?php | |
// This class gets a random template and a random signup flow associated to the "Path" | |
class SignupRender { | |
[...] | |
public function setup($pathUrl) | |
{ | |
if (null !== ($path = $this->request->getSession()->get('path', null))) { | |
return $path; | |
} | |
$qb = $this->entityManager->createQueryBuilder(); | |
$qb | |
->select('p, t, s, s2') | |
->from('JStout:Path', 'p') | |
->join('p.templates', 't') | |
->join('p.signupFlows', 's') | |
->join('s.pages', 's2') | |
->where('p.url = :path_url') | |
->setParameter('path_url', $pathUrl); | |
; | |
try { | |
$this->result = $qb->getQuery()->getSingleResult(); | |
} catch (NoResultException $e) { | |
throw new NotFoundHttpException('Path ' . $pathUrl . ' does not exist or is missing children!'); | |
} | |
// get a random template and it's signup pages | |
$this->path = array( | |
'path' => $pathUrl, | |
'template' => $this->getRandomTemplate($this->result->getTemplates()), | |
'signup' => $this->getRandomSignupFlow($this->result->getSignupFlows()) | |
); | |
// lets save the randomly chosen layout and randomly chosen signup flows to | |
$this->request->getSession()->set('path', $this->path); | |
return $this->path; | |
} | |
[...] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment