|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Ubiquity\seo; |
|
4
|
|
|
|
|
5
|
|
|
use Ubiquity\cache\CacheManager; |
|
6
|
|
|
use Ubiquity\utils\base\UIntrospection; |
|
7
|
|
|
use Ubiquity\utils\base\UFileSystem; |
|
8
|
|
|
use Ubiquity\controllers\Startup; |
|
9
|
|
|
|
|
10
|
|
|
class UrlParser { |
|
11
|
|
|
public static $frequencies=[ 'always','hourly','daily','weekly','monthly','yearly','never' ]; |
|
12
|
|
|
private $routes; |
|
13
|
|
|
private $config; |
|
14
|
|
|
|
|
15
|
|
|
public function __construct() { |
|
16
|
|
|
$this->routes=CacheManager::getRoutes(); |
|
17
|
|
|
$this->config=Startup::getConfig(); |
|
18
|
|
|
} |
|
19
|
|
|
|
|
20
|
|
|
public function parse() { |
|
21
|
|
|
$urls=[ ]; |
|
22
|
|
|
foreach ( $this->routes as $path => $route ) { |
|
23
|
|
|
$url=$this->parseUrl($path, $route); |
|
24
|
|
|
if (isset($url)) { |
|
25
|
|
|
$urls[]=$url; |
|
26
|
|
|
} |
|
27
|
|
|
} |
|
28
|
|
|
return $urls; |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
protected function parseUrl($path, $route) { |
|
32
|
|
|
if (isset($route["controller"])) { |
|
33
|
|
|
$controller=$route["controller"]; |
|
34
|
|
|
$action=$route["action"]; |
|
35
|
|
|
} elseif (isset($route["get"])) { |
|
36
|
|
|
return $this->parse($route["get"]); |
|
|
|
|
|
|
37
|
|
|
} else { |
|
38
|
|
|
return; |
|
39
|
|
|
} |
|
40
|
|
|
$url=new Url($path, $this->getLastModified($controller, $action)); |
|
41
|
|
|
return $url; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
protected function getLastModified($controller, $action) { |
|
45
|
|
|
$classCode=UIntrospection::getClassCode($controller); |
|
46
|
|
|
$lastModified=UFileSystem::lastModified(UIntrospection::getFileName($controller)); |
|
47
|
|
|
$reflexAction=new \ReflectionMethod([ $controller,$action ]); |
|
48
|
|
|
$actionCode=UIntrospection::getMethodCode($reflexAction, $classCode); |
|
49
|
|
|
$views=UIntrospection::getLoadedViews($reflexAction, $actionCode); |
|
50
|
|
|
foreach ( $views as $view ) { |
|
51
|
|
|
$file=ROOT . DS . "views" . DS . $view; |
|
52
|
|
|
$viewDate=UFileSystem::lastModified($file); |
|
53
|
|
|
if ($viewDate > $lastModified) |
|
54
|
|
|
$lastModified=$viewDate; |
|
55
|
|
|
} |
|
56
|
|
|
return $lastModified; |
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignorePhpDoc annotation to the duplicate definition and it will be ignored.