moveItem() 공개 메소드

Move menu item
public moveItem ( Menu $menu, MenuItem $item, MenuItem $parent = null ) : MenuItem
$menu Xpressengine\Menu\Models\Menu menu instance
$item Xpressengine\Menu\Models\MenuItem menu item instance
$parent Xpressengine\Menu\Models\MenuItem menu item instance
리턴 Xpressengine\Menu\Models\MenuItem
예제 #1
0
 /**
  * moveItem
  *
  * @param MenuHandler $handler menu handler
  *
  * @return RendererInterface
  * @throws Exception
  */
 public function moveItem(MenuHandler $handler)
 {
     $ordering = Input::get('ordering');
     $itemId = Input::get('itemId');
     $parentId = Input::get('parent');
     XeDB::beginTransaction();
     try {
         $item = $handler->getItem($itemId);
         /** @var Menu $menu */
         if (!($parent = $handler->getItem($parentId))) {
             $menu = $handler->get($parentId);
         } else {
             $menu = $parent->menu;
         }
         $old = clone $item;
         // 이동되기 전 상태의 객체를 구성하기 위해 relation 을 사전에 load
         $old->ancestors;
         $item = $handler->moveItem($menu, $item, $parent);
         $handler->setOrder($item, $ordering);
         $handler->moveItemConfig($old, $item);
         $toKey = $handler->permKeyString($item);
         $toKey = substr($toKey, 0, strrpos($toKey, '.'));
         $this->permissionMove($handler->permKeyString($old), $toKey);
     } catch (\Exception $e) {
         XeDB::rollback();
         throw $e;
     }
     XeDB::commit();
     return XePresenter::makeApi(Input::all());
 }