public function clearCache($pages){
        if(!is_array($pages)){
            $pages = [$pages];
        }
        foreach($pages as $page){
            foreach($this->config->getDomain("type") as $type => $cacheLvl){
                $cacheLvl = abs($cacheLvl);
                if($cacheLvl == self::NO_CACHE) continue;
                $type = $this->em->getRepository(PageType::class)->findOneByTitle(str_replace("type.","",$type));
                $pagesToClear = $this->em->getRepository(Page::class)->findByType($type);
                switch($cacheLvl){
                    case self::TEMPORARY:
                        foreach($pagesToClear as $pageToClear){
                            $this->clearPage($pageToClear);
                        }
                        break;
                    case self::CHILDREN_DEPENDENCE:
                        foreach($pagesToClear as $p){
                            if(in_array($page, $p->getSubPages()->toArray())){
                                $this->clearPage($p);
                            }
                        }
                        break;
                }

                $uri = $this->config->get("URIs","uri.".$page->getRootPage()->getId());
                $this->removeUrl($uri, $page->getLink());
            }
        }
    }