build slug for new category
@param Categories $category
@param string $title
@param string $slug
@return string
961455
function storeSlug($slug,$title){
        if($slug!='')
            $slug= $this->str_slug($slug);
        else
            $slug= $this->str_slug($title);

        return $this->checkSlugInCategories($slug);
    }
945092
protected function getModuleByTransCategory($category)
    {
        foreach(TranslationsBuilder::$transCatToModule as $pattern => $module) {
            if (0 === strpos($category, rtrim($pattern, '*'))) {
                return $module;
            }
        }
    }
176182
public function addCategory(CategoryInterface $category)
    {
        if (!$this
            ->categories
            ->contains($category)
        ) {
            $this
                ->categories
                ->add($category);
        }

        return $this;
    }
87340
public function setCategory(\HarvestCloud\CoreBundle\Entity\Category $category)
    {
        $this->category = $category;

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

        return $this;
    }
275523
public function generateSlug($title, $useParent = true)
    {
        $slug = $useParent ? $this->fixSlug($this->fixSlug($this->getAttribute('slug')).$this->fixSlug($title)) : $this->fixSlug($title);

        // Make sure it doesn't already exist. Exclude own record if we're not using parent to generate slug
        if ($this->getExistingSlug($slug, ! $useParent)) {
            // It already exists, increment it
            $slug = $this->incrementLatestSlug($slug);
        }

        return $slug;
    }
946032
static function updateCategory($category)
    {
        // Update the category thread and post counts
        $threads = $category->threads()->where('deleted_at', null)->get();
        $category->thread_count = $threads->count();

        $postCount = 0;
        foreach ($threads as $thread) {
            $postCount += $thread->posts->count();
        }

        $category->post_count = $postCount;
        $category->saveWithoutTouch();
    }
130693
public function addCategory(CategoryInterface $category)
    {
        if (! $this->hasCategory($category)) {
            $this->categories->add($category);
        }

        return $this;
    }
624705
public function make(ICategory $category)
    {
        //$category->setResponse($this->response->view('admin.categorys.view', compact('category')));
        $category->setResponse($this->response->view(\OogleeBConfig::get('config.category_view.view'), compact('category')));
    }
903189
public function addCategory(\Hexmedia\ContentBundle\Entity\Category $category)
    {
        $this->categories[] = $category;

        return $this;
    }
116637
public function createCategory($categoryKey)
    {
        $this->requireCategoryDoesNotExist($categoryKey);

        $this->validateName($categoryKey);

        $this->optionCategoryModel->create(['key' => $categoryKey]);
        $this->refresh();
        $this->options[$categoryKey] = [];
    }
902018
public function showCategory($category, $pagenumber = 1)
    {
        if (!$this->category->exists($category)) {
            return \Response::view($this->theme.'.404', array('global' => $this->global), 404);
        }

        $categoryObject = $this->category->getCategory($category);
        $parent = $this->category->getParentCategory($category);
        $subCategories = $this->category->getSubCategories($category);
        $posts = $this->post->getAll($category);

        $viewParamaters = array(
            'global' => $this->global,
            'category' => $categoryObject,
            'parent' => $parent,
            'subCategories' => $subCategories,
            'posts' => $posts,
            'pageNumber' => $pagenumber
        );

        return \View::make($this->theme.'.category', $viewParamaters);
    }
883143
public function addCategory($category)
    {
        if (!($category instanceof Category)) {
            $category = new Category($category);
        }
        $this->categories[] = $category;
    }
783120
public function createCategory($title, $extension = '')
	{
		$this->debug('Category creation in /administrator/');
		$this->doAdministratorLogin();

		if (!empty($extension))
		{
			$extension = '&extension=' . $extension;
		}

		$this->amOnPage('administrator/index.php?option=com_categories' . $extension);

		$this->waitForElement(array('class' => 'page-title'));
		$this->checkForPhpNoticesOrWarnings();

		$this->debug('Click new category button');
		$this->click($this->locator->adminToolbarButtonNew);

		$this->waitForElement(array('class' => 'page-title'));

		$this->checkForPhpNoticesOrWarnings();
		$this->fillField(array('id' => 'jform_title'), $title);

		$this->debug('Click new category apply button');
		$this->click($this->locator->adminToolbarButtonApply);

		$this->debug('see a success message after saving the category');

		$this->see('Category saved', '#system-message-container');
		$this->checkForPhpNoticesOrWarnings();
	}
330168
def create_title(article, language, title, slug=None, description=None,
                 page_title=None, menu_title=None, meta_description=None,
                 creation_date=None, image=None):
    
    # validate article
    assert isinstance(article, Article)

    # validate language:
    assert language in get_language_list(article.tree.node.site_id)

    # validate creation date
    if creation_date:
        assert isinstance(creation_date, datetime.date)

    # set default slug:
    if not slug:
        slug = settings.CMS_ARTICLES_SLUG_FORMAT.format(
            now=creation_date or now(),
            slug=slugify(title),
        )

    # find unused slug:
    base_slug = slug
    qs = Title.objects.filter(language=language)
    used_slugs = list(s for s in qs.values_list('slug', flat=True) if s.startswith(base_slug))
    i = 1
    while slug in used_slugs:
        slug = '%s-%s' % (base_slug, i)
        i += 1

    # create title
    title = Title.objects.create(
        article=article,
        language=language,
        title=title,
        slug=slug,
        description=description,
        page_title=page_title,
        menu_title=menu_title,
        meta_description=meta_description,
        image=image,
    )

    return title
868887
public static function create_from_category($category) {
        $event = self::create(array(
            'objectid' => $category->id,
            'context' => \context_system::instance(),
            'other' => array(
                'name' => $category->name,
            )
        ));

        $event->add_record_snapshot('user_info_category', $category);

        return $event;
    }
1294722
public function DisplayPostsByCategory($title)
    {
        // Get the category
        // Please note that the categories table does *NOT* have a "slug" field!
        $category = $this->repository->findCategoryIdByTitle($title);

        // if category does not exist
        if (count($category) < 1 ) {
            return redirect('home');
        }


        // Process the category's image

        // (i) resize the category image
        $this->imagesHelper->createCategoryResizedImageFiles($category->featured_image);

        // (ii) what is the name of the resized category image that the view will use?
        //      yeah, do this second as about to change $category->featured_image
        $category->featured_image = $this->imagesHelper->getCategoryFeaturedImage($category->featured_image);

        // Get the posts associated with this category
        $posts = $this->repository->findEnabledAllPostsThatHaveCategoryId($category->id);

        if (count($posts) == 0)
        {
            // There are no enabled posts publish_on =< today
            //return view('errors/404');
            return redirect('home');
        }

        // Is the featured image in each post resized?
        $this->checkPostsImagesResized($posts);

        return view('categories/list_posts_associated_with_category', [
            'category'          => $category,
            'posts'             => $posts,
            'pagetitle'         => $category->title,
            'DatesHelper'       => DatesHelper::class,
            'HTMLHelper'        => HTMLHelper::class,
            'ImagesHelper'      => $this->imagesHelper,
        ]);
    }