
| Current Path : /var/www/html/strat/web/modules/contrib/ckeditor5_premium_features/src/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : /var/www/html/strat/web/modules/contrib/ckeditor5_premium_features/src/CKeditorFieldKeyHelper.php |
<?php
/*
* Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see https://ckeditor.com/legal/ckeditor-oss-license
*/
namespace Drupal\ckeditor5_premium_features;
use Drupal\ckeditor5_premium_features\Utility\Html;
/**
* Class for generating unique field IDs.
*/
class CKeditorFieldKeyHelper {
/**
* Gets the element unique HTML ID.
*
* @param string $elementId
* Form element ID.
*
* @return string
* The ID.
*/
public static function getElementUniqueId(string $elementId): string {
$id = 'id-' . hash('crc32', static::cleanElementDrupalId($elementId));
return Html::getId($id);
}
/**
* Returns cleaned form element ID (without "--POSTFIX").
*
* @param string $elementId
* Form element ID.
*/
public static function cleanElementDrupalId(string $elementId): string {
$elementId = str_replace('_', '-', $elementId);
$elementParts = explode('--', $elementId);
return reset($elementParts);
}
}