Class craft\helpers\ElementHelper
- Inheritance
- craft\helpers\ElementHelper
- Available since version
- 3.0
- Source Code
- https://github.com/craftcms/cms/blob/master/src/helpers/ElementHelper.php
Class ElementHelper
Method | Description | Defined By |
---|---|---|
createSlug() |
Creates a slug based on a given string. | craft\helpers\ElementHelper |
doesUriFormatHaveSlugTag() |
Returns whether a given URL format has a proper {slug} tag. | craft\helpers\ElementHelper |
editableSiteIdsForElement() |
Returns the editable site IDs for a given element, taking user permissions into account. | craft\helpers\ElementHelper |
findSource() |
Returns an element type's source definition based on a given source key/path and context. | craft\helpers\ElementHelper |
isElementEditable() |
Returns whether the given element is editable by the current user, taking user permissions into account. | craft\helpers\ElementHelper |
setNextPrevOnElements() |
Given an array of elements, will go through and set the appropriate "next" and "prev" elements on them. | craft\helpers\ElementHelper |
setUniqueUri() |
Sets the URI on an element using a given URL format, tweaking its slug if necessary to ensure it's unique. | craft\helpers\ElementHelper |
supportedSitesForElement() |
Returns a list of sites that a given element supports. | craft\helpers\ElementHelper |
Method Details
createSlug()
public static method
#
Creates a slug based on a given string.
public static string createSlug ( \craft\helpers\string $str )
$str |
string |
doesUriFormatHaveSlugTag()
public static method
#
Returns whether a given URL format has a proper {slug} tag.
public static boolean doesUriFormatHaveSlugTag ( \craft\helpers\string $uriFormat )
$uriFormat |
string |
editableSiteIdsForElement()
public static method
#
Returns the editable site IDs for a given element, taking user permissions into account.
public static array editableSiteIdsForElement ( craft\base\ElementInterface $element )
$element |
craft\base\ElementInterface |
findSource()
public static method
#
Returns an element type's source definition based on a given source key/path and context.
public static array, null findSource ( \craft\helpers\string $elementType, \craft\helpers\string $sourceKey, \craft\helpers\string $context = null )
$elementType |
string | The element type class |
$sourceKey |
string | The source key/path |
$context |
string, null | The context |
return | array, null | The source definition, or null if it cannot be found |
---|
isElementEditable()
public static method
#
Returns whether the given element is editable by the current user, taking user permissions into account.
public static boolean isElementEditable ( craft\base\ElementInterface $element )
$element |
craft\base\ElementInterface |
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 |
craft\base\ElementInterface[] | 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 ( craft\base\ElementInterface $element )
$element |
craft\base\ElementInterface | |
throws | craft\errors\OperationAbortedException | if a unique URI could not be found |
---|
supportedSitesForElement()
public static method
#
Returns a list of sites that a given element supports.
Each site is represented as an array with 'siteId' and 'enabledByDefault' keys.
public static array supportedSitesForElement ( craft\base\ElementInterface $element )
$element |
craft\base\ElementInterface | |
throws | yii\base\Exception | if any of the element's supported sites are invalid |
---|