Ejemplo n.º 1
0
 /**
  * Actions to perform to restaure default settings
  *
  * @param  string $name The theme name to reset
  * @return bool         True for success
  */
 public function reset($name, $keep_data = false)
 {
     if (!$this->employee->can('add', 'AdminModules') || !$this->employee->can('delete', 'AdminModules') || !$this->moduleProvider->can('uninstall', $name)) {
         throw new Exception($this->translator->trans('You are not allowed to reset this module.', array(), 'Admin.Modules.Notification'));
     }
     $module = $this->moduleRepository->getModule($name);
     try {
         if ((bool) $keep_data && method_exists($this, 'reset')) {
             $status = $module->onReset();
         } else {
             $status = $module->onUninstall() && $module->onInstall();
         }
         return $status;
     } catch (Exception $e) {
         throw new Exception($this->translator->trans('Error when resetting module %module%. %error_details%', array('%module%' => $name, '%error_details%' => $e->getMessage()), 'Admin.Modules.Notification'), 0, $e);
     }
 }