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