1<?php 2 3namespace ComboStrap; 4 5 6 7 8class DropDownTag 9{ 10 11 public const TAG = "dropdown"; 12 13 public static function renderEnterXhtml(TagAttributes $tagAttributes): string 14 { 15 16 $dropDownId = ExecutionContext::getActualOrCreateFromEnv() 17 ->getIdManager() 18 ->generateNewHtmlIdForComponent(DropDownTag::TAG); 19 20 $name = $tagAttributes->getValueAndRemoveIfPresent("name","unknown name"); 21 $tagAttributes->addClassName("nav-item"); 22 $tagAttributes->addClassName("dropdown"); 23 24 /** 25 * New namespace for data attribute 26 */ 27 $bootstrapNameSpace = Bootstrap::getDataNamespace(); 28 $dataToggleAttribute = "data{$bootstrapNameSpace}-toggle"; 29 $liHtml = $tagAttributes->toHtmlEnterTag("li"); 30 return <<<EOF 31$liHtml 32 <a id="$dropDownId" href="#" class="nav-link dropdown-toggle active" {$dataToggleAttribute}="dropdown" role="button" aria-haspopup="true" aria-expanded="false" title="$name">$name</a> 33 <div class="dropdown-menu" aria-labelledby="$dropDownId"> 34EOF; 35 36 } 37 38 public static function renderExitXhtml(): string 39 { 40 return '</div></li>'; 41 } 42} 43