Craft 2 Class Reference

Class ElementHelper

Package
craft.app.helpers
Namespace
Craft
Inheritance
class ElementHelper
Since
2.0
Source Code
craft/app/helpers/ElementHelper.php

Class ElementHelper

Public Methods
Method Description Defined By
createSlug() Creates a slug based on a given string. ElementHelper
doesUrlFormatHaveSlugTag() Returns whether a given URL format has a proper {slug} tag. ElementHelper
getEditableLocaleIdsForElement() Returns the editable locale IDs for a given element, taking user locale permissions into account. ElementHelper
isElementEditable() Returns whether the given element is editable by the current user, taking user locale permissions into account. ElementHelper
setNextPrevOnElements() Given an array of elements, will go through and set the appropriate "next" and "prev" elements on them. ElementHelper
setUniqueUri() Sets the URI on an element using a given URL format, tweaking its slug if necessary to ensure it's unique. ElementHelper
setValidSlug() Sets a valid slug on a given element. ElementHelper

Method Details

createSlug() public static method #

Creates a slug based on a given string.

public static string createSlug(string $str)
$str string
Returns string

doesUrlFormatHaveSlugTag() public static method #

Returns whether a given URL format has a proper {slug} tag.

public static bool doesUrlFormatHaveSlugTag(string $urlFormat)
$urlFormat string
Returns bool

getEditableLocaleIdsForElement() public static method #

Returns the editable locale IDs for a given element, taking user locale permissions into account.

public static array getEditableLocaleIdsForElement(BaseElementModel $element)
$element BaseElementModel
Returns array

isElementEditable() public static method #

Returns whether the given element is editable by the current user, taking user locale permissions into account.

public static bool isElementEditable(BaseElementModel $element)
$element BaseElementModel
Returns bool

setNextPrevOnElements() public static method #

Given an array of elements, will go through and set the appropriate "next" and "prev" elements on them.

public static void setNextPrevOnElements(array $elements)
$elements array The array of elements.

setUniqueUri() public static method #

Sets the URI on an element using a given URL format, tweaking its slug if necessary to ensure it's unique.

public static void setUniqueUri(BaseElementModel $element)
$element BaseElementModel

setValidSlug() public static method #

Sets a valid slug on a given element.

public static null setValidSlug(BaseElementModel $element)
$element BaseElementModel