예제 #1
0
 /**
  * @Route("/", methods="POST")
  * @Request({"menu":"array"}, csrf=true)
  */
 public function saveAction($menu)
 {
     $oldId = isset($menu['id']) ? trim($menu['id']) : null;
     $label = trim($menu['label']);
     if (!($id = App::filter($label, 'slugify'))) {
         App::abort(400, __('Invalid id.'));
     }
     if ($id != $oldId) {
         if ($this->config->has('menus.' . $id)) {
             throw new ConflictException(__('Duplicate Menu Id.'));
         }
         $this->config->remove('menus.' . $oldId);
         Node::where(['menu = :old'], [':old' => $oldId])->update(['menu' => $id]);
     }
     $this->config->merge(['menus' => [$id => compact('id', 'label')]]);
     App::menu()->assign($id, $menu['positions']);
     return ['message' => 'success', 'menu' => $menu];
 }
 /**
  * @Request({"config": "array", "options": "array"}, csrf=true)
  */
 public function saveAction($values = [], $options = [])
 {
     $config = new Config();
     $config->merge(include $file = App::get('config.file'));
     foreach ($values as $module => $value) {
         $config->set($module, $value);
     }
     file_put_contents($file, $config->dump());
     foreach ($options as $module => $value) {
         $this->configAction($module, $value);
     }
     if (function_exists('opcache_invalidate')) {
         opcache_invalidate($file);
     }
     return ['message' => 'success'];
 }