I want to load the paragraph id in theme preprocess.
function theme_preprocess_layout(&$variables) {
$ID = $variables['content']['#paragraph'] ???; "contents - protected 'id' => array(1) = 68"
$variables['attributes'] = new Drupal\Core\Template\Attribute($variables['attributes']);
$variables['attributes']->addClass($ID);}
It gives me the available method "load($id)" but I don't know how to implement this method.
id()
method. So, try $variables['content']['#paragraph']->id();
. See api.drupal.org/api/drupal/….