1<?php 2 3 4namespace ComboStrap; 5 6 7class Align 8{ 9 10 /** 11 * @param TagAttributes $attributes 12 */ 13 public static function processAlignAttributes(&$attributes) 14 { 15 // The class shortcut 16 $align = MediaLink::ALIGN_KEY; 17 if ($attributes->hasComponentAttribute($align)) { 18 19 $alignValue = $attributes->getValueAndRemove($align); 20 21 if ($alignValue !== null && $alignValue !== "") { 22 switch ($alignValue) { 23 case "center": 24 $attributes->addClassName(PluginUtility::CENTER_CLASS); 25 break; 26 case "right": 27 case "end": 28 if (Bootstrap::getBootStrapMajorVersion()==Bootstrap::BootStrapFourMajorVersion) { 29 $attributes->addStyleDeclarationIfNotSet("margin-left", "auto"); 30 } else { 31 $attributes->addClassName("ms-auto"); 32 } 33 $attributes->addStyleDeclarationIfNotSet("width", "fit-content"); 34 break; 35 } 36 37 /** 38 * For inline element, 39 * center should be a block 40 * (svg is not a block by default for instance) 41 * ! 42 * this should not be the case for flex block such as a row 43 * therefore the condition 44 * ! 45 */ 46 if (in_array($attributes->getLogicalTag(), TagAttributes::INLINE_LOGICAL_ELEMENTS)) { 47 $attributes->addClassName("d-block"); 48 } 49 } 50 } 51 } 52} 53