Change sort order of the categories

@param category_controller $category category that needs to be moved
@param int $beforeid id of the category this category needs to be moved before, 0 to move to the end
333148
public function move_category(category_controller $category, int $beforeid = 0) {
        $category = $this->validate_category($category);
        api::move_category($category, $beforeid);
        $this->clear_configuration_cache();
    }
1017758
public function category($category)
    {
        $categoryId = NotificationCategory::getIdByCategory($category);
        $this->setNotificationData('category_id', $categoryId);

        return $this;
    }
198181
public static function action_course_change_sortorder_after_course($courserecordorid, $moveaftercourseid) {
        $course = \get_course($courserecordorid);
        $category = \core_course_category::get($course->category);
        if (!$category->can_resort_courses()) {
            $url = '/course/management.php?categoryid='.$course->category;
            throw new \moodle_exception('nopermissions', 'error', $url, \get_string('resortcourses', 'moodle'));
        }
        return \course_change_sortorder_after_course($course, $moveaftercourseid);
    }
563946
public function updateUserViewedCategory($categoryId = '')
    {
        $sessionUserViewedCategoryId = self::SESSION_ID_USER_VIEW_TOTAL_POST_BY_CATEGORY_FROM_SESSION . $categoryId;
        $this->logger->debug(__FUNCTION__, '$sessionUserViewedCategoryId => ' . json_encode($sessionUserViewedCategoryId));
        $checkSessionUserViewedCategoryValue = $this->hasSessionData($sessionUserViewedCategoryId);
        $this->logger->debug(__FUNCTION__, '$checkSessionUserViewedCategoryValue => ' . json_encode($checkSessionUserViewedCategoryValue));
        if ($checkSessionUserViewedCategoryValue === TRUE) {
            $currentSessionUserViewedCategoryValue = $this->getSessionData($sessionUserViewedCategoryId);
            $this->logger->debug(__FUNCTION__, '$currentSessionUserViewedCategoryValue => ' . json_encode($currentSessionUserViewedCategoryValue));
            if (is_numeric($currentSessionUserViewedCategoryValue)) {
                $viewValue = $currentSessionUserViewedCategoryValue + 1;
            } else {
                $viewValue = 1;
            }
            $this->logger->debug(__FUNCTION__, 'Update Total View Value: ' . $viewValue);
            $this->saveSessionData($sessionUserViewedCategoryId, $viewValue);
        } else {
            $this->saveSessionData($sessionUserViewedCategoryId, 1);
        }
    }
1212391
public function update(CategoryRequest $request, Category $category)
    {
        $category->update($request->all());
        return new CategoryResource($category);
    }
309022
protected function resetCategoryPictures($category, $params, $categoryId)
    {
        $config = \OxidEsales\Eshop\Core\Registry::getConfig();
        $category->load($categoryId);
        $category->loadInLang($this->_iEditLang, $categoryId);

        /** @var \OxidEsales\Eshop\Core\UtilsPic $utilsPic */
        $utilsPic = \OxidEsales\Eshop\Core\Registry::getUtilsPic();

        // #1173M - not all pic are deleted, after article is removed
        $utilsPic->overwritePic($category, 'oxcategories', 'oxthumb', 'TC', '0', $params, $config->getPictureDir(false));
        $utilsPic->overwritePic($category, 'oxcategories', 'oxicon', 'CICO', 'icon', $params, $config->getPictureDir(false));
        $utilsPic->overwritePic($category, 'oxcategories', 'oxpromoicon', 'PICO', 'icon', $params, $config->getPictureDir(false));
    }
445752
public function SortCategories() {
      // Check permission
      $this->Permission('Garden.Settings.Manage');
      
      // Set delivery type to true/false
      $TransientKey = GetIncomingValue('TransientKey');
      if (Gdn::Request()->IsPostBack()) {
         $TreeArray = GetValue('TreeArray', $_POST);
         $Saves = $this->CategoryModel->SaveTree($TreeArray);
         $this->SetData('Result', TRUE);
         $this->SetData('Saves', $Saves);
      }
         
      // Renders true/false rather than template  
      $this->Render();
   }
280046
public function editCategoryGroup($category_group_id = null)
    {
        $this->setCategoryGroup($category_group_id);
        $this->setTitleEditCategoryGroup();
        $this->setBreadcrumbEditCategoryGroup();

        $this->setData('category_group', $this->data_category_group);
        $this->setData('can_delete', $this->canDeleteCategoryGroup());
        $this->setData('languages', $this->language->getList(array('enabled' => true)));
        $this->setData('category_group_types', $this->category_group->getTypes());

        $this->submitEditCategoryGroup();
        $this->outputEditCategoryGroup();
    }
369132
public function update(DocumentCategory $category)
    {
        $attributes = request()->validate(DocumentCategory::$rules, DocumentCategory::$messages);

        $category = $this->updateEntry($category, $attributes);

        return redirect_to_resource();
    }
205557
public function rename_category(category_controller $category, string $name) {
        $this->validate_category($category);
        $category->set('name', $name);
        api::save_category($category);
        $this->clear_configuration_cache();
    }
315349
protected function setCategoryGroup($category_group_id)
    {
        $this->data_category_group = array();

        if (is_numeric($category_group_id)) {

            $conditions = array(
                'language' => 'und',
                'category_group_id' => $category_group_id
            );

            $this->data_category_group = $this->category_group->get($conditions);

            if (empty($this->data_category_group)) {
                $this->outputHttpStatus(404);
            }

            $this->prepareCategoryGroup($this->data_category_group);
        }
    }
933180
public function edit(Category $category)
    {
        return view('dashboard.sections.categories.edit', [
            'hasParent' => ! is_null($category->parent),
            'parents' => Category::parents()->get(),
            'category' => $category->load('parent'),
        ]);
    }
494367
public function removeCategory(\Amulen\ClassificationBundle\Entity\Category $category)
    {
        $this->categories->removeElement($category);
    }
77624
private function handleCategory($categoryId)
    {
        $categoryData = $this->getCategory($categoryId);

        if ($categoryData instanceof CategoryModel) {
            return $categoryData->getPath();
        }

        return '';
    }
795977
public function make(ICategory $category)
    {
        //$category->setContent($this->view->make($category->getLayoutViewPath(), compact('category'))->render());
        $category->setContent($this->view->make(\OogleeBConfig::get('config.category_view.view'), compact('category'))->render());
    }
1210140
protected function _beforeLoad()
    {
        parent::_beforeLoad();
        if ($this->category && $this->category->getId()) {
            $this->applyCategory();
        }
    }
412042
public function deleteCategory($id)
    {
        $this->validateId($id);

        $category = $this->getMapper()->find($id);

        if (null === $category) {
            throw new \InvalidArgumentException('No category found for id "' . $id . '"');
        }

        $node = $this->getNestedSetManager()->wrapNode($category);
        $node->delete();

        return $this;
    }