/**
  * Initializes this cache frontend
  *
  * @return void
  */
 public function initializeObject()
 {
     $this->useIgBinary = extension_loaded('igbinary');
     parent::initializeObject();
 }
 /**
  * Returns a filtered List
  *
  * @param \TYPO3\Flow\Cache\Frontend\AbstractFrontend $cacheInstance
  * @param array $forbiddenCTypes
  * @param array $pidList
  * @param array $categoriesIDList
  * @param array $ColPosIDList
  * @param int $limit
  * @param int $offset
  * @param int $tagID
  * @param string $sortfield
  * @param string $sorting
  * @parem bool $countQuery
  *
  * @return QueryResultInterface|array|int
  */
 public function getListWithQuerySettings($cacheInstance, array $forbiddenCTypes, array $pidList, array $categoriesIDList, array $ColPosIDList, $limit, $offset = 0, $tagID = 0, $sortfield = "sorting", $sorting = \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_DESCENDING, $countQuery = FALSE, $searchWord = NULL)
 {
     $query = $this->createQuery();
     /*	$query->getQuerySettings()
     			->setRespectStoragePage(FALSE)
     			->setRespectSysLanguage(FALSE)
     			->setLanguageMode("ignore")
     			->setLanguageOverlayMode("hideNonTranslated");*/
     $query->getQuerySettings()->setRespectStoragePage(FALSE);
     #\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump(array("getListWithQuerySettings"=>array( "forbiddenCTypes"=>$forbiddenCTypes,  "pidList"=>$pidList,  "categoriesIDList"=>$categoriesIDList,  "ColPosIDList"=>$ColPosIDList, "limit"=>$limit, "offset"=>$offset)));
     $constraints = array();
     if (count($forbiddenCTypes) > 0) {
         $forbiddenContraints = array();
         foreach ($forbiddenCTypes as $ctype) {
             $forbiddenContraints[] = $query->logicalNot($query->equals("ctype", $ctype));
         }
         if (count($forbiddenContraints)) {
             $constraints[] = $query->logicalAnd($forbiddenContraints);
         }
     }
     if (count($pidList) == 1) {
         $constraints[] = $query->equals("pid", $pidList[0]);
     } else {
         if (count($pidList) > 1) {
             $constraints[] = $query->in("pid", $pidList);
         }
     }
     if (count($categoriesIDList) > 0) {
         $catIDContraints = array();
         foreach ($categoriesIDList as $catID) {
             $catIDContraints[] = $query->contains("categories", $catID);
         }
         if (count($catIDContraints)) {
             $constraints[] = $query->logicalOr($catIDContraints);
         }
     }
     if (count($ColPosIDList) > 0) {
         $constraints[] = $query->in("colPos", $ColPosIDList);
     }
     if ($tagID > 0) {
         $constraints[] = $query->contains("tags", $tagID);
     }
     if ($GLOBALS['TSFE']->sys_language_uid > 0) {
         $constraints[] = $query->in('sys_language_uid', array(-1, $GLOBALS['TSFE']->sys_language_uid));
         /*
         						$query->getQuerySettings()
         								->setRespectSysLanguage(TRUE)
         								->setLanguageUid($language);*/
     }
     if ($searchWord != NULL) {
         $searchWord = $GLOBALS['TYPO3_DB']->quoteStr($searchWord, "tt_content");
         $constraints[] = $query->logicalOr($query->like('header', "%{$searchWord}%", false), $query->like('short', "%{$searchWord}%", false), $query->like('bodytext', "%{$searchWord}%", false), $query->like('imagecaption', "%{$searchWord}%", false));
     }
     if (count($constraints) > 0) {
         $query->matching($query->logicalAnd($constraints));
     }
     $sortingArray = array($sortfield => $sorting);
     #\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($sortingArray);
     $cacheIdentifier = hash("md5", implode(";", $forbiddenCTypes) . implode(";", $pidList) . implode(";", $categoriesIDList) . implode(";", $ColPosIDList) . $tagID . "L:" . $GLOBALS['TSFE']->sys_language_uid . "SW:" . $searchWord);
     if ($GLOBALS["TSFE"]->no_cache == false && $cacheInstance->has($cacheIdentifier)) {
         $res = $cacheInstance->get($cacheIdentifier);
         #\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($cacheIdentifier, "res from cache: ".$cacheIdentifier);
     } else {
         $res = $query->setOrderings($sortingArray)->execute();
         // safe un limited list to cache
         $cacheInstance->set($cacheIdentifier, $res);
         #\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($cacheIdentifier, "res TO cache".$cacheIdentifier);
     }
     // filter records that are not on Pages that match showOnPages
     $res = $this->filterResult($res->toArray());
     if ($countQuery == FALSE) {
         // limit
         $res = array_splice($res, $offset, $limit);
     } else {
         $res = count($res);
     }
     /** @var Typo3DbQueryParser $queryParser */
     #$queryParser = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Storage\\Typo3DbQueryParser');
     #\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($queryParser->parseQuery($query));
     return $res;
 }