Ubiquity  2.0.0
php rapid development framework
ControllerSeo.php
Go to the documentation of this file.
1 <?php
7 
9  private $name;
10  private $urlsFile;
12  private $route;
13 
14  public function __construct($className=null){
15  if(isset($className) && \class_exists($className)){
17  if($route){
18  $this->route=$route["path"];
19  }
20  $ctrl=new $className();
21  $this->name=$className;
22  $this->urlsFile=$ctrl->_getUrlsFilename();
23  $this->siteMapTemplate=$ctrl->_getSeoTemplateFilename();
24  }
25  }
29  public function getName() {
30  return $this->name;
31  }
32 
36  public function getUrlsFile() {
37  return $this->urlsFile;
38  }
39 
43  public function getSiteMapTemplate() {
45  }
46 
50  public function getRoute() {
51  return $this->route;
52  }
53 
57  public function setName($name) {
58  $this->name = $name;
59  }
60 
64  public function setUrlsFile($urlsFile) {
65  $this->urlsFile = $urlsFile;
66  }
67 
72  $this->siteMapTemplate = $siteMapTemplate;
73  }
74 
78  public function setRoute($route) {
79  $this->route = $route;
80  }
81 
82  public static function init(){
83  $result=[ ];
84  $config=Startup::getConfig();
85 
86  $files=CacheManager::getControllersFiles($config, true);
87  try {
88  $restCtrls=CacheManager::getRestCache();
89  } catch ( \Exception $e ) {
90  $restCtrls=[ ];
91  }
92 
93  foreach ( $files as $file ) {
94  if (is_file($file)) {
95  $controllerClass=ClassUtils::getClassFullNameFromFile($file);
96  if (isset($restCtrls[$controllerClass]) === false) {
97  $reflect=new \ReflectionClass($controllerClass);
98  if (!$reflect->isAbstract() && $reflect->isSubclassOf('Ubiquity\controllers\seo\SeoController')) {
99  $result[]=new ControllerSeo($controllerClass);
100  }
101  }
102  }
103  }
104  return $result;
105  }
106 
107 }
static getClassFullNameFromFile($filePathName)
get the full name (name \ namespace) of a class from its file path result example: (string) "I\Am\The...
Definition: ClassUtils.php:15
static getRouteInfoByControllerAction($controller, $action)
Definition: Router.php:49
static getControllersFiles(&$config, $silent=false)