Import categories.

@param \Cortex\Categories\Models\Category                   $category
@param \Cortex\Foundation\DataTables\ImportRecordsDataTable $importRecordsDataTable

@return \Illuminate\View\View
178614
public function import(Category $category, ImportRecordsDataTable $importRecordsDataTable)
    {
        return $importRecordsDataTable->with([
            'resource' => $category,
            'tabs' => 'adminarea.categories.tabs',
            'url' => route('adminarea.categories.stash'),
            'id' => "adminarea-categories-{$category->getRouteKey()}-import-table",
        ])->render('cortex/foundation::adminarea.pages.datatable-dropzone');
    }
164549
public function save(CategoryInterface $category): CategoryInterface
    {
        $data = $this->serializer()->serialize($category);

        if ($category->getId() !== 0) {
            $this->shopware()
                 ->put('/api/categories/'.(string)$category->getId(), [], $data);
        } else {
            $response = $this->shopware()->post('/api/categories', [], $data);
            $data     = json_decode((string)$response->getBody(), true);
            $category->setId((int)$data['data']['id']);
        }

        return $category;
    }
659484
public function created(CategoryTranslation $categoryTranslation)
    {
        DB::table('netcore_category__category_translations')->where('id', $categoryTranslation->id)->update([
            'full_slug' => $categoryTranslation->getFullSlug()
        ]);
    }
176182
public function addCategory(CategoryInterface $category)
    {
        if (!$this
            ->categories
            ->contains($category)
        ) {
            $this
                ->categories
                ->add($category);
        }

        return $this;
    }
903189
public function addCategory(\Hexmedia\ContentBundle\Entity\Category $category)
    {
        $this->categories[] = $category;

        return $this;
    }
1323946
private function buildCategory($objCategory)
  {
    $category = new \Category($objCategory->id, $objCategory->name);
    $category->parentCategoryId = $objCategory->pid;
    $category->description = $objCategory->description;
    $category->fileTypes = $objCategory->file_types;
    $category->fileTypesInherit = $objCategory->file_types_inherit;
    $category->publishDocumentsPerDefault = $objCategory->publish_documents_per_default;
    $category->generalReadPermission = $objCategory->general_read_permission;
    $category->generalManagePermission = $objCategory->general_manage_permission;
    $category->cssId = $objCategory->cssID;
    $category->published = $objCategory->published;
    $category->publicationStart = $objCategory->start;
    $category->publicationStop = $objCategory->stop;
    
    // HOOK: modify the category
    if (isset($GLOBALS['TL_HOOKS']['dmsModifyLoadedCategory']) && is_array($GLOBALS['TL_HOOKS']['dmsModifyLoadedCategory']))
    {
      foreach ($GLOBALS['TL_HOOKS']['dmsModifyLoadedCategory'] as $callback)
      {
        $this->import($callback[0]);
        $category = $this->{$callback[0]}->{$callback[1]}($category, $objCategory);
      }
    }
    
    return $category;
  }
440308
public function addCategorie(\Haven\CoreBundle\Entity\Category $categories)
    {
        $this->categories[] = $categories;
    
        return $this;
    }
971918
public function addCategory($category)
	{
		if (!is_string($category))
		{
			// @codeCoverageIgnoreStart
			throw new \LogicException('Category must be of a type "string"');
			// @codeCoverageIgnoreEnd
		}
		$this->categories[$category] = $category;

		return $this;
	}
134443
public static function update_category(stdClass $record) {
        $category = new category($record->id);
        $category->from_record($record);

        $result = $category->update();

        return $category;
    }
1338469
protected function _importData()
    {
        if (Import::BEHAVIOR_DELETE == $this->getBehavior()) {
            $this->deleteCategories();
        } else {
            $this->saveCategories();
            $this->saveOnTab();
        }

        //$this->reindexImportedCategories();

        $this->eventManager->dispatch('catalog_category_import_finish_before', ['adapter' => $this]);

        return true;
    }
1275507
public function importShoppingLists(?DataImporterConfigurationTransfer $dataImporterConfigurationTransfer = null): DataImporterReportTransfer
    {
        return $this->getFactory()
            ->getShoppingListDataImporter()
            ->import($dataImporterConfigurationTransfer);
    }
711022
public static function update_categories($categories) {
        global $DB;

        // Validate parameters.
        $params = self::validate_parameters(self::update_categories_parameters(), array('categories' => $categories));

        $transaction = $DB->start_delegated_transaction();

        foreach ($params['categories'] as $cat) {
            $category = core_course_category::get($cat['id']);

            $categorycontext = context_coursecat::instance($cat['id']);
            self::validate_context($categorycontext);
            require_capability('moodle/category:manage', $categorycontext);

            // this will throw an exception if descriptionformat is not valid
            external_validate_format($cat['descriptionformat']);

            $category->update($cat);
        }

        $transaction->allow_commit();
    }
765068
public function sort(ModelInterface $category, array $data = []): PodiumResponse
    {
        $forumSorter = $this->getSorter();

        $forumSorter->setCategory($category);

        if (!$forumSorter->loadData($data)) {
            return PodiumResponse::error();
        }

        return $forumSorter->sort();
    }
556406
public function addCategory($category)
    {
        if ( ! in_array($category, (array)$this->categories)) {
            $this->categories[] = $category;
        }

        return $this;
    }
1081080
public function withCategory($category)
    {
        Assertion::string($category);
        Assertion::maxLength($category, VideoInterface::CATEGORY_MAX_LENGTH);

        $instance = clone $this;

        $instance->category = $category;

        return $instance;
    }
1337260
private function getCategorySearchQuery(CategoryInterface $category)
    {
        $virtualRule = $category->getVirtualRule();
        if (!($virtualRule instanceof VirtualRuleInterface)) {
            return $this->loadVirtualRule($category)->getCategorySearchQuery($category);
        }

        return $this->helper->loadUsingCache($category, 'getCategorySearchQuery');
    }
1140395
public function setCategory(\Amulen\ClassificationBundle\Entity\Category $category = null)
    {
        $this->category = $category;

        return $this;
    }