/**
  * Deactivate selected modules
  */
 public function deactivateAction()
 {
     $request = $this->getRequest();
     if ($request->isPost() && $this->applicationCsrf()->isTokenValid($request->getPost('csrf'))) {
         if (null !== ($modulesIds = $request->getPost('modules', null))) {
             // deactivate selected modules
             $deactivateResult = false;
             $deactivatedCount = 0;
             foreach ($modulesIds as $module) {
                 // get a module info
                 if (null != ($moduleInfo = $this->getModel()->getModuleInfo($module))) {
                     // check dependent modules and type of the module
                     if (count($this->getModel()->getDependentModules($module)) || $moduleInfo['type'] == ApplicationAbstractBaseModel::MODULE_TYPE_SYSTEM) {
                         continue;
                     }
                     // check the permission and increase permission's actions track
                     if (true !== ($result = $this->aclCheckPermission(null, true, false))) {
                         $this->flashMessenger()->setNamespace('error')->addMessage($this->getTranslator()->translate('Access Denied'));
                         break;
                     }
                     // deactivate the module
                     if (true !== ($deactivateResult = $this->getModel()->setCustomModuleStatus($module, false))) {
                         $this->flashMessenger()->setNamespace('error')->addMessage($deactivateResult ? $this->getTranslator()->translate($deactivateResult) : $this->getTranslator()->translate('Error occurred'));
                         break;
                     }
                 }
                 $deactivatedCount++;
             }
             if (true === $deactivateResult) {
                 $message = $deactivatedCount > 1 ? 'Selected modules have been deactivated' : 'The selected module has been deactivated';
                 $this->flashMessenger()->setNamespace('success')->addMessage($this->getTranslator()->translate($message));
             }
         }
     }
     ApplicationCacheUtility::clearDynamicCache();
     // redirect back
     return $this->redirectTo('modules-administration', 'list-installed', [], true);
 }
 /**
  * Clear caches
  *
  * @param array $caches
  *      boolean setting optional
  *      boolean time_zone optional
  *      boolean admin_menu optional
  *      boolean js_cache optional
  *      boolean css_cache optional
  *      boolean layout optional
  *      boolean localization optional
  *      boolean page optional
  *      boolean user optional
  *      boolean xmlrpc optional
  * @return void
  */
 protected function clearCaches(array $caches = [])
 {
     // clear the modules and system config caches
     ApplicationCacheUtility::clearModuleCache();
     ApplicationCacheUtility::clearConfigCache();
     ApplicationCacheUtility::clearDynamicCache();
     foreach ($caches as $cacheName => $clear) {
         if (false === (bool) $clear) {
             continue;
         }
         switch ($cacheName) {
             case 'setting':
                 ApplicationCacheUtility::clearSettingCache();
                 break;
             case 'time_zone':
                 ApplicationCacheUtility::clearTimeZoneCache();
                 break;
             case 'admin_menu':
                 ApplicationCacheUtility::clearAdminMenuCache();
                 break;
             case 'js_cache':
                 ApplicationCacheUtility::clearJsCache();
                 break;
             case 'css_cache':
                 ApplicationCacheUtility::clearCssCache();
                 break;
             case 'layout':
                 LayoutCacheUtility::clearLayoutCache();
                 break;
             case 'localization':
                 LocalizationCacheUtility::clearLocalizationCache();
                 break;
             case 'page':
                 PageCacheUtility::clearPageCache();
                 break;
             case 'user':
                 UserCacheUtility::clearUserCache();
                 break;
             case 'xmlrpc':
                 XmlRpcCacheUtility::clearXmlRpcCache();
                 break;
         }
     }
 }
 /**
  * Clear cache
  */
 public function clearCacheAction()
 {
     // get a cache form
     $cacheForm = $this->getServiceLocator()->get('Application\\Form\\FormManager')->getInstance('Application\\Form\\ApplicationClearCache');
     $request = $this->getRequest();
     // validate the form
     if ($request->isPost()) {
         // fill the form with received values
         $cacheForm->getForm()->setData($request->getPost(), false);
         // check the form validation
         if ($cacheForm->getForm()->isValid()) {
             if (null != ($caches = $cacheForm->getForm()->getData()['cache'])) {
                 // clear selected caches
                 foreach ($caches as $cache) {
                     // check the permission and increase permission's actions track
                     if (true !== ($result = $this->aclCheckPermission())) {
                         return $result;
                     }
                     $clearResult = false;
                     switch ($cache) {
                         case self::CACHE_STATIC:
                             $clearResult = CacheUtility::clearStaticCache();
                             break;
                         case self::CACHE_DYNAMIC:
                             $clearResult = CacheUtility::clearDynamicCache();
                             break;
                         case self::CACHE_CONFIG:
                             $clearResult = CacheUtility::clearConfigCache();
                             break;
                         case self::CACHE_JS:
                             $clearResult = CacheUtility::clearJsCache();
                             break;
                         case self::CACHE_CSS:
                             $clearResult = CacheUtility::clearCssCache();
                             break;
                     }
                     if (false === $clearResult) {
                         $this->flashMessenger()->setNamespace('error')->addMessage(sprintf($this->getTranslator()->translate('Error clearing caches'), $cache));
                         break;
                     }
                 }
                 if (true === $clearResult) {
                     ApplicationEvent::fireClearCacheEvent($cache);
                     $this->flashMessenger()->setNamespace('success')->addMessage($this->getTranslator()->translate('Selected caches have been cleared'));
                 }
                 return $this->redirectTo('settings-administration', 'clear-cache');
             }
         }
     }
     return new ViewModel(['cacheForm' => $cacheForm->getForm()]);
 }
 /**
  * Clear layout caches
  *
  * @return void
  */
 public function clearLayoutCaches()
 {
     ApplicationCacheUtility::clearJsCache();
     ApplicationCacheUtility::clearCssCache();
     LayoutCacheUtility::clearLayoutCache();
     ApplicationCacheUtility::clearDynamicCache();
 }