Example #1
0
 /**
  * Find application as an array
  * @param interger $id
  * 
  * @return array
  */
 public function findArray($id)
 {
     $cache = \Jazzee\Controller::getCache();
     $cacheId = Application::ARRAY_CACHE_PREFIX . $id;
     if ($cache->contains($cacheId)) {
         return $cache->fetch($cacheId);
     }
     $queryBuilder = $this->makeQuery();
     $queryBuilder->andWhere('application.id = :id');
     $queryBuilder->setParameter('id', $id);
     $query = $queryBuilder->getQuery();
     if ($result = $query->getArrayResult()) {
         $application = $result[0];
         $keys = array('title', 'min', 'max', 'isRequired', 'answerStatusDisplay', 'instructions', 'leadingText', 'trailingText');
         foreach ($application['applicationPages'] as &$appPage) {
             foreach ($keys as $key) {
                 if (is_null($appPage[$key])) {
                     $appPage[$key] = $appPage['page'][$key];
                 }
             }
         }
         $query = $this->_em->createQuery('SELECT distinct tag from \\Jazzee\\Entity\\Tag as tag LEFT JOIN tag.applicants applicant WHERE applicant.id IN (SELECT a.id from Jazzee\\Entity\\Applicant a WHERE a.application = :applicationId)');
         $query->setParameter('applicationId', $application['id']);
         $application['tags'] = $query->getArrayResult();
         $cache->save($cacheId, $application);
         return $application;
     }
     return false;
 }
Example #2
0
 /**
  * Delete any references to the application in the cache
  * 
  */
 public function clearCache()
 {
     \Jazzee\Controller::getCache()->delete(self::ARRAY_CACHE_PREFIX . $this->id);
 }