function Html::getClass

Same name in other branches
  1. 9 core/lib/Drupal/Component/Utility/Html.php \Drupal\Component\Utility\Html::getClass()
  2. 10 core/lib/Drupal/Component/Utility/Html.php \Drupal\Component\Utility\Html::getClass()
  3. 11.x core/lib/Drupal/Component/Utility/Html.php \Drupal\Component\Utility\Html::getClass()

Prepares a string for use as a valid class name.

Do not pass one string containing multiple classes as they will be incorrectly concatenated with dashes, i.e. "one two" will become "one-two".

Parameters

mixed $class: The class name to clean. It can be a string or anything that can be cast to string.

Return value

string The cleaned class name.

23 calls to Html::getClass()
BlockContentForm::form in core/modules/block_content/src/BlockContentForm.php
Gets the actual form array to be built.
BlockForm::submitForm in core/modules/block/src/BlockForm.php
This is the default entity object builder function. It is called before any other submit handler to build the new entity object to be used by the following submit handlers. At this point of the form workflow the entity is validated and the form stateā€¦
BlockListBuilder::buildBlocksForm in core/modules/block/src/BlockListBuilder.php
Builds the main "Blocks" portion of the form.
BlockRenderOrderTest::testBlockRenderOrder in core/modules/block/tests/src/Functional/BlockRenderOrderTest.php
Tests the render order of the blocks.
BlockTest::moveBlockToRegion in core/modules/block/tests/src/Functional/BlockTest.php
Moves a block to a given region via the UI and confirms the result.

... See full list

File

core/lib/Drupal/Component/Utility/Html.php, line 71

Class

Html
Provides DOMDocument helpers for parsing and serializing HTML strings.

Namespace

Drupal\Component\Utility

Code

public static function getClass($class) {
    $class = (string) $class;
    if (!isset(static::$classes[$class])) {
        static::$classes[$class] = static::cleanCssIdentifier(mb_strtolower($class));
    }
    return static::$classes[$class];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.