/**
  * @Route("/{id}", methods="DELETE", requirements={"id"="\d+"})
  * @Request({"id": "int"}, csrf=true)
  */
 public function deleteAction($id)
 {
     if (!($widget = Widget::find($id))) {
         App::abort(404, 'Widget not found.');
     }
     $widget->delete();
     return ['message' => 'success'];
 }
Beispiel #2
0
 /**
  * @Request({"id": "int", "type": "string"})
  */
 public function editAction($id = 0, $type = null)
 {
     if (!$id) {
         $widget = Widget::create(['type' => $type]);
     } else {
         if (!($widget = Widget::find($id))) {
             App::abort(404, 'Widget not found.');
         }
     }
     return ['$view' => ['title' => __('Widgets'), 'name' => 'system/widget/edit.php'], '$data' => ['widget' => $widget, 'config' => ['menus' => App::menu(), 'nodes' => array_values(Node::query()->get()), 'roles' => array_values(Role::findAll()), 'types' => array_values(App::widget()->all()), 'positions' => array_values(App::position()->all())]]];
 }
 /**
  * @Route(methods="POST")
  * @Request({"ids": "int[]"}, csrf=true)
  */
 public function copyAction($ids = [])
 {
     foreach ($ids as $id) {
         if ($widget = Widget::find((int) $id)) {
             $copy = clone $widget;
             $copy->id = null;
             $copy->status = 0;
             $copy->title = $widget->title . ' - ' . __('Copy');
             $copy->save();
         }
     }
     return ['message' => 'success', 'positions' => array_values(App::position()->all())];
 }
 /**
  * @Route(methods="POST")
  * @Request({"ids": "int[]"}, csrf=true)
  */
 public function copyAction($ids = [])
 {
     foreach ($ids as $id) {
         if ($widget = Widget::find((int) $id)) {
             $copy = clone $widget;
             $copy->id = null;
             $copy->status = 0;
             $copy->title = $widget->title . ' - ' . __('Copy');
             $copy->save();
         }
     }
     return ['message' => 'success'];
 }