1<?php 2 3namespace ComboStrap; 4 5class RouterRedirection 6{ 7 8 9 /** 10 * The combostrap canonical where the doc is 11 */ 12 public const PERMANENT_REDIRECT_CANONICAL = "permanent:redirect"; 13 /** 14 * For permanent, see https://developers.google.com/search/docs/advanced/crawling/301-redirects 15 * was `Http` (301) 16 */ 17 public const REDIRECT_PERMANENT_METHOD = 'permanent'; 18 /** 19 * 404 (See other) (when best page name is calculated) 20 */ 21 public const REDIRECT_NOTFOUND_METHOD = "notfound"; 22 23 /** 24 * Transparent (Just setting another id without HTTP 3xx) 25 */ 26 const REDIRECT_TRANSPARENT_METHOD = 'transparent'; 27 28 /** 29 * Extended Permalink (abbreviated page id at the end) 30 */ 31 public const TARGET_ORIGIN_PERMALINK_EXTENDED = "extendedPermalink"; 32 /** 33 * Named Permalink (canonical) 34 */ 35 public const TARGET_ORIGIN_CANONICAL = 'canonical'; 36 public const TARGET_ORIGIN_START_PAGE = 'startPage'; 37 /** 38 * Identifier Permalink (full page id) 39 */ 40 public const TARGET_ORIGIN_PERMALINK = "permalink"; 41 public const TARGET_ORIGIN_SEARCH_ENGINE = 'searchEngine'; 42 public const TARGET_ORIGIN_PAGE_RULES = 'pageRules'; 43 public const TARGET_ORIGIN_ALIAS = 'alias'; 44 public const TARGET_ORIGIN_BEST_END_PAGE_NAME = 'bestEndPageName'; 45 public const TARGET_ORIGIN_BEST_PAGE_NAME = 'bestPageName'; 46 public const TARGET_ORIGIN_BEST_NAMESPACE = 'bestNamespace'; 47 public const TARGET_ORIGIN_WELL_KNOWN = 'well-known'; 48 public const TARGET_ORIGIN_SHADOW_BANNED = "shadowBanned"; 49 50 51 private RouterRedirectionBuilder $routerBuilder; 52 53 public function __construct(RouterRedirectionBuilder $routerRedirectionBuilder) 54 { 55 $this->routerBuilder=$routerRedirectionBuilder; 56 } 57 58 public function getOrigin(): string 59 { 60 return $this->routerBuilder->getOrigin(); 61 } 62 63 public function getType(): string 64 { 65 return $this->routerBuilder->getType(); 66 } 67 68 public function getTargetAsString(): string 69 { 70 $markupPath = $this->getTargetMarkupPath(); 71 if ($markupPath !== null){ 72 return $markupPath->toAbsoluteId(); 73 } 74 75 $targetUrl = $this->getTargetUrl(); 76 if($targetUrl!==null){ 77 return $targetUrl->toAbsoluteUrlString(); 78 } 79 return ""; 80 81 } 82 83 public function getTargetUrl(): ?Web\Url 84 { 85 return $this->routerBuilder->getTargetUrl(); 86 } 87 88 public function getTargetMarkupPath(): ?MarkupPath 89 { 90 return $this->routerBuilder->getTargetMarkupPath(); 91 } 92 93 94} 95