-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e637b59
commit 9cfc9eb
Showing
2 changed files
with
63 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
/** | ||
* Joomlatools Pages | ||
* | ||
* @copyright Copyright (C) 2018 Johan Janssens and Timble CVBA. (http://www.timble.net) | ||
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> | ||
* @link https://github.com/joomlatools/joomlatools-pages for the canonical source repository | ||
*/ | ||
|
||
class ComPagesDispatcherRouterFile extends ComPagesDispatcherRouterAbstract | ||
{ | ||
protected function _initialize(KObjectConfig $config) | ||
{ | ||
$config->append([ | ||
'routes' => [] | ||
])->append([ | ||
'resolvers' => [ | ||
'regex' => ['routes' => $config->routes] | ||
] | ||
]); | ||
|
||
parent::_initialize($config); | ||
} | ||
|
||
public function resolve($route = null, array $parameters = array()) | ||
{ | ||
$result = false; | ||
if(count($this->getConfig()->routes)) | ||
{ | ||
if(!$route) | ||
{ | ||
$base = $this->getRequest()->getBasePath(); | ||
$url = urldecode( $this->getRequest()->getUrl()->getPath()); | ||
$parameters = $this->getRequest()->getUrl()->getQuery(true); | ||
|
||
$route = trim(str_replace(array($base, '/index.php'), '', $url), '/'); | ||
} | ||
|
||
$result = parent::resolve($route, $parameters); | ||
} | ||
|
||
return $result; | ||
} | ||
|
||
public function qualify(ComPagesDispatcherRouterRouteInterface $route, $replace = false) | ||
{ | ||
$url = clone $route; | ||
|
||
$path = $url->getPath(); | ||
if(!is_file($path)) | ||
{ | ||
//Qualify the path | ||
$path = trim($path, '/'); | ||
$base = $this->getRequest()->getBasePath(true); | ||
$url->setPath($base.'/'.$path); | ||
} | ||
|
||
return $url; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters