3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace PortlandLabs\DomainMapper\Url; use Concrete\Core\Url\Components\Path; use Concrete\Core\Url\Resolver\PathUrlResolver; use Concrete\Core\Url\Resolver\UrlResolverInterface; use PortlandLabs\DomainMapper\Map\DomainMap; /** * Class Resolver * URL Resolver for handling domain mapped urls, this will intercept mapped paths and alter the outputted links to * remove the prefix and set the proper host. * * @package PortlandLabs\DomainMapper\Url */ class Resolver implements UrlResolverInterface { public function resolve(array $arguments, $resolved = null) { $args = $arguments; $path = array_shift($args); /** @var DomainMap $map */ $map = \Core::make('domain_mapper/config_map'); if ($path instanceof \Page) { $path = $path->getCollectionPath(); $arguments[0] = $path; } if (is_scalar($path) && $path) { $path = (string)$path; $resolved_url = $resolved; if (!$resolved) { /** @var PathUrlResolver $path_resolver */ $path_resolver = \URL::getResolver('concrete.path'); $resolved_url = $path_resolver->resolve($arguments); } $url = $resolved_url; if ($url) { if ($prefix = $map->getPath($url->getHost())) { $prefix_path = new Path($prefix); $real_path = $url->getPath(); if (substr(strtolower($real_path), 0, strlen($prefix_path)) === strtolower($prefix_path)) { $relative_path = $real_path->getRelativePath($prefix_path); $url = $url->setPath($relative_path); } else { $url = $url->setHost(\Config::get('concrete.seo.canonical_host')); } return $url; } if ($domain = $map->getDomain($url->getPath())) { $map_path = new Path(rtrim($map->getPath($domain), '/')); $url_path = new Path(rtrim($url->getPath(), '/')); foreach ($map_path->toArray() as $key => $path_node) { $url_path->offsetUnset($key); } $url = $url->setPath($url_path); $url = $url->setHost($domain); return $url; } } } return $resolved; } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sJA4Z
function name:  (null)
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   DECLARE_CLASS                                            'portlandlabs%5Cdomainmapper%5Curl%5Cresolver'
   80     1      > RETURN                                                   1

Class PortlandLabs\DomainMapper\Url\Resolver:
Function resolve:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 18
Branch analysis from position: 13
2 jumps found. (Code = 46) Position 1 = 22, Position 2 = 23
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 133
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 37
Branch analysis from position: 29
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 133
Branch analysis from position: 39
2 jumps found. (Code = 43) Position 1 = 46, Position 2 = 86
Branch analysis from position: 46
2 jumps found. (Code = 43) Position 1 = 69, Position 2 = 78
Branch analysis from position: 69
1 jumps found. (Code = 42) Position 1 = 85
Branch analysis from position: 85
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 78
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 86
2 jumps found. (Code = 43) Position 1 = 93, Position 2 = 133
Branch analysis from position: 93
2 jumps found. (Code = 77) Position 1 = 117, Position 2 = 123
Branch analysis from position: 117
2 jumps found. (Code = 78) Position 1 = 118, Position 2 = 123
Branch analysis from position: 118
1 jumps found. (Code = 42) Position 1 = 117
Branch analysis from position: 117
Branch analysis from position: 123
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 123
Branch analysis from position: 133
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 133
Branch analysis from position: 37
Branch analysis from position: 133
Branch analysis from position: 23
Branch analysis from position: 18
filename:       /in/sJA4Z
function name:  resolve
number of ops:  135
compiled vars:  !0 = $arguments, !1 = $resolved, !2 = $args, !3 = $path, !4 = $map, !5 = $resolved_url, !6 = $path_resolver, !7 = $url, !8 = $prefix, !9 = $prefix_path, !10 = $real_path, !11 = $relative_path, !12 = $domain, !13 = $map_path, !14 = $url_path, !15 = $path_node, !16 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
   22     2        ASSIGN                                                   !2, !0
   23     3        INIT_NS_FCALL_BY_NAME                                    'PortlandLabs%5CDomainMapper%5CUrl%5Carray_shift'
          4        SEND_VAR_EX                                              !2
          5        DO_FCALL                                      0  $18     
          6        ASSIGN                                                   !3, $18
   25     7        INIT_STATIC_METHOD_CALL                                  'Core', 'make'
          8        SEND_VAL_EX                                              'domain_mapper%2Fconfig_map'
          9        DO_FCALL                                      0  $20     
         10        ASSIGN                                                   !4, $20
   27    11        INSTANCEOF                                               !3, 'Page'
         12      > JMPZ                                                     ~22, ->18
   28    13    >   INIT_METHOD_CALL                                         !3, 'getCollectionPath'
         14        DO_FCALL                                      0  $23     
         15        ASSIGN                                                   !3, $23
   29    16        ASSIGN_DIM                                               !0, 0
         17        OP_DATA                                                  !3
   32    18    >   INIT_NS_FCALL_BY_NAME                                    'PortlandLabs%5CDomainMapper%5CUrl%5Cis_scalar'
         19        SEND_VAR_EX                                              !3
         20        DO_FCALL                                      0  $26     
         21      > JMPZ_EX                                          ~27     $26, ->23
         22    >   BOOL                                             ~27     !3
         23    > > JMPZ                                                     ~27, ->133
   33    24    >   CAST                                          6  ~28     !3
         25        ASSIGN                                                   !3, ~28
   35    26        ASSIGN                                                   !5, !1
   36    27        BOOL_NOT                                         ~31     !1
         28      > JMPZ                                                     ~31, ->37
   38    29    >   INIT_STATIC_METHOD_CALL                                  'URL', 'getResolver'
         30        SEND_VAL_EX                                              'concrete.path'
         31        DO_FCALL                                      0  $32     
         32        ASSIGN                                                   !6, $32
   39    33        INIT_METHOD_CALL                                         !6, 'resolve'
         34        SEND_VAR_EX                                              !0
         35        DO_FCALL                                      0  $34     
         36        ASSIGN                                                   !5, $34
   42    37    >   ASSIGN                                                   !7, !5
   44    38      > JMPZ                                                     !7, ->133
   45    39    >   INIT_METHOD_CALL                                         !4, 'getPath'
         40        INIT_METHOD_CALL                                         !7, 'getHost'
         41        DO_FCALL                                      0  $37     
         42        SEND_VAR_NO_REF_EX                                       $37
         43        DO_FCALL                                      0  $38     
         44        ASSIGN                                           ~39     !8, $38
         45      > JMPZ                                                     ~39, ->86
   46    46    >   NEW                                              $40     'Concrete%5CCore%5CUrl%5CComponents%5CPath'
         47        SEND_VAR_EX                                              !8
         48        DO_FCALL                                      0          
         49        ASSIGN                                                   !9, $40
   47    50        INIT_METHOD_CALL                                         !7, 'getPath'
         51        DO_FCALL                                      0  $43     
         52        ASSIGN                                                   !10, $43
   49    53        INIT_NS_FCALL_BY_NAME                                    'PortlandLabs%5CDomainMapper%5CUrl%5Csubstr'
         54        INIT_NS_FCALL_BY_NAME                                    'PortlandLabs%5CDomainMapper%5CUrl%5Cstrtolower'
         55        SEND_VAR_EX                                              !10
         56        DO_FCALL                                      0  $45     
         57        SEND_VAR_NO_REF_EX                                       $45
         58        SEND_VAL_EX                                              0
         59        INIT_NS_FCALL_BY_NAME                                    'PortlandLabs%5CDomainMapper%5CUrl%5Cstrlen'
         60        SEND_VAR_EX                                              !9
         61        DO_FCALL                                      0  $46     
         62        SEND_VAR_NO_REF_EX                                       $46
         63        DO_FCALL                                      0  $47     
         64        INIT_NS_FCALL_BY_NAME                                    'PortlandLabs%5CDomainMapper%5CUrl%5Cstrtolower'
         65        SEND_VAR_EX                                              !9
         66        DO_FCALL                                      0  $48     
         67        IS_IDENTICAL                                             $47, $48
         68      > JMPZ                                                     ~49, ->78
   50    69    >   INIT_METHOD_CALL                                         !10, 'getRelativePath'
         70        SEND_VAR_EX                                              !9
         71        DO_FCALL                                      0  $50     
         72        ASSIGN                                                   !11, $50
   52    73        INIT_METHOD_CALL                                         !7, 'setPath'
         74        SEND_VAR_EX                                              !11
         75        DO_FCALL                                      0  $52     
         76        ASSIGN                                                   !7, $52
         77      > JMP                                                      ->85
   54    78    >   INIT_METHOD_CALL                                         !7, 'setHost'
         79        INIT_STATIC_METHOD_CALL                                  'Config', 'get'
         80        SEND_VAL_EX                                              'concrete.seo.canonical_host'
         81        DO_FCALL                                      0  $54     
         82        SEND_VAR_NO_REF_EX                                       $54
         83        DO_FCALL                                      0  $55     
         84        ASSIGN                                                   !7, $55
   57    85    > > RETURN                                                   !7
   60    86    >   INIT_METHOD_CALL                                         !4, 'getDomain'
         87        INIT_METHOD_CALL                                         !7, 'getPath'
         88        DO_FCALL                                      0  $57     
         89        SEND_VAR_NO_REF_EX                                       $57
         90        DO_FCALL                                      0  $58     
         91        ASSIGN                                           ~59     !12, $58
         92      > JMPZ                                                     ~59, ->133
   61    93    >   NEW                                              $60     'Concrete%5CCore%5CUrl%5CComponents%5CPath'
         94        INIT_NS_FCALL_BY_NAME                                    'PortlandLabs%5CDomainMapper%5CUrl%5Crtrim'
         95        INIT_METHOD_CALL                                         !4, 'getPath'
         96        SEND_VAR_EX                                              !12
         97        DO_FCALL                                      0  $61     
         98        SEND_VAR_NO_REF_EX                                       $61
         99        SEND_VAL_EX                                              '%2F'
        100        DO_FCALL                                      0  $62     
        101        SEND_VAR_NO_REF_EX                                       $62
        102        DO_FCALL                                      0          
        103        ASSIGN                                                   !13, $60
   62   104        NEW                                              $65     'Concrete%5CCore%5CUrl%5CComponents%5CPath'
        105        INIT_NS_FCALL_BY_NAME                                    'PortlandLabs%5CDomainMapper%5CUrl%5Crtrim'
        106        INIT_METHOD_CALL                                         !7, 'getPath'
        107        DO_FCALL                                      0  $66     
        108        SEND_VAR_NO_REF_EX                                       $66
        109        SEND_VAL_EX                                              '%2F'
        110        DO_FCALL                                      0  $67     
        111        SEND_VAR_NO_REF_EX                                       $67
        112        DO_FCALL                                      0          
        113        ASSIGN                                                   !14, $65
   64   114        INIT_METHOD_CALL                                         !13, 'toArray'
        115        DO_FCALL                                      0  $70     
        116      > FE_RESET_R                                       $71     $70, ->123
        117    > > FE_FETCH_R                                       ~72     $71, !15, ->123
        118    >   ASSIGN                                                   !16, ~72
   65   119        INIT_METHOD_CALL                                         !14, 'offsetUnset'
        120        SEND_VAR_EX                                              !16
        121        DO_FCALL                                      0          
   64   122      > JMP                                                      ->117
        123    >   FE_FREE                                                  $71
   68   124        INIT_METHOD_CALL                                         !7, 'setPath'
        125        SEND_VAR_EX                                              !14
        126        DO_FCALL                                      0  $75     
        127        ASSIGN                                                   !7, $75
   69   128        INIT_METHOD_CALL                                         !7, 'setHost'
        129        SEND_VAR_EX                                              !12
        130        DO_FCALL                                      0  $77     
        131        ASSIGN                                                   !7, $77
   71   132      > RETURN                                                   !7
   77   133    > > RETURN                                                   !1
   78   134*     > RETURN                                                   null

End of function resolve

End of class PortlandLabs\DomainMapper\Url\Resolver.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
166.93 ms | 1408 KiB | 25 Q