-
Notifications
You must be signed in to change notification settings - Fork 1
/
plugin.php
126 lines (115 loc) · 3.24 KB
/
plugin.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<?php
/**
* Plugin.php
*
* This file is part of the Xpressengine package.
*
* PHP version 7
*
* @category NewsClient
* @package Xpressengine\Plugins\NewsClient
* @author XE Developers <developers@xpressengine.com>
* @copyright 2019 Copyright XEHub Corp. <https://www.xehub.io>
* @license http://www.gnu.org/licenses/lgpl-3.0-standalone.html LGPL
* @link https://xpressengine.io
*/
namespace Xpressengine\Plugins\NewsClient;
use Frontend;
use Presenter;
use Route;
use XeLang;
use Xpressengine\Plugin\AbstractPlugin;
/**
* Plugin
*
* @category NewsClient
* @package Xpressengine\Plugins\NewsClient
* @author XE Developers <developers@xpressengine.com>
* @copyright 2019 Copyright XEHub Corp. <https://www.xehub.io>
* @license http://www.gnu.org/licenses/lgpl-3.0-standalone.html LGPL
* @link https://xpressengine.io
*/
class Plugin extends AbstractPlugin
{
protected $handler;
/**
* 이 메소드는 활성화(activate) 된 플러그인이 부트될 때 항상 실행됩니다.
*
* @return void
*/
public function boot()
{
// implement code
$this->route();
$register = app('xe.pluginRegister');
$register->add(NewsWidget::class);
}
/**
* register
*
* @return void
*/
public function register()
{
app()->bind('xe.plugin.news_client', function () {
return $this;
});
app()->singleton(Handler::class, function ($app) {
return new Handler(
$app['cache.store'],
$app['xe.config'],
$app['xe.plugin'],
$app['db'],
$app['request']
);
});
app()->alias(Handler::class, 'xe.news_client');
}
/**
* register route
*
* @return void
*/
protected function route()
{
Route::settings($this->getId(), function () {
Route::group(['prefix' => 'setting', 'as' => 'news_client::setting'], function () {
Route::get('/', 'ManagerController@getSetting');
Route::post('/', 'ManagerController@postSetting');
});
}, ['namespace' => __NAMESPACE__]);
}
/**
* 플러그인이 활성화될 때 실행할 코드를 여기에 작성한다.
*
* @param string|null $installedVersion 현재 XpressEngine에 설치된 플러그인의 버전정보
*
* @return void
*/
public function activate($installedVersion = null)
{
if (!$this->getHandler()->getConfig()) {
$this->getHandler()->setAgree(false);
}
XeLang::putFromLangDataSource('news_client', base_path('plugins/news_client/langs/lang.php'));
}
/**
* 플러그인의 설정페이지 주소를 반환한다.
* 플러그인 목록에서 플러그인의 '관리' 버튼을 누를 경우 이 페이지에서 반환하는 주소로 연결된다.
*
* @return string
*/
public function getSettingsURI()
{
return route('news_client::setting');
}
/**
* get handler
*
* @return \Illuminate\Foundation\Application|mixed
*/
public function getHandler()
{
return app(Handler::class);
}
}