Creates new keyword for given category.

@param int $categoryId
@param Request $request

@return Response
355900
public function postAction($categoryId, Request $request)
    {
        /** @var KeywordInterface $keyword */
        $keyword = $this->getKeywordRepository()->createNew();
        $category = $this->getCategoryRepository()->findCategoryById($categoryId);
        $keyword->setKeyword($request->get('keyword'));
        $keyword->setLocale($request->get('locale'));

        $keyword = $this->getKeywordManager()->save($keyword, $category);

        $this->getEntityManager()->persist($keyword);
        $this->getEntityManager()->flush();

        return $this->handleView($this->view($keyword));
    }
998877
public function update(CategoryRequest $request, Category $category)
    {
        try {
            $attributes = $request->all();

            $category->update($attributes);
            return $this->response->message(trans('messages.success.updated', ['Module' => trans('faq::category.name')]))
                ->code(204)
                ->status('success')
                ->url(guard_url('faq/category/' . $category->getRouteKey()))
                ->redirect();
        } catch (Exception $e) {
            return $this->response->message($e->getMessage())
                ->code(400)
                ->status('error')
                ->url(guard_url('faq/category/' . $category->getRouteKey()))
                ->redirect();
        }

    }
1236973
public function newAction(Request $request, $contentTypeId, $language)
    {
        $siteId = $this->get('open_orchestra_backoffice.context_backoffice_manager')->getSiteId();
        $site = $this->get('open_orchestra_model.repository.site')->findOneBySiteId($siteId);

        $contentManager = $this->get('open_orchestra_backoffice.manager.content');
        $contentType = $this->get('open_orchestra_model.repository.content_type')->findOneByContentTypeIdInLastVersion($contentTypeId);
        if (!$contentType instanceof ContentTypeInterface || !in_array($contentType->getContentTypeId(), $site->getContentTypes())) {
            throw new \UnexpectedValueException();
        }
        $content = $contentManager->initializeNewContent(
            $contentTypeId,
            $language,
            $contentType->isLinkedToSite() && $contentType->isAlwaysShared(),
            $contentType->isDefiningStatusable()
        );
        if (!$content instanceof ContentInterface) {
            throw new \UnexpectedValueException();
        }
        $this->denyAccessUnlessGranted(ContributionActionInterface::CREATE, $content);

        $form = $this->createForm('oo_content', $content, array(
            'action' => $this->generateUrl('open_orchestra_backoffice_content_new', array(
                'contentTypeId' => $contentTypeId,
                'language' => $language,
            )),
            'method' => 'POST',
            'new_button' => true,
            'need_link_to_site_defintion' => !$contentType->isLinkedToSite() && !$contentType->isAlwaysShared(),
            'is_statusable' => $contentType->isDefiningStatusable()
        ));

        $status = $content->getStatus();
        $form->handleRequest($request);

        if ($form->isValid()) {
            $content = $contentManager->setVersionName($content);
            $documentManager = $this->get('object_manager');
            $documentManager->persist($content);
            $this->dispatchEvent(ContentEvents::CONTENT_CREATION, new ContentEvent($content));

            $this->createContentInNewLanguage($content, $language);

            $documentManager->flush();
            if ($status->getId() !== $content->getStatus()->getId()) {
                $this->dispatchEvent(ContentEvents::CONTENT_CHANGE_STATUS, new ContentEvent($content, $status));
            }

            $message = $this->get('translator')->trans('open_orchestra_backoffice.form.content.creation');
            $response = new Response(
                $message,
                Response::HTTP_CREATED,
                array('Content-type' => 'text/plain; charset=utf-8', 'contentId' => $content->getContentId(), 'version' => $content->getVersion())
            );

            return $response;
        }

        return $this->renderAdminForm($form);
    }
338551
public function makePublic($id, Request $request)
    {
        $this->authorize('createCategories');

        $category = $this->model()->where('private', 1)->find($id);

        return $this->updateModel($category, ['private' => 0]);
    }
1273388
def help_center_category_translation_create(self, category_id, data, **kwargs):
        ""
        api_path = "/api/v2/help_center/categories/{category_id}/translations.json"
        api_path = api_path.format(category_id=category_id)
        return self.call(api_path, method="POST", data=data, **kwargs)
1042057
public static function create_from_object(category_controller $category) : category_created {
        $eventparams = [
            'objectid' => $category->get('id'),
            'context'  => $category->get_handler()->get_configuration_context(),
            'other'    => ['name' => $category->get('name')]
        ];
        $event = self::create($eventparams);
        $event->add_record_snapshot($event->objecttable, $category->to_record());
        return $event;
    }
57112
public function store(Request $request)
    {
        $this->authorize('createCategories');

        $this->validate($request, [
            'title'             => ['required'],
            'weight'            => ['required'],
            'enable_threads'    => ['required'],
            'private'           => ['required']
        ]);

        $category = $this->model()->create($request->only(['category_id', 'title', 'description', 'weight', 'enable_threads', 'private']));

        return $this->response($category, 201);
    }
1125486
public function categoriesAdd(Request $request, Response $response)
    {
        if ($check = $this->sentinel->hasPerm('blog_categories.create', 'dashboard', $this->config['blog-enabled'])) {
            return $check;
        }

        if ($request->isPost()) {
            $this->validator->validate($request, [
                'category_name' => V::length(2, 25)->alpha('\''),
                'category_slug' => V::slug()
            ]);

            $checkSlug = BC::where('slug', '=', $request->getParam('category_slug'))->get()->count();

            if ($checkSlug > 0) {
                $this->validator->addError('category_slug', 'Slug already in use.');
            }

            if ($this->validator->isValid()) {
                $addCategory = new BC;
                $addCategory->name = $request->getParam('category_name');
                $addCategory->slug = $request->getParam('category_slug');

                if ($addCategory->save()) {
                    $this->flash('success', 'Category added successfully.');
                    return $this->redirect($response, 'admin-blog');
                }
            }
            $this->flash('danger', 'An error occured while adding this category.');
        }

        return $this->redirect($response, 'admin-blog');
    }
866565
public function newAction(Request $request, MenuItem $menuItemId)
    {
        $entity = new MenuItem();
        $form   = $this->createForm('CoreExtraBundle\Form\SubMenuItemType', $entity);
        $form->handleRequest($request);
        
        if ($form->isSubmitted() && $form->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $entity->getParentMenuItem($menuItemId);
            $em->persist($entity);
            $em->flush();
            
            //images
            $image = $form->getNormData()->getImage();
            if ($image instanceof Image) {
                $this->get('core_manager')->uploadMenuImage($entity);
            }
            
            $this->get('session')->getFlashBag()->add('success', 'menu.created');

            return $this->redirectToRoute('coreextra_menuitem_show', array('id' => $entity->getId()));
        }
        
        return array(
            'entity' => $entity,
            'menuitem' => $menuItemId,
            'form'   => $form->createView(),
        );
    }
1108375
public function index(Request $request)
    {
        $categories = $this->category->all();

        return Response::json(['errors' => false, 'data' => $categories]);
    }
1066308
public function addAction(Request $request, $menuid)
    {
        return parent::doAddAction($this->getAdminListConfigurator($request, $menuid), null, $request);
    }
44785
public function actionGetCategoryUrls(string $category, array $criteria = [], $siteId = null): Response
    {
        return $this->asJson(RouteMap::$plugin->routes->getCategoryUrls($category, $criteria, $siteId));
    }
291832
public function update(CreateCategoryRequest $request, $id)
	{
        $category = $this->model->findOrFail($id);
        if($category->name !== $request->get('name')){
            $category->generateNewSlug = true;
        }
        $category->fill($request->all());
        $category->save();
        flash()->success('Se ha actualizado la Categoria');
        return redirect()->to('backend/blog-categories');
	}
1079689
public function destroy(CategoryRequest $request, Category $category)
    {
        try {

            $category->delete();
            return $this->response->message(trans('messages.success.deleted', ['Module' => trans('faq::category.name')]))
                ->code(202)
                ->status('success')
                ->url(guard_url('faq/category/0'))
                ->redirect();

        } catch (Exception $e) {

            return $this->response->message($e->getMessage())
                ->code(400)
                ->status('error')
                ->url(guard_url('faq/category/' . $category->getRouteKey()))
                ->redirect();
        }

    }
1149187
public function insert (Request $request)
    {
        if ($this->category->categoryExist($request->input('title') , $request->input('model_type')))
            throw new CategoryException(trans('Categories::category.error-message.categoryExist'));

        $category = $this->category->newInstance($request->except('_token'));
        $slug = new Slugger($this->modelType);
        $category->slug = $slug->storeSlug($request->input('slug') , $request->input('title'));
        $category->model_type = $this->modelType;
        $category->save();

        return $category;

    }
707858
public function deleteAction($categoryId, $keywordId)
    {
        $keyword = $this->getKeywordRepository()->findById($keywordId);
        $category = $this->getCategoryRepository()->findCategoryById($categoryId);
        $this->getKeywordManager()->delete($keyword, $category);

        $this->getEntityManager()->flush();

        return $this->handleView($this->view());
    }
768001
public function update(CategoryRequest $request, Model $category)
    {
        $category->update($request->all());

        return redirect()->route('admin.category.index');
    }