예제 #1
0
 public function postNumRulesAction(Request $request)
 {
     if ($request->getMethod() == 'POST') {
         $setting = $request->request->get('setting', array());
         $this->getSettingService()->set('post_num_rules', $setting);
         $this->getLogService()->info('system', 'update_settings', "更新PostNumSetting设置", $setting);
         $this->setFlashMessage('success', '设置已保存!');
     }
     $setting = $this->getSettingService()->get('post_num_rules', array());
     $setting = JsonToolkit::prettyPrint(json_encode($setting));
     return $this->render('TopxiaAdminBundle:System:post-num-rules.html.twig', array('setting' => $setting));
 }
예제 #2
0
 public function magicAction(Request $request)
 {
     if ($request->getMethod() == 'POST') {
         $setting = $request->request->get('setting', '{}');
         $setting = json_decode($setting, true);
         $this->getSettingService()->set('magic', $setting);
         $this->getLogService()->info('system', 'update_settings', "更新Magic设置", $setting);
         $this->setFlashMessage('success', '设置已保存!');
     }
     $setting = $this->getSettingService()->get('magic', array());
     $setting = JsonToolkit::prettyPrint(json_encode($setting));
     return $this->render('TopxiaAdminBundle:DeveloperSetting:magic.html.twig', array('setting' => $setting));
 }
 public function redisAction(Request $request)
 {
     if ($request->getMethod() == 'POST') {
         $redis = $request->request->all();
         $redis['setting'] = json_decode($redis['setting'], true);
         $this->getSettingService()->set('redis', $redis);
         $redisConfigFile = $this->container->getParameter('kernel.root_dir') . '/data/redis.php';
         if ($redis['opened'] == '1') {
             $config = "<?php \nreturn " . var_export($redis['setting'], true) . ';';
             file_put_contents($redisConfigFile, $config);
         }
         if ($redis['opened'] == '0') {
             file_exists($redisConfigFile) && unlink($redisConfigFile);
         }
         $this->getLogService()->info('system', 'update_redis', "更新redis设置", $redis);
         $this->setFlashMessage('success', '设置已保存!');
     }
     $redis = $this->getSettingService()->get('redis', array());
     if (isset($redis['setting']) && !empty($redis['setting'])) {
         $redis['setting'] = JsonToolkit::prettyPrint(json_encode($redis['setting']));
     } else {
         $redis['setting'] = '{}';
     }
     return $this->render('TopxiaAdminBundle:DeveloperSetting:redis.html.twig', array('redis' => $redis));
 }