Skip to content

Commit 7b645ce

Browse files
committed
Admin 1.2.0
1 parent 82c5c69 commit 7b645ce

21 files changed

+663
-531
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
<a name="1.2.0"></a>
2+
# [1.2.0](https://github.com/flextype-plugins/admin) (2020-08-19)
3+
4+
### Features
5+
6+
* **core** update code base for new Flextype 0.9.10
7+
18
<a name="1.1.1"></a>
29
# [1.1.1](https://github.com/flextype-plugins/admin) (2020-08-xx)
310

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
![preview](https://github.com/flextype-plugins/admin/raw/dev/preview.png)
44

55
<p align="center">
6-
<a href="https://github.com/flextype-plugins/admin/releases"><img alt="Version" src="https://img.shields.io/github/release/flextype-plugins/admin.svg?label=version&color=black"></a> <a href="https://github.com/flextype-plugins/admin"><img src="https://img.shields.io/badge/license-MIT-blue.svg?color=black" alt="License"></a> <a href="https://github.com/flextype-plugins/admin"><img src="https://img.shields.io/github/downloads/flextype-plugins/admin/total.svg?color=black" alt="Total downloads"></a> <a href="https://github.com/flextype/flextype"><img src="https://img.shields.io/badge/Flextype-0.9.9-green.svg?color=black" alt="Flextype"></a> <a href="https://crowdin.com/project/flextype-plugin-admin"><img src="https://d322cqt584bo4o.cloudfront.net/flextype-plugin-admin/localized.svg?color=black" alt="Crowdin"></a> <a href="https://scrutinizer-ci.com/g/flextype-plugins/admin?branch=dev&color=black"><img src="https://img.shields.io/scrutinizer/g/flextype-plugins/admin.svg?branch=dev&color=black" alt="Quality Score"></a> <a href=""><img src="https://img.shields.io/discord/423097982498635778.svg?logo=discord&colorB=728ADA&label=Discord%20Chat" alt="Discord"></a>
6+
<a href="https://github.com/flextype-plugins/admin/releases"><img alt="Version" src="https://img.shields.io/github/release/flextype-plugins/admin.svg?label=version&color=black"></a> <a href="https://github.com/flextype-plugins/admin"><img src="https://img.shields.io/badge/license-MIT-blue.svg?color=black" alt="License"></a> <a href="https://github.com/flextype-plugins/admin"><img src="https://img.shields.io/github/downloads/flextype-plugins/admin/total.svg?color=black" alt="Total downloads"></a> <a href="https://github.com/flextype/flextype"><img src="https://img.shields.io/badge/Flextype-0.9.10-green.svg?color=black" alt="Flextype"></a> <a href="https://crowdin.com/project/flextype-plugin-admin"><img src="https://d322cqt584bo4o.cloudfront.net/flextype-plugin-admin/localized.svg?color=black" alt="Crowdin"></a> <a href="https://scrutinizer-ci.com/g/flextype-plugins/admin?branch=dev&color=black"><img src="https://img.shields.io/scrutinizer/g/flextype-plugins/admin.svg?branch=dev&color=black" alt="Quality Score"></a> <a href=""><img src="https://img.shields.io/discord/423097982498635778.svg?logo=discord&colorB=728ADA&label=Discord%20Chat" alt="Discord"></a>
77
</p>
88

99
Admin Panel plugin for Flextype.
@@ -14,7 +14,7 @@ The following dependencies need to be installed for Form Admin Plugin.
1414

1515
| Item | Version | Download |
1616
|---|---|---|
17-
| [flextype](https://github.com/flextype/flextype) | 0.9.9 | [download](https://github.com/flextype/flextype/releases) |
17+
| [flextype](https://github.com/flextype/flextype) | 0.9.10 | [download](https://github.com/flextype/flextype/releases) |
1818
| [twig](https://github.com/flextype-plugins/twig) | >=1.0.0 | [download](https://github.com/flextype-plugins/twig/releases) |
1919
| [form](https://github.com/flextype-plugins/form) | >=1.0.0 | [download](https://github.com/flextype-plugins/form/releases) |
2020
| [form-admin](https://github.com/flextype-plugins/form-admin) | >=1.0.0 | [download](https://github.com/flextype-plugins/form-admin/releases) |

app/Controllers/ApiAccessController.php

Lines changed: 43 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,23 @@
1414
use function Flextype\Component\I18n\__;
1515
use function random_bytes;
1616
use function time;
17-
use Flextype\App\Foundation\Container;
1817

19-
class ApiAccessController extends Container
18+
19+
class ApiAccessController
2020
{
21+
/**
22+
* Flextype Application
23+
*/
24+
protected $flextype;
25+
26+
/**
27+
* __construct
28+
*/
29+
public function __construct($flextype)
30+
{
31+
$this->flextype = $flextype;
32+
}
33+
2134
/**
2235
* Access Index page
2336
*
@@ -37,26 +50,26 @@ public function index(Request $request, Response $response) : Response
3750
}
3851
}
3952

40-
return $this->twig->render(
53+
return $this->flextype->container('twig')->render(
4154
$response,
4255
'plugins/admin/templates/system/api/access/index.html',
4356
[
4457
'menu_item' => 'api',
4558
'tokens' => $tokens,
4659
'links' => [
4760
'api' => [
48-
'link' => $this->router->pathFor('admin.api.index'),
61+
'link' => $this->flextype->container('router')->pathFor('admin.api.index'),
4962
'title' => __('admin_api'),
5063
],
5164
'api_Access' => [
52-
'link' => $this->router->pathFor('admin.api_access.index'),
65+
'link' => $this->flextype->container('router')->pathFor('admin.api_access.index'),
5366
'title' => __('admin_access'),
5467
'active' => true
5568
],
5669
],
5770
'buttons' => [
5871
'api_access_add' => [
59-
'link' => $this->router->pathFor('admin.api_access.add'),
72+
'link' => $this->flextype->container('router')->pathFor('admin.api_access.add'),
6073
'title' => __('admin_create_new_token')
6174
],
6275
],
@@ -72,22 +85,22 @@ public function index(Request $request, Response $response) : Response
7285
*/
7386
public function add(Request $request, Response $response) : Response
7487
{
75-
return $this->twig->render(
88+
return $this->flextype->container('twig')->render(
7689
$response,
7790
'plugins/admin/templates/system/api/access/add.html',
7891
[
7992
'menu_item' => 'api',
8093
'links' => [
8194
'api' => [
82-
'link' => $this->router->pathFor('admin.api.index'),
95+
'link' => $this->flextype->container('router')->pathFor('admin.api.index'),
8396
'title' => __('admin_api'),
8497
],
8598
'api_access' => [
86-
'link' => $this->router->pathFor('admin.api_access.index'),
99+
'link' => $this->flextype->container('router')->pathFor('admin.api_access.index'),
87100
'title' => __('admin_access')
88101
],
89102
'api_access_add' => [
90-
'link' => $this->router->pathFor('admin.api_access.add'),
103+
'link' => $this->flextype->container('router')->pathFor('admin.api_access.add'),
91104
'title' => __('admin_create_new_token'),
92105
'active' => true
93106
],
@@ -121,12 +134,12 @@ public function addProcess(Request $request, Response $response) : Response
121134
$uuid = Uuid::uuid4()->toString();
122135

123136
// Get time
124-
$time = date($this->registry->get('flextype.settings.date_format'), time());
137+
$time = date($this->flextype->container('registry')->get('flextype.settings.date_format'), time());
125138

126139
// Create API Token account
127140
if (Filesystem::write(
128141
$api_token_file_path,
129-
$this->yaml->encode([
142+
$this->flextype->container('yaml')->encode([
130143
'title' => $post_data['title'],
131144
'icon' => $post_data['icon'],
132145
'limit_calls' => (int) $post_data['limit_calls'],
@@ -139,18 +152,18 @@ public function addProcess(Request $request, Response $response) : Response
139152
'updated_at' => $time,
140153
])
141154
)) {
142-
$this->flash->addMessage('success', __('admin_message_access_api_token_created'));
155+
$this->flextype->container('flash')->addMessage('success', __('admin_message_access_api_token_created'));
143156
} else {
144-
$this->flash->addMessage('error', __('admin_message_access_api_token_was_not_created1'));
157+
$this->flextype->container('flash')->addMessage('error', __('admin_message_access_api_token_was_not_created1'));
145158
}
146159
} else {
147-
$this->flash->addMessage('error', __('admin_message_access_api_token_was_not_created2'));
160+
$this->flextype->container('flash')->addMessage('error', __('admin_message_access_api_token_was_not_created2'));
148161
}
149162

150163
if (isset($post_data['create-and-edit'])) {
151-
return $response->withRedirect($this->router->pathFor('admin.api_access.edit') . '?token=' . $api_token);
164+
return $response->withRedirect($this->flextype->container('router')->pathFor('admin.api_access.edit') . '?token=' . $api_token);
152165
} else {
153-
return $response->withRedirect($this->router->pathFor('admin.api_access.index'));
166+
return $response->withRedirect($this->flextype->container('router')->pathFor('admin.api_access.index'));
154167
}
155168
}
156169

@@ -163,9 +176,9 @@ public function addProcess(Request $request, Response $response) : Response
163176
public function edit(Request $request, Response $response) : Response
164177
{
165178
$token = $request->getQueryParams()['token'];
166-
$token_data = $this->yaml->decode(Filesystem::read(PATH['project'] . '/tokens' . '/access/' . $token . '/token.yaml'));
179+
$token_data = $this->flextype->container('yaml')->decode(Filesystem::read(PATH['project'] . '/tokens' . '/access/' . $token . '/token.yaml'));
167180

168-
return $this->twig->render(
181+
return $this->flextype->container('twig')->render(
169182
$response,
170183
'plugins/admin/templates/system/api/access/edit.html',
171184
[
@@ -174,15 +187,15 @@ public function edit(Request $request, Response $response) : Response
174187
'token_data' => $token_data,
175188
'links' => [
176189
'api' => [
177-
'link' => $this->router->pathFor('admin.api.index'),
190+
'link' => $this->flextype->container('router')->pathFor('admin.api.index'),
178191
'title' => __('admin_api')
179192
],
180193
'api_access' => [
181-
'link' => $this->router->pathFor('admin.api_access.index'),
194+
'link' => $this->flextype->container('router')->pathFor('admin.api_access.index'),
182195
'title' => __('admin_access')
183196
],
184197
'api_tokens_edit' => [
185-
'link' => $this->router->pathFor('admin.api_access.edit'),
198+
'link' => $this->flextype->container('router')->pathFor('admin.api_access.edit'),
186199
'title' => __('admin_edit_token'),
187200
'active' => true
188201
],
@@ -209,7 +222,7 @@ public function editProcess(Request $request, Response $response) : Response
209222
if (Filesystem::has($api_token_file_path)) {
210223
if (Filesystem::write(
211224
$api_token_file_path,
212-
$this->yaml->encode([
225+
$this->flextype->container('yaml')->encode([
213226
'title' => $post_data['title'],
214227
'icon' => $post_data['icon'],
215228
'limit_calls' => (int) $post_data['limit_calls'],
@@ -219,16 +232,16 @@ public function editProcess(Request $request, Response $response) : Response
219232
'created_by' => $post_data['created_by'],
220233
'created_at' => $post_data['created_at'],
221234
'updated_by' => Session::get('uuid'),
222-
'updated_at' => date($this->registry->get('flextype.settings.date_format'), time()),
235+
'updated_at' => date($this->flextype->container('registry')->get('flextype.settings.date_format'), time()),
223236
])
224237
)) {
225-
$this->flash->addMessage('success', __('admin_message_access_api_token_updated'));
238+
$this->flextype->container('flash')->addMessage('success', __('admin_message_access_api_token_updated'));
226239
}
227240
} else {
228-
$this->flash->addMessage('error', __('admin_message_access_api_token_was_not_updated'));
241+
$this->flextype->container('flash')->addMessage('error', __('admin_message_access_api_token_was_not_updated'));
229242
}
230243

231-
return $response->withRedirect($this->router->pathFor('admin.api_access.index'));
244+
return $response->withRedirect($this->flextype->container('router')->pathFor('admin.api_access.index'));
232245
}
233246

234247
/**
@@ -245,11 +258,11 @@ public function deleteProcess(Request $request, Response $response) : Response
245258
$api_token_dir_path = PATH['project'] . '/tokens' . '/access/' . $post_data['token'];
246259

247260
if (Filesystem::deleteDir($api_token_dir_path)) {
248-
$this->flash->addMessage('success', __('admin_message_access_api_token_deleted'));
261+
$this->flextype->container('flash')->addMessage('success', __('admin_message_access_api_token_deleted'));
249262
} else {
250-
$this->flash->addMessage('error', __('admin_message_access_api_token_was_not_deleted'));
263+
$this->flextype->container('flash')->addMessage('error', __('admin_message_access_api_token_was_not_deleted'));
251264
}
252265

253-
return $response->withRedirect($this->router->pathFor('admin.api_access.index'));
266+
return $response->withRedirect($this->flextype->container('router')->pathFor('admin.api_access.index'));
254267
}
255268
}

app/Controllers/ApiController.php

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,23 @@
1414
use function Flextype\Component\I18n\__;
1515
use function random_bytes;
1616
use function time;
17-
use Flextype\App\Foundation\Container;
1817

19-
class ApiController extends Container
18+
19+
class ApiController
2020
{
21+
/**
22+
* Flextype Application
23+
*/
24+
protected $flextype;
25+
26+
/**
27+
* __construct
28+
*/
29+
public function __construct($flextype)
30+
{
31+
$this->flextype = $flextype;
32+
}
33+
2134
/**
2235
* Index page for API's
2336
*
@@ -26,7 +39,7 @@ class ApiController extends Container
2639
*/
2740
public function index(Request $request, Response $response) : Response
2841
{
29-
return $this->twig->render(
42+
return $this->flextype->container('twig')->render(
3043
$response,
3144
'plugins/admin/templates/system/api/index.html',
3245
[
@@ -59,7 +72,7 @@ public function index(Request $request, Response $response) : Response
5972
],
6073
'links' => [
6174
'api' => [
62-
'link' => $this->router->pathFor('admin.api.index'),
75+
'link' => $this->flextype->container('router')->pathFor('admin.api.index'),
6376
'title' => __('admin_api'),
6477
'active' => true,
6578
],

0 commit comments

Comments
 (0)