2017-12-02 07:21:48 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Services;
|
|
|
|
|
2018-03-20 09:50:40 +08:00
|
|
|
use App\Interfaces\Service;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class ModuleService
|
|
|
|
*/
|
|
|
|
class ModuleService extends Service
|
2017-12-02 07:21:48 +08:00
|
|
|
{
|
|
|
|
protected static $adminLinks = [];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var array 0 == logged out, 1 == logged in
|
|
|
|
*/
|
2018-03-20 09:50:40 +08:00
|
|
|
protected static $frontendLinks = [
|
|
|
|
0 => [],
|
2018-08-27 00:40:04 +08:00
|
|
|
1 => [],
|
2018-03-20 09:50:40 +08:00
|
|
|
];
|
2017-12-02 07:21:48 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a module link in the frontend
|
2018-08-27 00:40:04 +08:00
|
|
|
*
|
2017-12-02 07:21:48 +08:00
|
|
|
* @param string $title
|
|
|
|
* @param string $url
|
|
|
|
* @param string $icon
|
2018-08-27 00:40:04 +08:00
|
|
|
* @param mixed $logged_in
|
2017-12-02 07:21:48 +08:00
|
|
|
*/
|
2018-03-20 09:50:40 +08:00
|
|
|
public function addFrontendLink(string $title, string $url, string $icon = '', $logged_in = true)
|
2017-12-02 07:21:48 +08:00
|
|
|
{
|
|
|
|
self::$frontendLinks[$logged_in][] = [
|
|
|
|
'title' => $title,
|
2018-03-20 09:50:40 +08:00
|
|
|
'url' => $url,
|
|
|
|
'icon' => 'pe-7s-users',
|
2017-12-02 07:21:48 +08:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get all of the frontend links
|
2018-08-27 00:40:04 +08:00
|
|
|
*
|
|
|
|
* @param mixed $logged_in
|
|
|
|
*
|
2017-12-02 07:21:48 +08:00
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function getFrontendLinks($logged_in): array
|
|
|
|
{
|
|
|
|
return self::$frontendLinks[$logged_in];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a module link in the admin panel
|
2018-08-27 00:40:04 +08:00
|
|
|
*
|
2017-12-02 07:21:48 +08:00
|
|
|
* @param string $title
|
|
|
|
* @param string $url
|
|
|
|
* @param string $icon
|
|
|
|
*/
|
2018-03-20 09:50:40 +08:00
|
|
|
public function addAdminLink(string $title, string $url, string $icon = '')
|
2017-12-02 07:21:48 +08:00
|
|
|
{
|
|
|
|
self::$adminLinks[] = [
|
|
|
|
'title' => $title,
|
2018-03-20 09:50:40 +08:00
|
|
|
'url' => $url,
|
2018-08-27 00:40:04 +08:00
|
|
|
'icon' => 'pe-7s-users',
|
2017-12-02 07:21:48 +08:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get all of the module links in the admin panel
|
2018-08-27 00:40:04 +08:00
|
|
|
*
|
2017-12-02 07:21:48 +08:00
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function getAdminLinks(): array
|
|
|
|
{
|
|
|
|
return self::$adminLinks;
|
|
|
|
}
|
|
|
|
}
|