-
Notifications
You must be signed in to change notification settings - Fork 1
/
router.php
78 lines (68 loc) · 1.23 KB
/
router.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
/**
* @since 3.0
* @version 3.x
* @author Denys D. Nosov ([email protected])
* @copyright (C) 2011-2020 by Denys D. Nosov (https://joomla-ua.org)
* @license GNU General Public License version 2 or later
*
* @package JUHome Component
*/
use Joomla\CMS\Component\Router\RouterView;
defined('_JEXEC') or die;
class HomeRouter extends RouterView
{
protected bool $noIDs = false;
/**
* @param $query
*
* @return array
*
* @since 1.0
*/
public function build(&$query)
{
parent::build($query);
if(isset($query[ 'view' ]))
{
unset($query[ 'view' ]);
}
return [];
}
/**
* @param $segments
*
* @return array
*
* @since 1.0
*/
public function parse(&$segments)
{
parent::parse($segments);
if($segments[ 0 ] === $this->app->getMenu()->getActive()->alias)
{
return [ 'view' => 'home' ];
}
return [ 'view' => 'homes' ];
}
}
/**
* @param $query
*
* @return array
*
* @since 1.0
*/
function homeBuildRoute(&$query)
{
return (new HomeRouter($this->app, $this->app->getMenu()))->build($query);
}
/**
* @return array
*
* @since 1.0
*/
function homeParseRoute()
{
return (new HomeRouter($this->app, $this->app->getMenu()))->parse($segments);
}