diff --git a/CHANGELOG.md b/CHANGELOG.md index 9efce44f..2db739e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ + +# [1.3.0](https://github.com/flextype-plugins/admin) (2020-08-25) + +### Features + +* **core** update code base for new Flextype 0.9.11 + # [1.2.0](https://github.com/flextype-plugins/admin) (2020-08-19) diff --git a/README.md b/README.md index d9c56100..f3e1fcf9 100755 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ ![preview](https://github.com/flextype-plugins/admin/raw/dev/preview.png)

-Version License Total downloads Flextype Crowdin Quality Score Discord +Version License Total downloads Flextype Crowdin Quality Score Discord

Admin Panel plugin for Flextype. @@ -14,7 +14,7 @@ The following dependencies need to be installed for Form Admin Plugin. | Item | Version | Download | |---|---|---| -| [flextype](https://github.com/flextype/flextype) | 0.9.10 | [download](https://github.com/flextype/flextype/releases) | +| [flextype](https://github.com/flextype/flextype) | 0.9.11 | [download](https://github.com/flextype/flextype/releases) | | [twig](https://github.com/flextype-plugins/twig) | >=1.0.0 | [download](https://github.com/flextype-plugins/twig/releases) | | [form](https://github.com/flextype-plugins/form) | >=1.0.0 | [download](https://github.com/flextype-plugins/form/releases) | | [form-admin](https://github.com/flextype-plugins/form-admin) | >=1.0.0 | [download](https://github.com/flextype-plugins/form-admin/releases) | diff --git a/app/Controllers/ApiAccessController.php b/app/Controllers/ApiAccessController.php index e5c0d9d2..eaf1a12a 100644 --- a/app/Controllers/ApiAccessController.php +++ b/app/Controllers/ApiAccessController.php @@ -18,17 +18,13 @@ class ApiAccessController { - /** - * Flextype Application - */ - protected $flextype; /** * __construct */ - public function __construct($flextype) + public function __construct() { - $this->flextype = $flextype; + } /** @@ -50,7 +46,7 @@ public function index(Request $request, Response $response) : Response } } - return $this->flextype->container('twig')->render( + return flextype('twig')->render( $response, 'plugins/admin/templates/system/api/access/index.html', [ @@ -58,18 +54,18 @@ public function index(Request $request, Response $response) : Response 'tokens' => $tokens, 'links' => [ 'api' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.api.index'), + 'link' => flextype('router')->pathFor('admin.api.index'), 'title' => __('admin_api'), ], 'api_Access' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.api_access.index'), + 'link' => flextype('router')->pathFor('admin.api_access.index'), 'title' => __('admin_access'), 'active' => true ], ], 'buttons' => [ 'api_access_add' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.api_access.add'), + 'link' => flextype('router')->pathFor('admin.api_access.add'), 'title' => __('admin_create_new_token') ], ], @@ -85,22 +81,22 @@ public function index(Request $request, Response $response) : Response */ public function add(Request $request, Response $response) : Response { - return $this->flextype->container('twig')->render( + return flextype('twig')->render( $response, 'plugins/admin/templates/system/api/access/add.html', [ 'menu_item' => 'api', 'links' => [ 'api' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.api.index'), + 'link' => flextype('router')->pathFor('admin.api.index'), 'title' => __('admin_api'), ], 'api_access' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.api_access.index'), + 'link' => flextype('router')->pathFor('admin.api_access.index'), 'title' => __('admin_access') ], 'api_access_add' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.api_access.add'), + 'link' => flextype('router')->pathFor('admin.api_access.add'), 'title' => __('admin_create_new_token'), 'active' => true ], @@ -134,12 +130,12 @@ public function addProcess(Request $request, Response $response) : Response $uuid = Uuid::uuid4()->toString(); // Get time - $time = date($this->flextype->container('registry')->get('flextype.settings.date_format'), time()); + $time = date(flextype('registry')->get('flextype.settings.date_format'), time()); // Create API Token account if (Filesystem::write( $api_token_file_path, - $this->flextype->container('yaml')->encode([ + flextype('yaml')->encode([ 'title' => $post_data['title'], 'icon' => $post_data['icon'], 'limit_calls' => (int) $post_data['limit_calls'], @@ -152,18 +148,18 @@ public function addProcess(Request $request, Response $response) : Response 'updated_at' => $time, ]) )) { - $this->flextype->container('flash')->addMessage('success', __('admin_message_access_api_token_created')); + flextype('flash')->addMessage('success', __('admin_message_access_api_token_created')); } else { - $this->flextype->container('flash')->addMessage('error', __('admin_message_access_api_token_was_not_created1')); + flextype('flash')->addMessage('error', __('admin_message_access_api_token_was_not_created1')); } } else { - $this->flextype->container('flash')->addMessage('error', __('admin_message_access_api_token_was_not_created2')); + flextype('flash')->addMessage('error', __('admin_message_access_api_token_was_not_created2')); } if (isset($post_data['create-and-edit'])) { - return $response->withRedirect($this->flextype->container('router')->pathFor('admin.api_access.edit') . '?token=' . $api_token); + return $response->withRedirect(flextype('router')->pathFor('admin.api_access.edit') . '?token=' . $api_token); } else { - return $response->withRedirect($this->flextype->container('router')->pathFor('admin.api_access.index')); + return $response->withRedirect(flextype('router')->pathFor('admin.api_access.index')); } } @@ -176,9 +172,9 @@ public function addProcess(Request $request, Response $response) : Response public function edit(Request $request, Response $response) : Response { $token = $request->getQueryParams()['token']; - $token_data = $this->flextype->container('yaml')->decode(Filesystem::read(PATH['project'] . '/tokens' . '/access/' . $token . '/token.yaml')); + $token_data = flextype('yaml')->decode(Filesystem::read(PATH['project'] . '/tokens' . '/access/' . $token . '/token.yaml')); - return $this->flextype->container('twig')->render( + return flextype('twig')->render( $response, 'plugins/admin/templates/system/api/access/edit.html', [ @@ -187,15 +183,15 @@ public function edit(Request $request, Response $response) : Response 'token_data' => $token_data, 'links' => [ 'api' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.api.index'), + 'link' => flextype('router')->pathFor('admin.api.index'), 'title' => __('admin_api') ], 'api_access' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.api_access.index'), + 'link' => flextype('router')->pathFor('admin.api_access.index'), 'title' => __('admin_access') ], 'api_tokens_edit' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.api_access.edit'), + 'link' => flextype('router')->pathFor('admin.api_access.edit'), 'title' => __('admin_edit_token'), 'active' => true ], @@ -222,7 +218,7 @@ public function editProcess(Request $request, Response $response) : Response if (Filesystem::has($api_token_file_path)) { if (Filesystem::write( $api_token_file_path, - $this->flextype->container('yaml')->encode([ + flextype('yaml')->encode([ 'title' => $post_data['title'], 'icon' => $post_data['icon'], 'limit_calls' => (int) $post_data['limit_calls'], @@ -232,16 +228,16 @@ public function editProcess(Request $request, Response $response) : Response 'created_by' => $post_data['created_by'], 'created_at' => $post_data['created_at'], 'updated_by' => Session::get('uuid'), - 'updated_at' => date($this->flextype->container('registry')->get('flextype.settings.date_format'), time()), + 'updated_at' => date(flextype('registry')->get('flextype.settings.date_format'), time()), ]) )) { - $this->flextype->container('flash')->addMessage('success', __('admin_message_access_api_token_updated')); + flextype('flash')->addMessage('success', __('admin_message_access_api_token_updated')); } } else { - $this->flextype->container('flash')->addMessage('error', __('admin_message_access_api_token_was_not_updated')); + flextype('flash')->addMessage('error', __('admin_message_access_api_token_was_not_updated')); } - return $response->withRedirect($this->flextype->container('router')->pathFor('admin.api_access.index')); + return $response->withRedirect(flextype('router')->pathFor('admin.api_access.index')); } /** @@ -258,11 +254,11 @@ public function deleteProcess(Request $request, Response $response) : Response $api_token_dir_path = PATH['project'] . '/tokens' . '/access/' . $post_data['token']; if (Filesystem::deleteDir($api_token_dir_path)) { - $this->flextype->container('flash')->addMessage('success', __('admin_message_access_api_token_deleted')); + flextype('flash')->addMessage('success', __('admin_message_access_api_token_deleted')); } else { - $this->flextype->container('flash')->addMessage('error', __('admin_message_access_api_token_was_not_deleted')); + flextype('flash')->addMessage('error', __('admin_message_access_api_token_was_not_deleted')); } - return $response->withRedirect($this->flextype->container('router')->pathFor('admin.api_access.index')); + return $response->withRedirect(flextype('router')->pathFor('admin.api_access.index')); } } diff --git a/app/Controllers/ApiController.php b/app/Controllers/ApiController.php index c17c5a91..16329c93 100644 --- a/app/Controllers/ApiController.php +++ b/app/Controllers/ApiController.php @@ -18,17 +18,12 @@ class ApiController { - /** - * Flextype Application - */ - protected $flextype; - /** * __construct */ - public function __construct($flextype) + public function __construct() { - $this->flextype = $flextype; + } /** @@ -39,7 +34,7 @@ public function __construct($flextype) */ public function index(Request $request, Response $response) : Response { - return $this->flextype->container('twig')->render( + return flextype('twig')->render( $response, 'plugins/admin/templates/system/api/index.html', [ @@ -72,7 +67,7 @@ public function index(Request $request, Response $response) : Response ], 'links' => [ 'api' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.api.index'), + 'link' => flextype('router')->pathFor('admin.api.index'), 'title' => __('admin_api'), 'active' => true, ], diff --git a/app/Controllers/ApiEntriesController.php b/app/Controllers/ApiEntriesController.php index f6e396a8..92d8d365 100644 --- a/app/Controllers/ApiEntriesController.php +++ b/app/Controllers/ApiEntriesController.php @@ -18,17 +18,13 @@ class ApiEntriesController { - /** - * Flextype Application - */ - protected $flextype; /** * __construct */ - public function __construct($flextype) + public function __construct() { - $this->flextype = $flextype; + } /** @@ -50,7 +46,7 @@ public function index(Request $request, Response $response) : Response } } - return $this->flextype->container('twig')->render( + return flextype('twig')->render( $response, 'plugins/admin/templates/system/api/entries/index.html', [ @@ -58,18 +54,18 @@ public function index(Request $request, Response $response) : Response 'tokens' => $tokens, 'links' => [ 'api' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.api.index'), + 'link' => flextype('router')->pathFor('admin.api.index'), 'title' => __('admin_api'), ], 'api_entries' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.api_entries.index'), + 'link' => flextype('router')->pathFor('admin.api_entries.index'), 'title' => __('admin_entries'), 'active' => true ], ], 'buttons' => [ 'api_entries_add' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.api_entries.add'), + 'link' => flextype('router')->pathFor('admin.api_entries.add'), 'title' => __('admin_create_new_token') ], ], @@ -85,22 +81,22 @@ public function index(Request $request, Response $response) : Response */ public function add(Request $request, Response $response) : Response { - return $this->flextype->container('twig')->render( + return flextype('twig')->render( $response, 'plugins/admin/templates/system/api/entries/add.html', [ 'menu_item' => 'api', 'links' => [ 'api' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.api.index'), + 'link' => flextype('router')->pathFor('admin.api.index'), 'title' => __('admin_api'), ], 'api_entries' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.api_entries.index'), + 'link' => flextype('router')->pathFor('admin.api_entries.index'), 'title' => __('admin_entries') ], 'api_entries_add' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.api_entries.add'), + 'link' => flextype('router')->pathFor('admin.api_entries.add'), 'title' => __('admin_create_new_token'), 'active' => true ], @@ -134,12 +130,12 @@ public function addProcess(Request $request, Response $response) : Response $uuid = Uuid::uuid4()->toString(); // Get time - $time = date($this->flextype->container('registry')->get('flextype.settings.date_format'), time()); + $time = date(flextype('registry')->get('flextype.settings.date_format'), time()); // Create API Token account if (Filesystem::write( $api_token_file_path, - $this->flextype->container('yaml')->encode([ + flextype('yaml')->encode([ 'title' => $post_data['title'], 'icon' => $post_data['icon'], 'limit_calls' => (int) $post_data['limit_calls'], @@ -152,18 +148,18 @@ public function addProcess(Request $request, Response $response) : Response 'updated_at' => $time, ]) )) { - $this->flextype->container('flash')->addMessage('success', __('admin_message_entries_api_token_created')); + flextype('flash')->addMessage('success', __('admin_message_entries_api_token_created')); } else { - $this->flextype->container('flash')->addMessage('error', __('admin_message_entries_api_token_was_not_created1')); + flextype('flash')->addMessage('error', __('admin_message_entries_api_token_was_not_created1')); } } else { - $this->flextype->container('flash')->addMessage('error', __('admin_message_entries_api_token_was_not_created2')); + flextype('flash')->addMessage('error', __('admin_message_entries_api_token_was_not_created2')); } if (isset($post_data['create-and-edit'])) { - return $response->withRedirect($this->flextype->container('router')->pathFor('admin.api_entries.edit') . '?token=' . $api_token); + return $response->withRedirect(flextype('router')->pathFor('admin.api_entries.edit') . '?token=' . $api_token); } else { - return $response->withRedirect($this->flextype->container('router')->pathFor('admin.api_entries.index')); + return $response->withRedirect(flextype('router')->pathFor('admin.api_entries.index')); } } @@ -176,9 +172,9 @@ public function addProcess(Request $request, Response $response) : Response public function edit(Request $request, Response $response) : Response { $token = $request->getQueryParams()['token']; - $token_data = $this->flextype->container('yaml')->decode(Filesystem::read(PATH['project'] . '/tokens/entries/' . $token . '/token.yaml')); + $token_data = flextype('yaml')->decode(Filesystem::read(PATH['project'] . '/tokens/entries/' . $token . '/token.yaml')); - return $this->flextype->container('twig')->render( + return flextype('twig')->render( $response, 'plugins/admin/templates/system/api/entries/edit.html', [ @@ -187,15 +183,15 @@ public function edit(Request $request, Response $response) : Response 'token_data' => $token_data, 'links' => [ 'api' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.api.index'), + 'link' => flextype('router')->pathFor('admin.api.index'), 'title' => __('admin_api') ], 'api_entries' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.api_entries.index'), + 'link' => flextype('router')->pathFor('admin.api_entries.index'), 'title' => __('admin_entries') ], 'api_tokens_edit' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.api_entries.edit'), + 'link' => flextype('router')->pathFor('admin.api_entries.edit'), 'title' => __('admin_edit_token'), 'active' => true ], @@ -222,7 +218,7 @@ public function editProcess(Request $request, Response $response) : Response if (Filesystem::has($api_token_file_path)) { if (Filesystem::write( $api_token_file_path, - $this->flextype->container('yaml')->encode([ + flextype('yaml')->encode([ 'title' => $post_data['title'], 'icon' => $post_data['icon'], 'limit_calls' => (int) $post_data['limit_calls'], @@ -232,16 +228,16 @@ public function editProcess(Request $request, Response $response) : Response 'created_by' => $post_data['created_by'], 'created_at' => $post_data['created_at'], 'updated_by' => Session::get('uuid'), - 'updated_at' => date($this->flextype->container('registry')->get('flextype.settings.date_format'), time()), + 'updated_at' => date(flextype('registry')->get('flextype.settings.date_format'), time()), ]) )) { - $this->flextype->container('flash')->addMessage('success', __('admin_message_entries_api_token_updated')); + flextype('flash')->addMessage('success', __('admin_message_entries_api_token_updated')); } } else { - $this->flextype->container('flash')->addMessage('error', __('admin_message_entries_api_token_was_not_updated')); + flextype('flash')->addMessage('error', __('admin_message_entries_api_token_was_not_updated')); } - return $response->withRedirect($this->flextype->container('router')->pathFor('admin.api_entries.index')); + return $response->withRedirect(flextype('router')->pathFor('admin.api_entries.index')); } /** @@ -258,11 +254,11 @@ public function deleteProcess(Request $request, Response $response) : Response $api_token_dir_path = PATH['project'] . '/tokens/entries/' . $post_data['token']; if (Filesystem::deleteDir($api_token_dir_path)) { - $this->flextype->container('flash')->addMessage('success', __('admin_message_entries_api_token_deleted')); + flextype('flash')->addMessage('success', __('admin_message_entries_api_token_deleted')); } else { - $this->flextype->container('flash')->addMessage('error', __('admin_message_entries_api_token_was_not_deleted')); + flextype('flash')->addMessage('error', __('admin_message_entries_api_token_was_not_deleted')); } - return $response->withRedirect($this->flextype->container('router')->pathFor('admin.api_entries.index')); + return $response->withRedirect(flextype('router')->pathFor('admin.api_entries.index')); } } diff --git a/app/Controllers/ApiFilesController.php b/app/Controllers/ApiFilesController.php index 11879268..80d91997 100644 --- a/app/Controllers/ApiFilesController.php +++ b/app/Controllers/ApiFilesController.php @@ -19,17 +19,12 @@ class ApiFilesController { - /** - * Flextype Application - */ - protected $flextype; - /** * __construct */ - public function __construct($flextype) + public function __construct() { - $this->flextype = $flextype; + } /** @@ -51,7 +46,7 @@ public function index(Request $request, Response $response) : Response } } - return $this->flextype->container('twig')->render( + return flextype('twig')->render( $response, 'plugins/admin/templates/system/api/files/index.html', [ @@ -59,18 +54,18 @@ public function index(Request $request, Response $response) : Response 'tokens' => $tokens, 'links' => [ 'api' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.api.index'), + 'link' => flextype('router')->pathFor('admin.api.index'), 'title' => __('admin_api'), ], 'api_files' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.api_files.index'), + 'link' => flextype('router')->pathFor('admin.api_files.index'), 'title' => __('admin_files'), 'active' => true ], ], 'buttons' => [ 'api_files_add' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.api_files.add'), + 'link' => flextype('router')->pathFor('admin.api_files.add'), 'title' => __('admin_create_new_token') ], ], @@ -86,22 +81,22 @@ public function index(Request $request, Response $response) : Response */ public function add(Request $request, Response $response) : Response { - return $this->flextype->container('twig')->render( + return flextype('twig')->render( $response, 'plugins/admin/templates/system/api/files/add.html', [ 'menu_item' => 'api', 'links' => [ 'api' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.api.index'), + 'link' => flextype('router')->pathFor('admin.api.index'), 'title' => __('admin_api'), ], 'api_files' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.api_files.index'), + 'link' => flextype('router')->pathFor('admin.api_files.index'), 'title' => __('admin_files') ], 'api_files_add' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.api_files.add'), + 'link' => flextype('router')->pathFor('admin.api_files.add'), 'title' => __('admin_create_new_token'), 'active' => true ], @@ -135,12 +130,12 @@ public function addProcess(Request $request, Response $response) : Response $uuid = Uuid::uuid4()->toString(); // Get time - $time = date($this->flextype->container('registry')->get('flextype.settings.date_format'), time()); + $time = date(flextype('registry')->get('flextype.settings.date_format'), time()); // Create API Token account if (Filesystem::write( $api_token_file_path, - $this->flextype->container('yaml')->encode([ + flextype('yaml')->encode([ 'title' => $post_data['title'], 'icon' => $post_data['icon'], 'limit_calls' => (int) $post_data['limit_calls'], @@ -153,18 +148,18 @@ public function addProcess(Request $request, Response $response) : Response 'updated_at' => $time, ]) )) { - $this->flextype->container('flash')->addMessage('success', __('admin_message_files_api_token_created')); + flextype('flash')->addMessage('success', __('admin_message_files_api_token_created')); } else { - $this->flextype->container('flash')->addMessage('error', __('admin_message_files_api_token_was_not_created1')); + flextype('flash')->addMessage('error', __('admin_message_files_api_token_was_not_created1')); } } else { - $this->flextype->container('flash')->addMessage('error', __('admin_message_files_api_token_was_not_created2')); + flextype('flash')->addMessage('error', __('admin_message_files_api_token_was_not_created2')); } if (isset($post_data['create-and-edit'])) { - return $response->withRedirect($this->flextype->container('router')->pathFor('admin.api_files.edit') . '?token=' . $api_token); + return $response->withRedirect(flextype('router')->pathFor('admin.api_files.edit') . '?token=' . $api_token); } else { - return $response->withRedirect($this->flextype->container('router')->pathFor('admin.api_files.index')); + return $response->withRedirect(flextype('router')->pathFor('admin.api_files.index')); } } @@ -177,9 +172,9 @@ public function addProcess(Request $request, Response $response) : Response public function edit(Request $request, Response $response) : Response { $token = $request->getQueryParams()['token']; - $token_data = $this->flextype->container('yaml')->decode(Filesystem::read(PATH['project'] . '/tokens/files/' . $token . '/token.yaml')); + $token_data = flextype('yaml')->decode(Filesystem::read(PATH['project'] . '/tokens/files/' . $token . '/token.yaml')); - return $this->flextype->container('twig')->render( + return flextype('twig')->render( $response, 'plugins/admin/templates/system/api/files/edit.html', [ @@ -188,15 +183,15 @@ public function edit(Request $request, Response $response) : Response 'token_data' => $token_data, 'links' => [ 'api' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.api.index'), + 'link' => flextype('router')->pathFor('admin.api.index'), 'title' => __('admin_api') ], 'api_files' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.api_files.index'), + 'link' => flextype('router')->pathFor('admin.api_files.index'), 'title' => __('admin_files') ], 'api_tokens_edit' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.api_files.edit'), + 'link' => flextype('router')->pathFor('admin.api_files.edit'), 'title' => __('admin_edit_token'), 'active' => true ], @@ -223,7 +218,7 @@ public function editProcess(Request $request, Response $response) : Response if (Filesystem::has($api_token_file_path)) { if (Filesystem::write( $api_token_file_path, - $this->flextype->container('yaml')->encode([ + flextype('yaml')->encode([ 'title' => $post_data['title'], 'icon' => $post_data['icon'], 'limit_calls' => (int) $post_data['limit_calls'], @@ -233,16 +228,16 @@ public function editProcess(Request $request, Response $response) : Response 'created_by' => $post_data['created_by'], 'created_at' => $post_data['created_at'], 'updated_by' => Session::get('uuid'), - 'updated_at' => date($this->flextype->container('registry')->get('flextype.settings.date_format'), time()), + 'updated_at' => date(flextype('registry')->get('flextype.settings.date_format'), time()), ]) )) { - $this->flextype->container('flash')->addMessage('success', __('admin_message_files_api_token_updated')); + flextype('flash')->addMessage('success', __('admin_message_files_api_token_updated')); } } else { - $this->flextype->container('flash')->addMessage('error', __('admin_message_files_api_token_was_not_updated')); + flextype('flash')->addMessage('error', __('admin_message_files_api_token_was_not_updated')); } - return $response->withRedirect($this->flextype->container('router')->pathFor('admin.api_files.index')); + return $response->withRedirect(flextype('router')->pathFor('admin.api_files.index')); } /** @@ -259,11 +254,11 @@ public function deleteProcess(Request $request, Response $response) : Response $api_token_dir_path = PATH['project'] . '/tokens/files/' . $post_data['token']; if (Filesystem::deleteDir($api_token_dir_path)) { - $this->flextype->container('flash')->addMessage('success', __('admin_message_files_api_token_deleted')); + flextype('flash')->addMessage('success', __('admin_message_files_api_token_deleted')); } else { - $this->flextype->container('flash')->addMessage('error', __('admin_message_files_api_token_was_not_deleted')); + flextype('flash')->addMessage('error', __('admin_message_files_api_token_was_not_deleted')); } - return $response->withRedirect($this->flextype->container('router')->pathFor('admin.api_files.index')); + return $response->withRedirect(flextype('router')->pathFor('admin.api_files.index')); } } diff --git a/app/Controllers/ApiFoldersController.php b/app/Controllers/ApiFoldersController.php index 68bc32ef..c223a49a 100644 --- a/app/Controllers/ApiFoldersController.php +++ b/app/Controllers/ApiFoldersController.php @@ -17,19 +17,14 @@ class ApiFoldersController { - /** - * Flextype Application - */ - protected $flextype; - /** * __construct */ - public function __construct($flextype) + public function __construct() { - $this->flextype = $flextype; + } - + /** * folders Index page * @@ -49,7 +44,7 @@ public function index(Request $request, Response $response) : Response } } - return $this->flextype->container('twig')->render( + return flextype('twig')->render( $response, 'plugins/admin/templates/system/api/folders/index.html', [ @@ -57,18 +52,18 @@ public function index(Request $request, Response $response) : Response 'tokens' => $tokens, 'links' => [ 'api' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.api.index'), + 'link' => flextype('router')->pathFor('admin.api.index'), 'title' => __('admin_api'), ], 'api_folders' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.api_folders.index'), + 'link' => flextype('router')->pathFor('admin.api_folders.index'), 'title' => __('admin_folders'), 'active' => true ], ], 'buttons' => [ 'api_folders_add' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.api_folders.add'), + 'link' => flextype('router')->pathFor('admin.api_folders.add'), 'title' => __('admin_create_new_token') ], ], @@ -84,22 +79,22 @@ public function index(Request $request, Response $response) : Response */ public function add(Request $request, Response $response) : Response { - return $this->flextype->container('twig')->render( + return flextype('twig')->render( $response, 'plugins/admin/templates/system/api/folders/add.html', [ 'menu_item' => 'api', 'links' => [ 'api' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.api.index'), + 'link' => flextype('router')->pathFor('admin.api.index'), 'title' => __('admin_api'), ], 'api_folders' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.api_folders.index'), + 'link' => flextype('router')->pathFor('admin.api_folders.index'), 'title' => __('admin_folders') ], 'api_folders_add' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.api_folders.add'), + 'link' => flextype('router')->pathFor('admin.api_folders.add'), 'title' => __('admin_create_new_token'), 'active' => true ], @@ -133,12 +128,12 @@ public function addProcess(Request $request, Response $response) : Response $uuid = Uuid::uuid4()->toString(); // Get time - $time = date($this->flextype->container('registry')->get('flextype.settings.date_format'), time()); + $time = date(flextype('registry')->get('flextype.settings.date_format'), time()); // Create API Token account if (Filesystem::write( $api_token_file_path, - $this->flextype->container('yaml')->encode([ + flextype('yaml')->encode([ 'title' => $post_data['title'], 'icon' => $post_data['icon'], 'limit_calls' => (int) $post_data['limit_calls'], @@ -151,18 +146,18 @@ public function addProcess(Request $request, Response $response) : Response 'updated_at' => $time, ]) )) { - $this->flextype->container('flash')->addMessage('success', __('admin_message_folders_api_token_created')); + flextype('flash')->addMessage('success', __('admin_message_folders_api_token_created')); } else { - $this->flextype->container('flash')->addMessage('error', __('admin_message_folders_api_token_was_not_created1')); + flextype('flash')->addMessage('error', __('admin_message_folders_api_token_was_not_created1')); } } else { - $this->flextype->container('flash')->addMessage('error', __('admin_message_folders_api_token_was_not_created2')); + flextype('flash')->addMessage('error', __('admin_message_folders_api_token_was_not_created2')); } if (isset($post_data['create-and-edit'])) { - return $response->withRedirect($this->flextype->container('router')->pathFor('admin.api_folders.edit') . '?token=' . $api_token); + return $response->withRedirect(flextype('router')->pathFor('admin.api_folders.edit') . '?token=' . $api_token); } else { - return $response->withRedirect($this->flextype->container('router')->pathFor('admin.api_folders.index')); + return $response->withRedirect(flextype('router')->pathFor('admin.api_folders.index')); } } @@ -175,9 +170,9 @@ public function addProcess(Request $request, Response $response) : Response public function edit(Request $request, Response $response) : Response { $token = $request->getQueryParams()['token']; - $token_data = $this->flextype->container('yaml')->decode(Filesystem::read(PATH['project'] . '/tokens/folders/' . $token . '/token.yaml')); + $token_data = flextype('yaml')->decode(Filesystem::read(PATH['project'] . '/tokens/folders/' . $token . '/token.yaml')); - return $this->flextype->container('twig')->render( + return flextype('twig')->render( $response, 'plugins/admin/templates/system/api/folders/edit.html', [ @@ -186,15 +181,15 @@ public function edit(Request $request, Response $response) : Response 'token_data' => $token_data, 'links' => [ 'api' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.api.index'), + 'link' => flextype('router')->pathFor('admin.api.index'), 'title' => __('admin_api') ], 'api_folders' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.api_folders.index'), + 'link' => flextype('router')->pathFor('admin.api_folders.index'), 'title' => __('admin_folders') ], 'api_tokens_edit' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.api_folders.edit'), + 'link' => flextype('router')->pathFor('admin.api_folders.edit'), 'title' => __('admin_edit_token'), 'active' => true ], @@ -221,7 +216,7 @@ public function editProcess(Request $request, Response $response) : Response if (Filesystem::has($api_token_file_path)) { if (Filesystem::write( $api_token_file_path, - $this->flextype->container('yaml')->encode([ + flextype('yaml')->encode([ 'title' => $post_data['title'], 'icon' => $post_data['icon'], 'limit_calls' => (int) $post_data['limit_calls'], @@ -231,16 +226,16 @@ public function editProcess(Request $request, Response $response) : Response 'created_by' => $post_data['created_by'], 'created_at' => $post_data['created_at'], 'updated_by' => Session::get('uuid'), - 'updated_at' => date($this->flextype->container('registry')->get('flextype.settings.date_format'), time()), + 'updated_at' => date(flextype('registry')->get('flextype.settings.date_format'), time()), ]) )) { - $this->flextype->container('flash')->addMessage('success', __('admin_message_folders_api_token_updated')); + flextype('flash')->addMessage('success', __('admin_message_folders_api_token_updated')); } } else { - $this->flextype->container('flash')->addMessage('error', __('admin_message_folders_api_token_was_not_updated')); + flextype('flash')->addMessage('error', __('admin_message_folders_api_token_was_not_updated')); } - return $response->withRedirect($this->flextype->container('router')->pathFor('admin.api_folders.index')); + return $response->withRedirect(flextype('router')->pathFor('admin.api_folders.index')); } /** @@ -257,11 +252,11 @@ public function deleteProcess(Request $request, Response $response) : Response $api_token_dir_path = PATH['project'] . '/tokens/folders/' . $post_data['token']; if (Filesystem::deleteDir($api_token_dir_path)) { - $this->flextype->container('flash')->addMessage('success', __('admin_message_folders_api_token_deleted')); + flextype('flash')->addMessage('success', __('admin_message_folders_api_token_deleted')); } else { - $this->flextype->container('flash')->addMessage('error', __('admin_message_folders_api_token_was_not_deleted')); + flextype('flash')->addMessage('error', __('admin_message_folders_api_token_was_not_deleted')); } - return $response->withRedirect($this->flextype->container('router')->pathFor('admin.api_folders.index')); + return $response->withRedirect(flextype('router')->pathFor('admin.api_folders.index')); } } diff --git a/app/Controllers/ApiImagesController.php b/app/Controllers/ApiImagesController.php index ee782720..90facc62 100644 --- a/app/Controllers/ApiImagesController.php +++ b/app/Controllers/ApiImagesController.php @@ -17,17 +17,12 @@ class ApiImagesController { - /** - * Flextype Application - */ - protected $flextype; - /** * __construct */ - public function __construct($flextype) + public function __construct() { - $this->flextype = $flextype; + } /** @@ -49,7 +44,7 @@ public function index(Request $request, Response $response) : Response } } - return $this->flextype->container('twig')->render( + return flextype('twig')->render( $response, 'plugins/admin/templates/system/api/images/index.html', [ @@ -57,18 +52,18 @@ public function index(Request $request, Response $response) : Response 'tokens' => $tokens, 'links' => [ 'api' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.api.index'), + 'link' => flextype('router')->pathFor('admin.api.index'), 'title' => __('admin_api'), ], 'api_images' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.api_images.index'), + 'link' => flextype('router')->pathFor('admin.api_images.index'), 'title' => __('admin_images'), 'active' => true ], ], 'buttons' => [ 'api_images_add' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.api_images.add'), + 'link' => flextype('router')->pathFor('admin.api_images.add'), 'title' => __('admin_create_new_token') ], ], @@ -84,22 +79,22 @@ public function index(Request $request, Response $response) : Response */ public function add(Request $request, Response $response) : Response { - return $this->flextype->container('twig')->render( + return flextype('twig')->render( $response, 'plugins/admin/templates/system/api/images/add.html', [ 'menu_item' => 'api', 'links' => [ 'api' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.api.index'), + 'link' => flextype('router')->pathFor('admin.api.index'), 'title' => __('admin_api'), ], 'api_images' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.api_images.index'), + 'link' => flextype('router')->pathFor('admin.api_images.index'), 'title' => __('admin_images') ], 'api_images_add' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.api_images.add'), + 'link' => flextype('router')->pathFor('admin.api_images.add'), 'title' => __('admin_create_new_token'), 'active' => true ], @@ -133,12 +128,12 @@ public function addProcess(Request $request, Response $response) : Response $uuid = Uuid::uuid4()->toString(); // Get time - $time = date($this->flextype->container('registry')->get('flextype.settings.date_format'), time()); + $time = date(flextype('registry')->get('flextype.settings.date_format'), time()); // Create API Token account if (Filesystem::write( $api_token_file_path, - $this->flextype->container('yaml')->encode([ + flextype('yaml')->encode([ 'title' => $post_data['title'], 'icon' => $post_data['icon'], 'limit_calls' => (int) $post_data['limit_calls'], @@ -151,18 +146,18 @@ public function addProcess(Request $request, Response $response) : Response 'updated_at' => $time, ]) )) { - $this->flextype->container('flash')->addMessage('success', __('admin_message_images_api_token_created')); + flextype('flash')->addMessage('success', __('admin_message_images_api_token_created')); } else { - $this->flextype->container('flash')->addMessage('error', __('admin_message_images_api_token_was_not_created1')); + flextype('flash')->addMessage('error', __('admin_message_images_api_token_was_not_created1')); } } else { - $this->flextype->container('flash')->addMessage('error', __('admin_message_images_api_token_was_not_created2')); + flextype('flash')->addMessage('error', __('admin_message_images_api_token_was_not_created2')); } if (isset($post_data['create-and-edit'])) { - return $response->withRedirect($this->flextype->container('router')->pathFor('admin.api_images.edit') . '?token=' . $api_token); + return $response->withRedirect(flextype('router')->pathFor('admin.api_images.edit') . '?token=' . $api_token); } else { - return $response->withRedirect($this->flextype->container('router')->pathFor('admin.api_images.index')); + return $response->withRedirect(flextype('router')->pathFor('admin.api_images.index')); } } @@ -175,9 +170,9 @@ public function addProcess(Request $request, Response $response) : Response public function edit(Request $request, Response $response) : Response { $token = $request->getQueryParams()['token']; - $token_data = $this->flextype->container('yaml')->decode(Filesystem::read(PATH['project'] . '/tokens' . '/images/' . $token . '/token.yaml')); + $token_data = flextype('yaml')->decode(Filesystem::read(PATH['project'] . '/tokens' . '/images/' . $token . '/token.yaml')); - return $this->flextype->container('twig')->render( + return flextype('twig')->render( $response, 'plugins/admin/templates/system/api/images/edit.html', [ @@ -186,15 +181,15 @@ public function edit(Request $request, Response $response) : Response 'token_data' => $token_data, 'links' => [ 'api' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.api.index'), + 'link' => flextype('router')->pathFor('admin.api.index'), 'title' => __('admin_api') ], 'api_images' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.api_images.index'), + 'link' => flextype('router')->pathFor('admin.api_images.index'), 'title' => __('admin_images') ], 'api_tokens_edit' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.api_images.edit'), + 'link' => flextype('router')->pathFor('admin.api_images.edit'), 'title' => __('admin_edit_token'), 'active' => true ], @@ -221,7 +216,7 @@ public function editProcess(Request $request, Response $response) : Response if (Filesystem::has($api_token_file_path)) { if (Filesystem::write( $api_token_file_path, - $this->flextype->container('yaml')->encode([ + flextype('yaml')->encode([ 'title' => $post_data['title'], 'icon' => $post_data['icon'], 'limit_calls' => (int) $post_data['limit_calls'], @@ -231,16 +226,16 @@ public function editProcess(Request $request, Response $response) : Response 'created_by' => $post_data['created_by'], 'created_at' => $post_data['created_at'], 'updated_by' => Session::get('uuid'), - 'updated_at' => date($this->flextype->container('registry')->get('flextype.settings.date_format'), time()), + 'updated_at' => date(flextype('registry')->get('flextype.settings.date_format'), time()), ]) )) { - $this->flextype->container('flash')->addMessage('success', __('admin_message_images_api_token_updated')); + flextype('flash')->addMessage('success', __('admin_message_images_api_token_updated')); } } else { - $this->flextype->container('flash')->addMessage('error', __('admin_message_images_api_token_was_not_updated')); + flextype('flash')->addMessage('error', __('admin_message_images_api_token_was_not_updated')); } - return $response->withRedirect($this->flextype->container('router')->pathFor('admin.api_images.index')); + return $response->withRedirect(flextype('router')->pathFor('admin.api_images.index')); } /** @@ -257,11 +252,11 @@ public function deleteProcess(Request $request, Response $response) : Response $api_token_dir_path = PATH['project'] . '/tokens' . '/images/' . $post_data['token']; if (Filesystem::deleteDir($api_token_dir_path)) { - $this->flextype->container('flash')->addMessage('success', __('admin_message_images_api_token_deleted')); + flextype('flash')->addMessage('success', __('admin_message_images_api_token_deleted')); } else { - $this->flextype->container('flash')->addMessage('error', __('admin_message_images_api_token_was_not_deleted')); + flextype('flash')->addMessage('error', __('admin_message_images_api_token_was_not_deleted')); } - return $response->withRedirect($this->flextype->container('router')->pathFor('admin.api_images.index')); + return $response->withRedirect(flextype('router')->pathFor('admin.api_images.index')); } } diff --git a/app/Controllers/ApiRegistryController.php b/app/Controllers/ApiRegistryController.php index aae94356..bb2b77fe 100644 --- a/app/Controllers/ApiRegistryController.php +++ b/app/Controllers/ApiRegistryController.php @@ -17,19 +17,14 @@ class ApiRegistryController { - /** - * Flextype Application - */ - protected $flextype; - /** * __construct */ - public function __construct($flextype) + public function __construct() { - $this->flextype = $flextype; + } - + /** * Registry Index page * @@ -49,7 +44,7 @@ public function index(Request $request, Response $response) : Response } } - return $this->flextype->container('twig')->render( + return flextype('twig')->render( $response, 'plugins/admin/templates/system/api/registry/index.html', [ @@ -57,18 +52,18 @@ public function index(Request $request, Response $response) : Response 'tokens' => $tokens, 'links' => [ 'api' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.api.index'), + 'link' => flextype('router')->pathFor('admin.api.index'), 'title' => __('admin_api'), ], 'api_registry' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.api_registry.index'), + 'link' => flextype('router')->pathFor('admin.api_registry.index'), 'title' => __('admin_registry'), 'active' => true ], ], 'buttons' => [ 'api_registry_add' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.api_registry.add'), + 'link' => flextype('router')->pathFor('admin.api_registry.add'), 'title' => __('admin_create_new_token') ], ], @@ -84,22 +79,22 @@ public function index(Request $request, Response $response) : Response */ public function add(Request $request, Response $response) : Response { - return $this->flextype->container('twig')->render( + return flextype('twig')->render( $response, 'plugins/admin/templates/system/api/registry/add.html', [ 'menu_item' => 'api', 'links' => [ 'api' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.api.index'), + 'link' => flextype('router')->pathFor('admin.api.index'), 'title' => __('admin_api'), ], 'api_registry' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.api_registry.index'), + 'link' => flextype('router')->pathFor('admin.api_registry.index'), 'title' => __('admin_registry') ], 'api_registry_add' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.api_registry.add'), + 'link' => flextype('router')->pathFor('admin.api_registry.add'), 'title' => __('admin_create_new_token'), 'active' => true ], @@ -133,12 +128,12 @@ public function addProcess(Request $request, Response $response) : Response $uuid = Uuid::uuid4()->toString(); // Get time - $time = date($this->flextype->container('registry')->get('flextype.settings.date_format'), time()); + $time = date(flextype('registry')->get('flextype.settings.date_format'), time()); // Create API Token account if (Filesystem::write( $api_token_file_path, - $this->flextype->container('yaml')->encode([ + flextype('yaml')->encode([ 'title' => $post_data['title'], 'icon' => $post_data['icon'], 'limit_calls' => (int) $post_data['limit_calls'], @@ -151,18 +146,18 @@ public function addProcess(Request $request, Response $response) : Response 'updated_at' => $time, ]) )) { - $this->flextype->container('flash')->addMessage('success', __('admin_message_registry_api_token_created')); + flextype('flash')->addMessage('success', __('admin_message_registry_api_token_created')); } else { - $this->flextype->container('flash')->addMessage('error', __('admin_message_registry_api_token_was_not_created1')); + flextype('flash')->addMessage('error', __('admin_message_registry_api_token_was_not_created1')); } } else { - $this->flextype->container('flash')->addMessage('error', __('admin_message_registry_api_token_was_not_created2')); + flextype('flash')->addMessage('error', __('admin_message_registry_api_token_was_not_created2')); } if (isset($post_data['create-and-edit'])) { - return $response->withRedirect($this->flextype->container('router')->pathFor('admin.api_registry.edit') . '?token=' . $api_token); + return $response->withRedirect(flextype('router')->pathFor('admin.api_registry.edit') . '?token=' . $api_token); } else { - return $response->withRedirect($this->flextype->container('router')->pathFor('admin.api_registry.index')); + return $response->withRedirect(flextype('router')->pathFor('admin.api_registry.index')); } } @@ -175,9 +170,9 @@ public function addProcess(Request $request, Response $response) : Response public function edit(Request $request, Response $response) : Response { $token = $request->getQueryParams()['token']; - $token_data = $this->flextype->container('yaml')->decode(Filesystem::read(PATH['project'] . '/tokens/registry/' . $token . '/token.yaml')); + $token_data = flextype('yaml')->decode(Filesystem::read(PATH['project'] . '/tokens/registry/' . $token . '/token.yaml')); - return $this->flextype->container('twig')->render( + return flextype('twig')->render( $response, 'plugins/admin/templates/system/api/registry/edit.html', [ @@ -186,15 +181,15 @@ public function edit(Request $request, Response $response) : Response 'token_data' => $token_data, 'links' => [ 'api' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.api.index'), + 'link' => flextype('router')->pathFor('admin.api.index'), 'title' => __('admin_api') ], 'api_registry' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.api_registry.index'), + 'link' => flextype('router')->pathFor('admin.api_registry.index'), 'title' => __('admin_registry') ], 'api_tokens_edit' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.api_registry.edit'), + 'link' => flextype('router')->pathFor('admin.api_registry.edit'), 'title' => __('admin_edit_token'), 'active' => true ], @@ -221,7 +216,7 @@ public function editProcess(Request $request, Response $response) : Response if (Filesystem::has($api_token_file_path)) { if (Filesystem::write( $api_token_file_path, - $this->flextype->container('yaml')->encode([ + flextype('yaml')->encode([ 'title' => $post_data['title'], 'icon' => $post_data['icon'], 'limit_calls' => (int) $post_data['limit_calls'], @@ -231,16 +226,16 @@ public function editProcess(Request $request, Response $response) : Response 'created_by' => $post_data['created_by'], 'created_at' => $post_data['created_at'], 'updated_by' => Session::get('uuid'), - 'updated_at' => date($this->flextype->container('registry')->get('flextype.settings.date_format'), time()), + 'updated_at' => date(flextype('registry')->get('flextype.settings.date_format'), time()), ]) )) { - $this->flextype->container('flash')->addMessage('success', __('admin_message_registry_api_token_updated')); + flextype('flash')->addMessage('success', __('admin_message_registry_api_token_updated')); } } else { - $this->flextype->container('flash')->addMessage('error', __('admin_message_registry_api_token_was_not_updated')); + flextype('flash')->addMessage('error', __('admin_message_registry_api_token_was_not_updated')); } - return $response->withRedirect($this->flextype->container('router')->pathFor('admin.api_registry.index')); + return $response->withRedirect(flextype('router')->pathFor('admin.api_registry.index')); } /** @@ -257,11 +252,11 @@ public function deleteProcess(Request $request, Response $response) : Response $api_token_dir_path = PATH['project'] . '/tokens/registry/' . $post_data['token']; if (Filesystem::deleteDir($api_token_dir_path)) { - $this->flextype->container('flash')->addMessage('success', __('admin_message_registry_api_token_deleted')); + flextype('flash')->addMessage('success', __('admin_message_registry_api_token_deleted')); } else { - $this->flextype->container('flash')->addMessage('error', __('admin_message_registry_api_token_was_not_deleted')); + flextype('flash')->addMessage('error', __('admin_message_registry_api_token_was_not_deleted')); } - return $response->withRedirect($this->flextype->container('router')->pathFor('admin.api_registry.index')); + return $response->withRedirect(flextype('router')->pathFor('admin.api_registry.index')); } } diff --git a/app/Controllers/DashboardController.php b/app/Controllers/DashboardController.php index ccd4d879..d65498ce 100644 --- a/app/Controllers/DashboardController.php +++ b/app/Controllers/DashboardController.php @@ -9,17 +9,12 @@ class DashboardController { - /** - * Flextype Application - */ - protected $flextype; - /** * __construct */ - public function __construct($flextype) + public function __construct() { - $this->flextype = $flextype; + } /** @@ -30,6 +25,6 @@ public function __construct($flextype) */ public function index(/** @scrutinizer ignore-unused */ Request $request, Response $response) : Response { - return $response->withRedirect($this->flextype->container('router')->pathFor('admin.entries.index')); + return $response->withRedirect(flextype('router')->pathFor('admin.entries.index')); } } diff --git a/app/Controllers/EntriesController.php b/app/Controllers/EntriesController.php index 5f92aabc..30b17feb 100644 --- a/app/Controllers/EntriesController.php +++ b/app/Controllers/EntriesController.php @@ -14,17 +14,12 @@ class EntriesController { - /** - * Flextype Application - */ - protected $flextype; - /** * __construct */ - public function __construct($flextype) + public function __construct() { - $this->flextype = $flextype; + } /** @@ -73,7 +68,7 @@ public function index(Request $request, Response $response) : Response if (count($fieldsets_list) > 0) { foreach ($fieldsets_list as $fieldset) { if ($fieldset['type'] == 'file' && $fieldset['extension'] == 'yaml') { - $fieldset_content = $this->flextype->container('yaml')->decode(Filesystem::read($fieldset['path'])); + $fieldset_content = flextype('yaml')->decode(Filesystem::read($fieldset['path'])); if (isset($fieldset_content['form']) && isset($fieldset_content['form']['tabs']) && isset($fieldset_content['form']['tabs']['main']['fields']) && @@ -87,17 +82,17 @@ public function index(Request $request, Response $response) : Response } } - $entry_current = $this->flextype->container('entries')->fetch($this->getEntryID($query)); + $entry_current = flextype('entries')->fetch($this->getEntryID($query)); if (isset($entry_current['items_view'])) { $items_view = $entry_current['items_view']; } else { - $items_view = $this->flextype->container('registry')->get('plugins.admin.settings.entries.items_view_default'); + $items_view = flextype('registry')->get('plugins.admin.settings.entries.items_view_default'); } $entries_list = []; $entries_collection = []; - $entries_collection = collect($this->flextype->container('entries')->fetchCollection($this->getEntryID($query), ['depth' => ['1']]))->orderBy('published_at', 'DESC')->all(); + $entries_collection = collect(flextype('entries')->fetchCollection($this->getEntryID($query), ['depth' => ['1']]))->orderBy('published_at', 'DESC')->all(); foreach ($entries_collection as $slug => $body) { $entries_list[$slug] = $body; @@ -106,7 +101,7 @@ public function index(Request $request, Response $response) : Response } } - return $this->flextype->container('twig')->render( + return flextype('twig')->render( $response, 'plugins/admin/templates/content/entries/index.html', [ @@ -121,7 +116,7 @@ public function index(Request $request, Response $response) : Response 'last' => array_pop($parts), 'links' => [ 'entries' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.entries.index'), + 'link' => flextype('router')->pathFor('admin.entries.index'), 'title' => __('admin_entries'), 'active' => true ] @@ -159,11 +154,11 @@ public function add(Request $request, Response $response) : Response $type = isset($query['type']) ? $query['type']: ''; - return $this->flextype->container('twig')->render( + return flextype('twig')->render( $response, 'plugins/admin/templates/content/entries/add.html', [ - 'entries_list' => collect($this->flextype->container('entries')->fetchCollection($this->getEntryID($query)))->orderBy('order_by', 'ASC')->all(), + 'entries_list' => collect(flextype('entries')->fetchCollection($this->getEntryID($query)))->orderBy('order_by', 'ASC')->all(), 'menu_item' => 'entries', 'current_id' => $this->getEntryID($query), 'parts' => $parts, @@ -172,12 +167,12 @@ public function add(Request $request, Response $response) : Response 'type' => $type, 'links' => [ 'entries' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.entries.index'), + 'link' => flextype('router')->pathFor('admin.entries.index'), 'title' => __('admin_entries'), ], 'entries_add' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.entries.add') . '?id=' . $this->getEntryID($query), + 'link' => flextype('router')->pathFor('admin.entries.add') . '?id=' . $this->getEntryID($query), 'title' => __('admin_create_new_entry'), 'active' => true ] @@ -199,7 +194,7 @@ public function selectEntryTypeProcess(Request $request, Response $response) : R // Get data from POST $data = $request->getParsedBody(); - return $response->withRedirect($this->flextype->container('router')->pathFor('admin.entries.add') . '?id=' . $data['id'] . '&type=' . $data['type']); + return $response->withRedirect(flextype('router')->pathFor('admin.entries.add') . '?id=' . $data['id'] . '&type=' . $data['type']); } /** @@ -223,20 +218,20 @@ public function addProcess(Request $request, Response $response) : Response } // Set new Entry ID using slugify or without it - if ($this->flextype->container('registry')->get('plugins.admin.settings.entries.slugify') == true) { - $id = ltrim($parent_entry_id . '/' . $this->flextype->container('slugify')->slugify($data['id']), '/'); + if (flextype('registry')->get('plugins.admin.settings.entries.slugify') == true) { + $id = ltrim($parent_entry_id . '/' . flextype('slugify')->slugify($data['id']), '/'); } else { $id = ltrim($parent_entry_id . '/' . $data['id'], '/'); } // Check if entry exists then try to create it - if (!$this->flextype->container('entries')->has($id)) { + if (!flextype('entries')->has($id)) { // Check if we have fieldset for this entry - if ($this->flextype->container('fieldsets')->has($data['fieldset'])) { + if (flextype('fieldsets')->has($data['fieldset'])) { // Get fieldset - $fieldset = $this->flextype->container('fieldsets')->fetch($data['fieldset']); + $fieldset = flextype('fieldsets')->fetch($data['fieldset']); // Init entry data $data_from_post = []; @@ -244,19 +239,19 @@ public function addProcess(Request $request, Response $response) : Response $data_result = []; // Define data values based on POST data - $data_from_post['created_by'] = $this->flextype->container('acl')->getUserLoggedInUuid(); - $data_from_post['published_by'] = $this->flextype->container('acl')->getUserLoggedInUuid(); + $data_from_post['created_by'] = flextype('acl')->getUserLoggedInUuid(); + $data_from_post['published_by'] = flextype('acl')->getUserLoggedInUuid(); $data_from_post['title'] = $data['title']; $data_from_post['fieldset'] = $data['fieldset']; $data_from_post['visibility'] = $data['visibility']; - $data_from_post['published_at'] = date($this->flextype->container('registry')->get('flextype.settings.date_format'), time()); + $data_from_post['published_at'] = date(flextype('registry')->get('flextype.settings.date_format'), time()); $data_from_post['routable'] = isset($data['routable']) ? (bool) $data['routable'] : false; // Themes/Templates support for Site Plugin // We need to check if template for current fieldset is exists // if template is not exist then `default` template will be used! - if ($this->flextype->container('registry')->has('plugins.site')) { - $template_path = PATH['project'] . '/themes/' . $this->flextype->container('registry')->get('plugins.site.settings.theme') . '/templates/' . $data['fieldset'] . '.html'; + if (flextype('registry')->has('plugins.site')) { + $template_path = PATH['project'] . '/themes/' . flextype('registry')->get('plugins.site.settings.theme') . '/templates/' . $data['fieldset'] . '.html'; $template = (Filesystem::has($template_path)) ? $data['fieldset'] : 'default'; $data_from_post['template'] = $template; } @@ -297,23 +292,23 @@ public function addProcess(Request $request, Response $response) : Response $data_result = $data_from_post; } - if ($this->flextype->container('entries')->create($id, $data_result)) { - $this->flextype->container('media_folders')->create('entries/' . $id); - $this->flextype->container('flash')->addMessage('success', __('admin_message_entry_created')); + if (flextype('entries')->create($id, $data_result)) { + flextype('media_folders')->create('entries/' . $id); + flextype('flash')->addMessage('success', __('admin_message_entry_created')); } else { - $this->flextype->container('flash')->addMessage('error', __('admin_message_entry_was_not_created')); + flextype('flash')->addMessage('error', __('admin_message_entry_was_not_created')); } } else { - $this->flextype->container('flash')->addMessage('error', __('admin_message_fieldset_not_found')); + flextype('flash')->addMessage('error', __('admin_message_fieldset_not_found')); } } else { - $this->flextype->container('flash')->addMessage('error', __('admin_message_entry_was_not_created')); + flextype('flash')->addMessage('error', __('admin_message_entry_was_not_created')); } if (isset($data['create-and-edit'])) { - return $response->withRedirect($this->flextype->container('router')->pathFor('admin.entries.edit') . '?id=' . $id . '&type=editor'); + return $response->withRedirect(flextype('router')->pathFor('admin.entries.edit') . '?id=' . $id . '&type=editor'); } else { - return $response->withRedirect($this->flextype->container('router')->pathFor('admin.entries.index') . '?id=' . $parent_entry_id); + return $response->withRedirect(flextype('router')->pathFor('admin.entries.index') . '?id=' . $parent_entry_id); } } @@ -337,7 +332,7 @@ public function type(Request $request, Response $response) : Response $parts = [0 => '']; } - $entry = $this->flextype->container('entries')->fetch($this->getEntryID($query)); + $entry = flextype('entries')->fetch($this->getEntryID($query)); $fieldsets = []; @@ -348,7 +343,7 @@ public function type(Request $request, Response $response) : Response if (count($_fieldsets) > 0) { foreach ($_fieldsets as $fieldset) { if ($fieldset['type'] == 'file' && $fieldset['extension'] == 'yaml') { - $fieldset_content = $this->flextype->container('yaml')->decode(Filesystem::read($fieldset['path'])); + $fieldset_content = flextype('yaml')->decode(Filesystem::read($fieldset['path'])); if (isset($fieldset_content['form']) && isset($fieldset_content['form']['tabs']['main']) && isset($fieldset_content['form']['tabs']['main']['fields']) && @@ -364,7 +359,7 @@ public function type(Request $request, Response $response) : Response $fieldset = $entry['fieldset'] ?? []; - return $this->flextype->container('twig')->render( + return flextype('twig')->render( $response, 'plugins/admin/templates/content/entries/type.html', [ @@ -377,12 +372,12 @@ public function type(Request $request, Response $response) : Response 'last' => array_pop($parts), 'links' => [ 'entries' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.entries.index'), + 'link' => flextype('router')->pathFor('admin.entries.index'), 'title' => __('admin_entries'), ], 'entries_type' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.entries.type') . '?id=' . $this->getEntryID($query), + 'link' => flextype('router')->pathFor('admin.entries.type') . '?id=' . $this->getEntryID($query), 'title' => __('admin_type'), 'active' => true ] @@ -405,7 +400,7 @@ public function typeProcess(Request $request, Response $response) : Response $id = $post_data['id']; - $entry = $this->flextype->container('entries')->fetch($id); + $entry = flextype('entries')->fetch($id); Arrays::delete($entry, 'slug'); Arrays::delete($entry, 'id'); @@ -418,21 +413,21 @@ public function typeProcess(Request $request, Response $response) : Response Arrays::delete($post_data, 'save_entry'); Arrays::delete($post_data, 'id'); - $post_data['created_by'] = $this->flextype->container('acl')->getUserLoggedInUuid(); - $post_data['published_by'] = $this->flextype->container('acl')->getUserLoggedInUuid(); + $post_data['created_by'] = flextype('acl')->getUserLoggedInUuid(); + $post_data['published_by'] = flextype('acl')->getUserLoggedInUuid(); $data = array_merge($entry, $post_data); - if ($this->flextype->container('entries')->update( + if (flextype('entries')->update( $id, $data )) { - $this->flextype->container('flash')->addMessage('success', __('admin_message_entry_changes_saved')); + flextype('flash')->addMessage('success', __('admin_message_entry_changes_saved')); } else { - $this->flextype->container('flash')->addMessage('error', __('admin_message_entry_was_not_moved')); + flextype('flash')->addMessage('error', __('admin_message_entry_was_not_moved')); } - return $response->withRedirect($this->flextype->container('router')->pathFor('admin.entries.index') . '?id=' . implode('/', array_slice(explode("/", $id), 0, -1))); + return $response->withRedirect(flextype('router')->pathFor('admin.entries.index') . '?id=' . implode('/', array_slice(explode("/", $id), 0, -1))); } /** @@ -456,7 +451,7 @@ public function move(Request $request, Response $response) : Response $entry_id_current = array_pop($parts); // Fetch entry - $entry = $this->flextype->container('entries')->fetch($this->getEntryID($query)); + $entry = flextype('entries')->fetch($this->getEntryID($query)); // Set Entries IDs in parts if (isset($query['id'])) { @@ -467,15 +462,15 @@ public function move(Request $request, Response $response) : Response // Get entries list $entries_list['/'] = '/'; - foreach ($this->flextype->container('entries')->fetchCollection('', ['depth' => '>0', 'order_by' => ['field' => ['id']]]) as $_entry) { + foreach (flextype('entries')->fetchCollection('', ['depth' => '>0', 'order_by' => ['field' => ['id']]]) as $_entry) { if ($_entry['id'] != '') { $entries_list[$_entry['id']] = $_entry['id']; } else { - $entries_list[$this->flextype->container('registry')->get('flextype.entries.main')] = $this->flextype->container('registry')->get('flextype.entries.main'); + $entries_list[flextype('registry')->get('flextype.entries.main')] = flextype('registry')->get('flextype.entries.main'); } } - return $this->flextype->container('twig')->render( + return flextype('twig')->render( $response, 'plugins/admin/templates/content/entries/move.html', [ @@ -489,12 +484,12 @@ public function move(Request $request, Response $response) : Response 'last' => array_pop($parts), 'links' => [ 'entries' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.entries.index'), + 'link' => flextype('router')->pathFor('admin.entries.index'), 'title' => __('admin_entries'), ], 'entries_move' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.entries.move'), + 'link' => flextype('router')->pathFor('admin.entries.move'), 'title' => __('admin_move'), 'active' => true ] @@ -519,22 +514,22 @@ public function moveProcess(Request $request, Response $response) // Set entry id current $entry_id_current = $data['entry_id_current']; - if (!$this->flextype->container('entries')->has($data['parent_entry'] . '/' . $entry_id_current)) { - if ($this->flextype->container('entries')->rename( + if (!flextype('entries')->has($data['parent_entry'] . '/' . $entry_id_current)) { + if (flextype('entries')->rename( $data['entry_id_path_current'], $data['parent_entry'] . '/' . $entry_id_current )) { - $this->flextype->container('media_folders')->rename('entries/' . $data['entry_id_path_current'], 'entries/' . $data['parent_entry'] . '/' . $entry_id_current); + flextype('media_folders')->rename('entries/' . $data['entry_id_path_current'], 'entries/' . $data['parent_entry'] . '/' . $entry_id_current); - $this->flextype->container('flash')->addMessage('success', __('admin_message_entry_moved')); + flextype('flash')->addMessage('success', __('admin_message_entry_moved')); } else { - $this->flextype->container('flash')->addMessage('error', __('admin_message_entry_was_not_moved')); + flextype('flash')->addMessage('error', __('admin_message_entry_was_not_moved')); } } else { - $this->flextype->container('flash')->addMessage('error', __('admin_message_entry_was_not_moved')); + flextype('flash')->addMessage('error', __('admin_message_entry_was_not_moved')); } - return $response->withRedirect($this->flextype->container('router')->pathFor('admin.entries.index') . '?id=' . (($data['parent_entry'] == '/') ? '' : $data['parent_entry'])); + return $response->withRedirect(flextype('router')->pathFor('admin.entries.index') . '?id=' . (($data['parent_entry'] == '/') ? '' : $data['parent_entry'])); } /** @@ -560,7 +555,7 @@ public function rename(Request $request, Response $response) : Response $entry_id = explode("/", $this->getEntryID($query)); $name_current = array_pop($entry_id); - return $this->flextype->container('twig')->render( + return flextype('twig')->render( $response, 'plugins/admin/templates/content/entries/rename.html', [ @@ -573,12 +568,12 @@ public function rename(Request $request, Response $response) : Response 'last' => array_pop($parts), 'links' => [ 'entries' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.entries.index'), + 'link' => flextype('router')->pathFor('admin.entries.index'), 'title' => __('admin_entries'), ], 'entries_type' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.entries.rename') . '?id=' . $this->getEntryID($query), + 'link' => flextype('router')->pathFor('admin.entries.rename') . '?id=' . $this->getEntryID($query), 'title' => __('admin_rename'), 'active' => true ] @@ -600,23 +595,23 @@ public function renameProcess(Request $request, Response $response) : Response $data = $request->getParsedBody(); // Set name - if ($this->flextype->container('registry')->get('plugins.admin.settings.entries.slugify') == true) { - $name = $this->flextype->container('slugify')->slugify($data['name']); + if (flextype('registry')->get('plugins.admin.settings.entries.slugify') == true) { + $name = flextype('slugify')->slugify($data['name']); } else { $name = $data['name']; } - if ($this->flextype->container('entries')->rename( + if (flextype('entries')->rename( $data['entry_path_current'], $data['entry_parent'] . '/' . $name) ) { - $this->flextype->container('media_folders')->rename('entries/' . $data['entry_path_current'], 'entries/' . $data['entry_parent'] . '/' . $this->flextype->container('slugify')->slugify($data['name'])); - $this->flextype->container('flash')->addMessage('success', __('admin_message_entry_renamed')); + flextype('media_folders')->rename('entries/' . $data['entry_path_current'], 'entries/' . $data['entry_parent'] . '/' . flextype('slugify')->slugify($data['name'])); + flextype('flash')->addMessage('success', __('admin_message_entry_renamed')); } else { - $this->flextype->container('flash')->addMessage('error', __('admin_message_entry_was_not_renamed')); + flextype('flash')->addMessage('error', __('admin_message_entry_was_not_renamed')); } - return $response->withRedirect($this->flextype->container('router')->pathFor('admin.entries.index') . '?id=' . $data['entry_parent']); + return $response->withRedirect(flextype('router')->pathFor('admin.entries.index') . '?id=' . $data['entry_parent']); } /** @@ -634,16 +629,16 @@ public function deleteProcess(Request $request, Response $response) : Response $id = $data['id']; $id_current = $data['id-current']; - if ($this->flextype->container('entries')->delete($id)) { + if (flextype('entries')->delete($id)) { - $this->flextype->container('media_folders')->delete('entries/' . $id); + flextype('media_folders')->delete('entries/' . $id); - $this->flextype->container('flash')->addMessage('success', __('admin_message_entry_deleted')); + flextype('flash')->addMessage('success', __('admin_message_entry_deleted')); } else { - $this->flextype->container('flash')->addMessage('error', __('admin_message_entry_was_not_deleted')); + flextype('flash')->addMessage('error', __('admin_message_entry_was_not_deleted')); } - return $response->withRedirect($this->flextype->container('router')->pathFor('admin.entries.index') . '?id=' . $id_current); + return $response->withRedirect(flextype('router')->pathFor('admin.entries.index') . '?id=' . $id_current); } /** @@ -663,7 +658,7 @@ public function duplicateProcess(Request $request, Response $response) : Respons $random_date = date("Ymd_His"); - $this->flextype->container('entries')->copy($id, $id . '-duplicate-' . $random_date, true); + flextype('entries')->copy($id, $id . '-duplicate-' . $random_date, true); if (Filesystem::has(PATH['project'] . '/uploads' . '/entries/' . $id)) { Filesystem::copy(PATH['project'] . '/uploads' . '/entries/' . $id, PATH['project'] . '/uploads' . '/entries/' . $id . '-duplicate-' . $random_date, true); @@ -671,9 +666,9 @@ public function duplicateProcess(Request $request, Response $response) : Respons Filesystem::createDir(PATH['project'] . '/uploads' . '/entries/' . $id . '-duplicate-' . $random_date); } - $this->flextype->container('flash')->addMessage('success', __('admin_message_entry_duplicated')); + flextype('flash')->addMessage('success', __('admin_message_entry_duplicated')); - return $response->withRedirect($this->flextype->container('router')->pathFor('admin.entries.index') . '?id=' . $parent_id); + return $response->withRedirect(flextype('router')->pathFor('admin.entries.index') . '?id=' . $parent_id); } /** @@ -699,10 +694,10 @@ public function edit(Request $request, Response $response) : Response // Get Entry type $type = $request->getQueryParams()['type']; - $this->flextype->container('registry')->set('entries.fields.parsers.settings.enabled', false); + flextype('registry')->set('entries.fields.parsers.settings.enabled', false); // Get Entry - $entry = $this->flextype->container('entries')->fetch($this->getEntryID($query)); + $entry = flextype('entries')->fetch($this->getEntryID($query)); Arrays::delete($entry, 'slug'); Arrays::delete($entry, 'id'); @@ -710,14 +705,14 @@ public function edit(Request $request, Response $response) : Response // Fieldsets for current entry template $fieldsets_path = PATH['project'] . '/fieldsets/' . (isset($entry['fieldset']) ? $entry['fieldset'] : 'default') . '.yaml'; - $fieldsets = $this->flextype->container('yaml')->decode(Filesystem::read($fieldsets_path)); + $fieldsets = flextype('yaml')->decode(Filesystem::read($fieldsets_path)); is_null($fieldsets) and $fieldsets = []; if ($type == 'source') { - $entry['published_at'] = date($this->flextype->container('registry')->get('flextype.settings.date_format'), $entry['published_at']); - $entry['created_at'] = date($this->flextype->container('registry')->get('flextype.settings.date_format'), $entry['created_at']); + $entry['published_at'] = date(flextype('registry')->get('flextype.settings.date_format'), $entry['published_at']); + $entry['created_at'] = date(flextype('registry')->get('flextype.settings.date_format'), $entry['created_at']); - return $this->flextype->container('twig')->render( + return flextype('twig')->render( $response, 'plugins/admin/templates/content/entries/source.html', [ @@ -725,27 +720,27 @@ public function edit(Request $request, Response $response) : Response 'i' => count($parts), 'last' => array_pop($parts), 'id' => $this->getEntryID($query), - 'data' => $this->flextype->container('frontmatter')->encode($entry), + 'data' => flextype('frontmatter')->encode($entry), 'type' => $type, 'menu_item' => 'entries', 'links' => [ 'entries' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.entries.index'), + 'link' => flextype('router')->pathFor('admin.entries.index'), 'title' => __('admin_entries'), ], 'edit_entry' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.entries.edit') . '?id=' . $this->getEntryID($query). '&type=editor', + 'link' => flextype('router')->pathFor('admin.entries.edit') . '?id=' . $this->getEntryID($query). '&type=editor', 'title' => __('admin_editor'), ], 'edit_entry_media' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.entries.edit') . '?id=' . $this->getEntryID($query) . '&type=media', + 'link' => flextype('router')->pathFor('admin.entries.edit') . '?id=' . $this->getEntryID($query) . '&type=media', 'title' => __('admin_media'), ], 'edit_entry_source' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.entries.edit') . '?id=' . $this->getEntryID($query) . '&type=source', + 'link' => flextype('router')->pathFor('admin.entries.edit') . '?id=' . $this->getEntryID($query) . '&type=source', 'title' => __('admin_source'), 'active' => true ], @@ -761,7 +756,7 @@ public function edit(Request $request, Response $response) : Response ] ); } elseif ($type == 'media') { - return $this->flextype->container('twig')->render( + return flextype('twig')->render( $response, 'plugins/admin/templates/content/entries/media.html', [ @@ -773,22 +768,22 @@ public function edit(Request $request, Response $response) : Response 'menu_item' => 'entries', 'links' => [ 'entries' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.entries.index') . '?id=' . implode('/', array_slice(explode("/", $this->getEntryID($query)), 0, -1)), + 'link' => flextype('router')->pathFor('admin.entries.index') . '?id=' . implode('/', array_slice(explode("/", $this->getEntryID($query)), 0, -1)), 'title' => __('admin_entries'), ], 'edit_entry' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.entries.edit') . '?id=' . $this->getEntryID($query) . '&type=editor', + 'link' => flextype('router')->pathFor('admin.entries.edit') . '?id=' . $this->getEntryID($query) . '&type=editor', 'title' => __('admin_editor'), ], 'edit_entry_media' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.entries.edit') . '?id=' . $this->getEntryID($query) . '&type=media', + 'link' => flextype('router')->pathFor('admin.entries.edit') . '?id=' . $this->getEntryID($query) . '&type=media', 'title' => __('admin_media'), 'active' => true ], 'edit_entry_source' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.entries.edit') . '?id=' . $this->getEntryID($query) . '&type=source', + 'link' => flextype('router')->pathFor('admin.entries.edit') . '?id=' . $this->getEntryID($query) . '&type=source', 'title' => __('admin_source'), ], ] @@ -798,12 +793,12 @@ public function edit(Request $request, Response $response) : Response // Merge current entry fieldset with global fildset if (isset($entry['entry_fieldset'])) { - $form = $this->flextype->container('form')->render(array_replace_recursive($fieldsets, $entry['entry_fieldset']), $entry); + $form = flextype('form')->render(array_replace_recursive($fieldsets, $entry['entry_fieldset']), $entry); } else { - $form = $this->flextype->container('form')->render($fieldsets, $entry); + $form = flextype('form')->render($fieldsets, $entry); } - return $this->flextype->container('twig')->render( + return flextype('twig')->render( $response, 'plugins/admin/templates/content/entries/edit.html', [ @@ -814,20 +809,20 @@ public function edit(Request $request, Response $response) : Response 'menu_item' => 'entries', 'links' => [ 'entries' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.entries.index') . '?id=' . implode('/', array_slice(explode("/", $this->getEntryID($query)), 0, -1)), + 'link' => flextype('router')->pathFor('admin.entries.index') . '?id=' . implode('/', array_slice(explode("/", $this->getEntryID($query)), 0, -1)), 'title' => __('admin_entries') ], 'edit_entry' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.entries.edit') . '?id=' . $this->getEntryID($query) . '&type=editor', + 'link' => flextype('router')->pathFor('admin.entries.edit') . '?id=' . $this->getEntryID($query) . '&type=editor', 'title' => __('admin_editor'), 'active' => true ], 'edit_entry_media' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.entries.edit') . '?id=' . $this->getEntryID($query) . '&type=media', + 'link' => flextype('router')->pathFor('admin.entries.edit') . '?id=' . $this->getEntryID($query) . '&type=media', 'title' => __('admin_media') ], 'edit_entry_source' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.entries.edit') . '?id=' . $this->getEntryID($query) . '&type=source', + 'link' => flextype('router')->pathFor('admin.entries.edit') . '?id=' . $this->getEntryID($query) . '&type=source', 'title' => __('admin_source') ], ], @@ -865,20 +860,20 @@ public function editProcess(Request $request, Response $response) : Response // Data from POST $data = $request->getParsedBody(); - $entry = $this->flextype->container('frontmatter')->decode($data['data']); + $entry = flextype('frontmatter')->decode($data['data']); - $entry['created_by'] = $this->flextype->container('acl')->getUserLoggedInUuid(); - $entry['published_by'] = $this->flextype->container('acl')->getUserLoggedInUuid(); + $entry['created_by'] = flextype('acl')->getUserLoggedInUuid(); + $entry['published_by'] = flextype('acl')->getUserLoggedInUuid(); Arrays::delete($entry, 'slug'); Arrays::delete($entry, 'id'); Arrays::delete($entry, 'modified_at'); // Update entry - if (Filesystem::write(PATH['project'] . '/entries' . '/' . $id . '/entry.md', $this->flextype->container('frontmatter')->encode($entry))) { - $this->flextype->container('flash')->addMessage('success', __('admin_message_entry_changes_saved')); + if (Filesystem::write(PATH['project'] . '/entries' . '/' . $id . '/entry.md', flextype('frontmatter')->encode($entry))) { + flextype('flash')->addMessage('success', __('admin_message_entry_changes_saved')); } else { - $this->flextype->container('flash')->addMessage('error', __('admin_message_entry_changes_not_saved')); + flextype('flash')->addMessage('error', __('admin_message_entry_changes_not_saved')); } } else { // Result data to save @@ -902,21 +897,21 @@ public function editProcess(Request $request, Response $response) : Response $data['published_by'] = Session::get('uuid'); // Fetch entry - $entry = $this->flextype->container('entries')->fetch($id); + $entry = flextype('entries')->fetch($id); Arrays::delete($entry, 'slug'); Arrays::delete($entry, 'id'); Arrays::delete($entry, 'modified_at'); if (isset($data['created_at'])) { - $data['created_at'] = date($this->flextype->container('registry')->get('flextype.settings.date_format'), strtotime($data['created_at'])); + $data['created_at'] = date(flextype('registry')->get('flextype.settings.date_format'), strtotime($data['created_at'])); } else { - $data['created_at'] = date($this->flextype->container('registry')->get('flextype.settings.date_format'), $entry['created_at']); + $data['created_at'] = date(flextype('registry')->get('flextype.settings.date_format'), $entry['created_at']); } if (isset($data['published_at'])) { - $data['published_at'] = (string) date($this->flextype->container('registry')->get('flextype.settings.date_format'), strtotime($data['published_at'])); + $data['published_at'] = (string) date(flextype('registry')->get('flextype.settings.date_format'), strtotime($data['published_at'])); } else { - $data['published_at'] = (string) date($this->flextype->container('registry')->get('flextype.settings.date_format'), $entry['published_at']); + $data['published_at'] = (string) date(flextype('registry')->get('flextype.settings.date_format'), $entry['published_at']); } if (isset($data['routable'])) { @@ -931,14 +926,14 @@ public function editProcess(Request $request, Response $response) : Response $result_data = array_merge($entry, $data); // Update entry - if ($this->flextype->container('entries')->update($id, $result_data)) { - $this->flextype->container('flash')->addMessage('success', __('admin_message_entry_changes_saved')); + if (flextype('entries')->update($id, $result_data)) { + flextype('flash')->addMessage('success', __('admin_message_entry_changes_saved')); } else { - $this->flextype->container('flash')->addMessage('error', __('admin_message_entry_changes_not_saved')); + flextype('flash')->addMessage('error', __('admin_message_entry_changes_not_saved')); } } - return $response->withRedirect($this->flextype->container('router')->pathFor('admin.entries.edit') . '?id=' . $id . '&type=' . $type); + return $response->withRedirect(flextype('router')->pathFor('admin.entries.edit') . '?id=' . $id . '&type=' . $type); } /** @@ -956,11 +951,11 @@ public function deleteMediaFileProcess(Request $request, Response $response) : R $entry_id = $data['entry-id']; $media_id = $data['media-id']; - $this->flextype->container('media_files')->delete('entries/' . $entry_id . '/' . $media_id); + flextype('media_files')->delete('entries/' . $entry_id . '/' . $media_id); - $this->flextype->container('flash')->addMessage('success', __('admin_message_entry_file_deleted')); + flextype('flash')->addMessage('success', __('admin_message_entry_file_deleted')); - return $response->withRedirect($this->flextype->container('router')->pathFor('admin.entries.edit') . '?id=' . $entry_id . '&type=media'); + return $response->withRedirect(flextype('router')->pathFor('admin.entries.edit') . '?id=' . $entry_id . '&type=media'); } /** @@ -975,13 +970,13 @@ public function uploadMediaFileProcess(Request $request, Response $response) : R { $data = $request->getParsedBody(); - if ($this->flextype->container('media_files')->upload($_FILES['file'], '/entries/' . $data['entry-id'] . '/')) { - $this->flextype->container('flash')->addMessage('success', __('admin_message_entry_file_uploaded')); + if (flextype('media_files')->upload($_FILES['file'], '/entries/' . $data['entry-id'] . '/')) { + flextype('flash')->addMessage('success', __('admin_message_entry_file_uploaded')); } else { - $this->flextype->container('flash')->addMessage('error', __('admin_message_entry_file_not_uploaded')); + flextype('flash')->addMessage('error', __('admin_message_entry_file_not_uploaded')); } - return $response->withRedirect($this->flextype->container('router')->pathFor('admin.entries.edit') . '?id=' . $data['entry-id'] . '&type=media'); + return $response->withRedirect(flextype('router')->pathFor('admin.entries.edit') . '?id=' . $data['entry-id'] . '&type=media'); } /** @@ -1002,7 +997,7 @@ public function getMediaList(string $id, bool $path = false) : array } foreach (array_diff(scandir(PATH['project'] . '/uploads/entries/' . $id), ['..', '.']) as $file) { - if (strpos($this->flextype->container('registry')->get('plugins.admin.settings.entries.media.accept_file_types'), $file_ext = substr(strrchr($file, '.'), 1)) !== false) { + if (strpos(flextype('registry')->get('plugins.admin.settings.entries.media.accept_file_types'), $file_ext = substr(strrchr($file, '.'), 1)) !== false) { if (strpos($file, strtolower($file_ext), 1)) { if ($file !== 'entry.md') { if ($path) { diff --git a/app/Controllers/PluginsController.php b/app/Controllers/PluginsController.php index 9728fdc5..b8d8dc49 100644 --- a/app/Controllers/PluginsController.php +++ b/app/Controllers/PluginsController.php @@ -15,17 +15,13 @@ class PluginsController { - /** - * Flextype Application - */ - protected $flextype; /** * __construct */ - public function __construct($flextype) + public function __construct() { - $this->flextype = $flextype; + } /** @@ -37,11 +33,11 @@ public function __construct($flextype) public function index(/** @scrutinizer ignore-unused */ Request $request, Response $response) : Response { - $plugins_list = $this->flextype->container('registry')->get('plugins'); + $plugins_list = flextype('registry')->get('plugins'); ksort($plugins_list); - return $this->flextype->container('twig')->render( + return flextype('twig')->render( $response, 'plugins/admin/templates/extends/plugins/index.html', [ @@ -49,7 +45,7 @@ public function index(/** @scrutinizer ignore-unused */ Request $request, Respon 'menu_item' => 'plugins', 'links' => [ 'plugins' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.plugins.index'), + 'link' => flextype('router')->pathFor('admin.plugins.index'), 'title' => __('admin_plugins'), 'active' => true ], @@ -77,19 +73,19 @@ public function pluginStatusProcess(Request $request, Response $response) : Resp $post_data = $request->getParsedBody(); $custom_plugin_settings_file = PATH['project'] . '/config/' . '/plugins/' . $post_data['plugin-key'] . '/settings.yaml'; - $custom_plugin_settings_file_data = $this->flextype->container('yaml')->decode(Filesystem::read($custom_plugin_settings_file)); + $custom_plugin_settings_file_data = flextype('yaml')->decode(Filesystem::read($custom_plugin_settings_file)); $status = ($post_data['plugin-set-status'] == 'true') ? true : false; Arrays::set($custom_plugin_settings_file_data, 'enabled', $status); - Filesystem::write($custom_plugin_settings_file, $this->flextype->container('yaml')->encode($custom_plugin_settings_file_data)); + Filesystem::write($custom_plugin_settings_file, flextype('yaml')->encode($custom_plugin_settings_file_data)); // Clear doctrine cache - $this->flextype->container('cache')->purge('doctrine'); + flextype('cache')->purge('doctrine'); // Redirect to plugins index page - return $response->withRedirect($this->flextype->container('router')->pathFor('admin.plugins.index')); + return $response->withRedirect(flextype('router')->pathFor('admin.plugins.index')); } /** @@ -109,21 +105,21 @@ public function information(Request $request, Response $response) : Response // Get plugin custom manifest content $custom_plugin_manifest_file_content = Filesystem::read($custom_plugin_manifest_file); - return $this->flextype->container('twig')->render( + return flextype('twig')->render( $response, 'plugins/admin/templates/extends/plugins/information.html', [ 'menu_item' => 'plugins', 'id' => $id, - 'plugin_manifest' => $this->flextype->container('yaml')->decode($custom_plugin_manifest_file_content), + 'plugin_manifest' => flextype('yaml')->decode($custom_plugin_manifest_file_content), 'links' => [ 'plugins' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.plugins.index'), + 'link' => flextype('router')->pathFor('admin.plugins.index'), 'title' => __('admin_plugins'), ], 'plugins_information' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.plugins.information') . '?id=' . $request->getQueryParams()['id'], + 'link' => flextype('router')->pathFor('admin.plugins.information') . '?id=' . $request->getQueryParams()['id'], 'title' => __('admin_information'), 'active' => true ], @@ -149,7 +145,7 @@ public function settings(Request $request, Response $response) : Response // Get plugin custom setting file content $custom_plugin_settings_file_content = Filesystem::read($custom_plugin_settings_file); - return $this->flextype->container('twig')->render( + return flextype('twig')->render( $response, 'plugins/admin/templates/extends/plugins/settings.html', [ @@ -158,11 +154,11 @@ public function settings(Request $request, Response $response) : Response 'plugin_settings' => $custom_plugin_settings_file_content, 'links' => [ 'plugins' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.plugins.index'), + 'link' => flextype('router')->pathFor('admin.plugins.index'), 'title' => __('admin_plugins'), ], 'plugins_settings' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.plugins.settings') . '?id=' . $request->getQueryParams()['id'], + 'link' => flextype('router')->pathFor('admin.plugins.settings') . '?id=' . $request->getQueryParams()['id'], 'title' => __('admin_settings'), 'active' => true ], @@ -195,11 +191,11 @@ public function settingsProcess(Request $request, Response $response) : Response $custom_plugin_settings_file = PATH['project'] . '/config/' . '/plugins/' . $id . '/settings.yaml'; if (Filesystem::write($custom_plugin_settings_file, $data)) { - $this->flextype->container('flash')->addMessage('success', __('admin_message_plugin_settings_saved')); + flextype('flash')->addMessage('success', __('admin_message_plugin_settings_saved')); } else { - $this->flextype->container('flash')->addMessage('error', __('admin_message_plugin_settings_not_saved')); + flextype('flash')->addMessage('error', __('admin_message_plugin_settings_not_saved')); } - return $response->withRedirect($this->flextype->container('router')->pathFor('admin.plugins.settings') . '?id=' . $id); + return $response->withRedirect(flextype('router')->pathFor('admin.plugins.settings') . '?id=' . $id); } } diff --git a/app/Controllers/SettingsController.php b/app/Controllers/SettingsController.php index eb9fc3f6..40a80f3e 100644 --- a/app/Controllers/SettingsController.php +++ b/app/Controllers/SettingsController.php @@ -15,19 +15,15 @@ class SettingsController { - /** - * Flextype Application - */ - protected $flextype; /** * __construct */ - public function __construct($flextype) + public function __construct() { - $this->flextype = $flextype; + } - + /** * Index page * @@ -36,7 +32,7 @@ public function __construct($flextype) */ public function index(/** @scrutinizer ignore-unused */ Request $request, Response $response) : Response { - return $this->flextype->container('twig')->render( + return flextype('twig')->render( $response, 'plugins/admin/templates/system/settings/index.html', [ @@ -44,7 +40,7 @@ public function index(/** @scrutinizer ignore-unused */ Request $request, Respon 'menu_item' => 'settings', 'links' => [ 'settings' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.settings.index'), + 'link' => flextype('router')->pathFor('admin.settings.index'), 'title' => __('admin_settings'), 'active' => true ], @@ -71,12 +67,12 @@ public function updateSettingsProcess(Request $request, Response $response) : Re $post_data = $request->getParsedBody(); if (Filesystem::write(PATH['project'] . '/config/flextype/' . '/settings.yaml', $post_data['data'])) { - $this->flextype->container('flash')->addMessage('success', __('admin_message_settings_saved')); + flextype('flash')->addMessage('success', __('admin_message_settings_saved')); } else { - $this->flextype->container('flash')->addMessage('error', __('admin_message_settings_was_not_saved')); + flextype('flash')->addMessage('error', __('admin_message_settings_was_not_saved')); } - return $response->withRedirect($this->flextype->container('router')->pathFor('admin.settings.index')); + return $response->withRedirect(flextype('router')->pathFor('admin.settings.index')); } /** diff --git a/app/Controllers/ToolsController.php b/app/Controllers/ToolsController.php index 19f82ee7..857c4b87 100644 --- a/app/Controllers/ToolsController.php +++ b/app/Controllers/ToolsController.php @@ -21,17 +21,12 @@ class ToolsController { - /** - * Flextype Application - */ - protected $flextype; - /** * __construct */ - public function __construct($flextype) + public function __construct() { - $this->flextype = $flextype; + } /** @@ -42,7 +37,7 @@ public function __construct($flextype) */ public function index(Request $request, Response $response) : Response { - return $response->withRedirect($this->flextype->container('router')->pathFor('admin.tools.information')); + return $response->withRedirect(flextype('router')->pathFor('admin.tools.information')); } /** @@ -53,7 +48,7 @@ public function index(Request $request, Response $response) : Response */ public function information(Request $request, Response $response) : Response { - return $this->flextype->container('twig')->render( + return flextype('twig')->render( $response, 'plugins/admin/templates/system/tools/information.html', [ @@ -63,17 +58,17 @@ public function information(Request $request, Response $response) : Response 'php_sapi_name' => php_sapi_name(), 'links' => [ 'information' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.tools.index'), + 'link' => flextype('router')->pathFor('admin.tools.index'), 'title' => __('admin_information'), 'active' => true ], 'cache' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.tools.cache'), + 'link' => flextype('router')->pathFor('admin.tools.cache'), 'title' => __('admin_cache'), ], 'registry' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.tools.registry'), + 'link' => flextype('router')->pathFor('admin.tools.registry'), 'title' => __('admin_registry'), ], @@ -90,7 +85,7 @@ public function information(Request $request, Response $response) : Response */ public function cache(Request $request, Response $response) : Response { - return $this->flextype->container('twig')->render( + return flextype('twig')->render( $response, 'plugins/admin/templates/system/tools/cache.html', [ @@ -100,17 +95,17 @@ public function cache(Request $request, Response $response) : Response 'twig_size' => Number::byteFormat($this->getDirectorySize(PATH['cache'] . '/twig')), 'links' => [ 'information' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.tools.index'), + 'link' => flextype('router')->pathFor('admin.tools.index'), 'title' => __('admin_information'), ], 'cache' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.tools.cache'), + 'link' => flextype('router')->pathFor('admin.tools.cache'), 'title' => __('admin_cache'), 'active' => true ], 'registry' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.tools.registry'), + 'link' => flextype('router')->pathFor('admin.tools.registry'), 'title' => __('admin_registry'), ], @@ -119,7 +114,7 @@ public function cache(Request $request, Response $response) : Response 'tools_clear_cache' => [ 'type' => 'action', 'id' => 'clear-cache-all', - 'link' => $this->flextype->container('router')->pathFor('admin.tools.clearCacheAllProcess'), + 'link' => flextype('router')->pathFor('admin.tools.clearCacheAllProcess'), 'title' => __('admin_clear_cache_all'), ], ], @@ -135,25 +130,25 @@ public function cache(Request $request, Response $response) : Response */ public function registry(Request $request, Response $response) : Response { - return $this->flextype->container('twig')->render( + return flextype('twig')->render( $response, 'plugins/admin/templates/system/tools/registry.html', [ 'menu_item' => 'tools', - 'registry_dump' => $this->dotArray($this->flextype->container('registry')->all()), + 'registry_dump' => $this->dotArray(flextype('registry')->all()), 'links' => [ 'information' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.tools.index'), + 'link' => flextype('router')->pathFor('admin.tools.index'), 'title' => __('admin_information'), ], 'cache' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.tools.cache'), + 'link' => flextype('router')->pathFor('admin.tools.cache'), 'title' => __('admin_cache'), ], 'registry' => [ - 'link' => $this->flextype->container('router')->pathFor('admin.tools.registry'), + 'link' => flextype('router')->pathFor('admin.tools.registry'), 'title' => __('admin_registry'), 'active' => true ], @@ -172,12 +167,12 @@ public function clearCacheProcess(Request $request, Response $response) : Respon { $id = $request->getParsedBody()['cache-id']; - $this->flextype->container('cache')->purge('doctrine'); - $this->flextype->container('cache')->purge('preflight'); + flextype('cache')->purge('doctrine'); + flextype('cache')->purge('preflight'); - $this->flextype->container('flash')->addMessage('success', __('admin_message_cache_files_deleted')); + flextype('flash')->addMessage('success', __('admin_message_cache_files_deleted')); - return $response->withRedirect($this->flextype->container('router')->pathFor('admin.tools.cache')); + return $response->withRedirect(flextype('router')->pathFor('admin.tools.cache')); } /** @@ -188,11 +183,11 @@ public function clearCacheProcess(Request $request, Response $response) : Respon */ public function clearCacheAllProcess(Request $request, Response $response) : Response { - $this->flextype->container('cache')->purgeAll(); + flextype('cache')->purgeAll(); - $this->flextype->container('flash')->addMessage('success', __('admin_message_cache_files_deleted')); + flextype('flash')->addMessage('success', __('admin_message_cache_files_deleted')); - return $response->withRedirect($this->flextype->container('router')->pathFor('admin.tools.cache')); + return $response->withRedirect(flextype('router')->pathFor('admin.tools.cache')); } /** diff --git a/bootstrap.php b/bootstrap.php index ead99bdb..87770d6d 100755 --- a/bootstrap.php +++ b/bootstrap.php @@ -18,7 +18,7 @@ /** * Set base admin route */ -$admin_route = $flextype->container('registry')->get('plugins.admin.settings.route'); +$admin_route = flextype('registry')->get('plugins.admin.settings.route'); /** * Ensure vendor libraries exist diff --git a/composer.json b/composer.json index 602cf1fe..b853336d 100755 --- a/composer.json +++ b/composer.json @@ -16,13 +16,13 @@ "issues": "https://github.com/flextype/issues" }, "require": { - "php": ">=7.2.5" + "php": ">=7.3.0" }, "config": { "apcu-autoloader": true, "optimize-autoloader": true, "platform": { - "php": "7.2.5" + "php": "7.3.0" } }, "autoload": { diff --git a/dependencies.php b/dependencies.php index b87e4a08..2ae8f337 100644 --- a/dependencies.php +++ b/dependencies.php @@ -27,73 +27,73 @@ use Flextype\Plugin\Admin\Controllers\ApiAccessController; // Set Default Admin locale -I18n::$locale = $flextype->container('registry')->get('flextype.settings.locale'); +I18n::$locale = flextype('registry')->get('flextype.settings.locale'); // Add Admin Navigation -$flextype->container('registry')->set('plugins.admin.settings.navigation.content.entries', ['title' => __('admin_entries'), 'icon' => 'fas fa-database', 'link' => $flextype->container('router')->pathFor('admin.entries.index')]); -$flextype->container('registry')->set('plugins.admin.settings.navigation.extends.plugins', ['title' => __('admin_plugins'),'icon' => 'fas fa-plug', 'link' => $flextype->container('router')->pathFor('admin.plugins.index')]); -$flextype->container('registry')->set('plugins.admin.settings.navigation.system.tools', ['title' => __('admin_tools'),'icon' => 'fas fa-toolbox', 'link' => $flextype->container('router')->pathFor('admin.tools.index')]); -$flextype->container('registry')->set('plugins.admin.settings.navigation.system.api', ['title' => __('admin_api'),'icon' => 'fas fa-network-wired', 'link' => $flextype->container('router')->pathFor('admin.api.index')]); +flextype('registry')->set('plugins.admin.settings.navigation.content.entries', ['title' => __('admin_entries'), 'icon' => 'fas fa-database', 'link' => flextype('router')->pathFor('admin.entries.index')]); +flextype('registry')->set('plugins.admin.settings.navigation.extends.plugins', ['title' => __('admin_plugins'),'icon' => 'fas fa-plug', 'link' => flextype('router')->pathFor('admin.plugins.index')]); +flextype('registry')->set('plugins.admin.settings.navigation.system.tools', ['title' => __('admin_tools'),'icon' => 'fas fa-toolbox', 'link' => flextype('router')->pathFor('admin.tools.index')]); +flextype('registry')->set('plugins.admin.settings.navigation.system.api', ['title' => __('admin_api'),'icon' => 'fas fa-network-wired', 'link' => flextype('router')->pathFor('admin.api.index')]); /** * Add Assets */ -$_admin_css = ($flextype->container('registry')->has('assets.admin.css')) ? $flextype->container('registry')->get('assets.admin.css') : []; -$_admin_js = ($flextype->container('registry')->has('assets.admin.js')) ? $flextype->container('registry')->get('assets.admin.js') : []; +$_admin_css = (flextype('registry')->has('assets.admin.css')) ? flextype('registry')->get('assets.admin.css') : []; +$_admin_js = (flextype('registry')->has('assets.admin.js')) ? flextype('registry')->get('assets.admin.js') : []; -$flextype->container('registry')->set('assets.admin.css', +flextype('registry')->set('assets.admin.css', array_merge($_admin_css, ['project/plugins/admin/assets/dist/css/admin-vendor-build.min.css', 'project/plugins/admin/assets/dist/css/admin-build.min.css'])); -$flextype->container('registry')->set('assets.admin.js', +flextype('registry')->set('assets.admin.js', array_merge($_admin_js, ['project/plugins/admin/assets/dist/js/admin-vendor-build.min.js'])); -$flextype->container()['DashboardController'] = static function () use ($flextype) { - return new DashboardController($flextype); +flextype()->container()['DashboardController'] = static function () { + return new DashboardController(); }; -$flextype->container()['SettingsController'] = static function () use ($flextype) { - return new SettingsController($flextype); +flextype()->container()['SettingsController'] = static function () { + return new SettingsController(); }; -$flextype->container()['PluginsController'] = static function () use ($flextype) { - return new PluginsController($flextype); +flextype()->container()['PluginsController'] = static function () { + return new PluginsController(); }; -$flextype->container()['EntriesController'] = static function () use ($flextype) { - return new EntriesController($flextype); +flextype()->container()['EntriesController'] = static function () { + return new EntriesController(); }; -$flextype->container()['ToolsController'] = static function () use ($flextype) { - return new ToolsController($flextype); +flextype()->container()['ToolsController'] = static function () { + return new ToolsController(); }; -$flextype->container()['ApiController'] = static function () use ($flextype) { - return new ApiController($flextype); +flextype()->container()['ApiController'] = static function () { + return new ApiController(); }; -$flextype->container()['ApiEntriesController'] = static function () use ($flextype) { - return new ApiEntriesController($flextype); +flextype()->container()['ApiEntriesController'] = static function () { + return new ApiEntriesController(); }; -$flextype->container()['ApiFilesController'] = static function () use ($flextype) { - return new ApiFilesController($flextype); +flextype()->container()['ApiFilesController'] = static function () { + return new ApiFilesController(); }; -$flextype->container()['ApiFoldersController'] = static function () use ($flextype) { - return new ApiFoldersController($flextype); +flextype()->container()['ApiFoldersController'] = static function () { + return new ApiFoldersController(); }; -$flextype->container()['ApiImagesController'] = static function () use ($flextype) { - return new ApiImagesController($flextype); +flextype()->container()['ApiImagesController'] = static function () { + return new ApiImagesController(); }; -$flextype->container()['ApiAccessController'] = static function () use ($flextype) { - return new ApiAccessController($flextype); +flextype()->container()['ApiAccessController'] = static function () { + return new ApiAccessController(); }; -$flextype->container()['ApiRegistryController'] = static function () use ($flextype) { - return new ApiRegistryController($flextype); +flextype()->container()['ApiRegistryController'] = static function () { + return new ApiRegistryController(); }; diff --git a/package.json b/package.json index cec5867b..3c7c567f 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "Admin", - "version": "1.2.0", + "version": "1.3.0", "description": "Admin theme for Flextype", "homepage": "http://flextype.org", "author": "Sergey Romanenko", diff --git a/plugin.yaml b/plugin.yaml index 350d1b4b..986dab03 100755 --- a/plugin.yaml +++ b/plugin.yaml @@ -1,5 +1,5 @@ name: Admin -version: 1.2.0 +version: 1.3.0 description: Admin Panel plugin for Flextype. icon: fab fa-fort-awesome author: @@ -14,7 +14,7 @@ keywords: admin, panel, manager license: MIT dependencies: - flextype: 0.9.10 + flextype: 0.9.11 twig: '>=1.0.0' icon: '>=1.0.0' form: '>=1.0.0' diff --git a/routes/web.php b/routes/web.php index 54798ffc..adb155ff 100644 --- a/routes/web.php +++ b/routes/web.php @@ -5,94 +5,94 @@ use Flextype\Plugin\Acl\Middlewares\AclIsUserLoggedInMiddleware; use Flextype\Plugin\Acl\Middlewares\AclIsUserLoggedInRolesInMiddleware; -$flextype->group('/' . $admin_route, function () use ($flextype) : void { +flextype()->group('/' . $admin_route, function () : void { // Dashboard - $flextype->get('', 'DashboardController:index')->setName('admin.dashboard.index'); + flextype()->get('', 'DashboardController:index')->setName('admin.dashboard.index'); // EntriesController - $flextype->get('/entries', 'EntriesController:index')->setName('admin.entries.index'); - $flextype->get('/entries/edit', 'EntriesController:edit')->setName('admin.entries.edit'); - $flextype->post('/entries/edit', 'EntriesController:editProcess')->setName('admin.entries.editProcess'); - $flextype->get('/entries/add', 'EntriesController:add')->setName('admin.entries.add'); - $flextype->post('/entries/add', 'EntriesController:addProcess')->setName('admin.entries.addProcess'); - $flextype->post('/entries/select-entry-type', 'EntriesController:selectEntryTypeProcess')->setName('admin.entries.selectEntryTypeProcess'); - $flextype->get('/entries/move', 'EntriesController:move')->setName('admin.entries.move'); - $flextype->post('/entries/move', 'EntriesController:moveProcess')->setName('admin.entries.moveProcess'); - $flextype->get('/entries/rename', 'EntriesController:rename')->setName('admin.entries.rename'); - $flextype->post('/entries/rename', 'EntriesController:renameProcess')->setName('admin.entries.renameProcess'); - $flextype->get('/entries/type', 'EntriesController:type')->setName('admin.entries.type'); - $flextype->post('/entries/type', 'EntriesController:typeProcess')->setName('admin.entries.typeProcess'); - $flextype->post('/entries/duplicate', 'EntriesController:duplicateProcess')->setName('admin.entries.duplicateProcess'); - $flextype->post('/entries/delete', 'EntriesController:deleteProcess')->setName('admin.entries.deleteProcess'); - $flextype->post('/entries/delete-media-file', 'EntriesController:deleteMediaFileProcess')->setName('admin.entries.deleteMediaFileProcess'); - $flextype->post('/entries/upload-media-file', 'EntriesController:uploadMediaFileProcess')->setName('admin.entries.uploadMediaFileProcess'); - $flextype->post('/entries/display-view-process', 'EntriesController:displayViewProcess')->setName('admin.entries.displayViewProcess'); + flextype()->get('/entries', 'EntriesController:index')->setName('admin.entries.index'); + flextype()->get('/entries/edit', 'EntriesController:edit')->setName('admin.entries.edit'); + flextype()->post('/entries/edit', 'EntriesController:editProcess')->setName('admin.entries.editProcess'); + flextype()->get('/entries/add', 'EntriesController:add')->setName('admin.entries.add'); + flextype()->post('/entries/add', 'EntriesController:addProcess')->setName('admin.entries.addProcess'); + flextype()->post('/entries/select-entry-type', 'EntriesController:selectEntryTypeProcess')->setName('admin.entries.selectEntryTypeProcess'); + flextype()->get('/entries/move', 'EntriesController:move')->setName('admin.entries.move'); + flextype()->post('/entries/move', 'EntriesController:moveProcess')->setName('admin.entries.moveProcess'); + flextype()->get('/entries/rename', 'EntriesController:rename')->setName('admin.entries.rename'); + flextype()->post('/entries/rename', 'EntriesController:renameProcess')->setName('admin.entries.renameProcess'); + flextype()->get('/entries/type', 'EntriesController:type')->setName('admin.entries.type'); + flextype()->post('/entries/type', 'EntriesController:typeProcess')->setName('admin.entries.typeProcess'); + flextype()->post('/entries/duplicate', 'EntriesController:duplicateProcess')->setName('admin.entries.duplicateProcess'); + flextype()->post('/entries/delete', 'EntriesController:deleteProcess')->setName('admin.entries.deleteProcess'); + flextype()->post('/entries/delete-media-file', 'EntriesController:deleteMediaFileProcess')->setName('admin.entries.deleteMediaFileProcess'); + flextype()->post('/entries/upload-media-file', 'EntriesController:uploadMediaFileProcess')->setName('admin.entries.uploadMediaFileProcess'); + flextype()->post('/entries/display-view-process', 'EntriesController:displayViewProcess')->setName('admin.entries.displayViewProcess'); // Settings Controller - $flextype->get('/settings', 'SettingsController:index')->setName('admin.settings.index'); - $flextype->post('/settings', 'SettingsController:updateSettingsProcess')->setName('admin.settings.update'); + flextype()->get('/settings', 'SettingsController:index')->setName('admin.settings.index'); + flextype()->post('/settings', 'SettingsController:updateSettingsProcess')->setName('admin.settings.update'); // Plugins Controller - $flextype->get('/plugins', 'PluginsController:index')->setName('admin.plugins.index'); - $flextype->get('/plugins/information', 'PluginsController:information')->setName('admin.plugins.information'); - $flextype->get('/plugins/settings', 'PluginsController:settings')->setName('admin.plugins.settings'); - $flextype->post('/plugins/settings', 'PluginsController:settingsProcess')->setName('admin.plugins.settingsProcess'); - $flextype->post('/plugins/update-status', 'PluginsController:pluginStatusProcess')->setName('admin.plugins.update-status'); + flextype()->get('/plugins', 'PluginsController:index')->setName('admin.plugins.index'); + flextype()->get('/plugins/information', 'PluginsController:information')->setName('admin.plugins.information'); + flextype()->get('/plugins/settings', 'PluginsController:settings')->setName('admin.plugins.settings'); + flextype()->post('/plugins/settings', 'PluginsController:settingsProcess')->setName('admin.plugins.settingsProcess'); + flextype()->post('/plugins/update-status', 'PluginsController:pluginStatusProcess')->setName('admin.plugins.update-status'); // ToolsController - $flextype->get('/tools', 'ToolsController:index')->setName('admin.tools.index'); - $flextype->get('/tools/information', 'ToolsController:information')->setName('admin.tools.information'); - $flextype->get('/tools/registry', 'ToolsController:registry')->setName('admin.tools.registry'); - $flextype->get('/tools/cache', 'ToolsController:cache')->setName('admin.tools.cache'); - $flextype->post('/tools/cache', 'ToolsController:clearCacheProcess')->setName('admin.tools.clearCacheProcess'); - $flextype->post('/tools/cache-all', 'ToolsController:clearCacheAllProcess')->setName('admin.tools.clearCacheAllProcess'); + flextype()->get('/tools', 'ToolsController:index')->setName('admin.tools.index'); + flextype()->get('/tools/information', 'ToolsController:information')->setName('admin.tools.information'); + flextype()->get('/tools/registry', 'ToolsController:registry')->setName('admin.tools.registry'); + flextype()->get('/tools/cache', 'ToolsController:cache')->setName('admin.tools.cache'); + flextype()->post('/tools/cache', 'ToolsController:clearCacheProcess')->setName('admin.tools.clearCacheProcess'); + flextype()->post('/tools/cache-all', 'ToolsController:clearCacheAllProcess')->setName('admin.tools.clearCacheAllProcess'); // ApiController - $flextype->get('/api', 'ApiController:index')->setName('admin.api.index'); + flextype()->get('/api', 'ApiController:index')->setName('admin.api.index'); - $flextype->get('/api/entries', 'ApiEntriesController:index')->setName('admin.api_entries.index'); - $flextype->get('/api/entries/add', 'ApiEntriesController:add')->setName('admin.api_entries.add'); - $flextype->post('/api/entries/add', 'ApiEntriesController:addProcess')->setName('admin.api_entries.addProcess'); - $flextype->get('/api/entries/edit', 'ApiEntriesController:edit')->setName('admin.api_entries.edit'); - $flextype->post('/api/entries/edit', 'ApiEntriesController:editProcess')->setName('admin.api_entries.editProcess'); - $flextype->post('/api/entries/delete', 'ApiEntriesController:deleteProcess')->setName('admin.api_entries.deleteProcess'); + flextype()->get('/api/entries', 'ApiEntriesController:index')->setName('admin.api_entries.index'); + flextype()->get('/api/entries/add', 'ApiEntriesController:add')->setName('admin.api_entries.add'); + flextype()->post('/api/entries/add', 'ApiEntriesController:addProcess')->setName('admin.api_entries.addProcess'); + flextype()->get('/api/entries/edit', 'ApiEntriesController:edit')->setName('admin.api_entries.edit'); + flextype()->post('/api/entries/edit', 'ApiEntriesController:editProcess')->setName('admin.api_entries.editProcess'); + flextype()->post('/api/entries/delete', 'ApiEntriesController:deleteProcess')->setName('admin.api_entries.deleteProcess'); - $flextype->get('/api/files', 'ApiFilesController:index')->setName('admin.api_files.index'); - $flextype->get('/api/files/add', 'ApiFilesController:add')->setName('admin.api_files.add'); - $flextype->post('/api/files/add', 'ApiFilesController:addProcess')->setName('admin.api_files.addProcess'); - $flextype->get('/api/files/edit', 'ApiFilesController:edit')->setName('admin.api_files.edit'); - $flextype->post('/api/files/edit', 'ApiFilesController:editProcess')->setName('admin.api_files.editProcess'); - $flextype->post('/api/files/delete', 'ApiFilesController:deleteProcess')->setName('admin.api_files.deleteProcess'); + flextype()->get('/api/files', 'ApiFilesController:index')->setName('admin.api_files.index'); + flextype()->get('/api/files/add', 'ApiFilesController:add')->setName('admin.api_files.add'); + flextype()->post('/api/files/add', 'ApiFilesController:addProcess')->setName('admin.api_files.addProcess'); + flextype()->get('/api/files/edit', 'ApiFilesController:edit')->setName('admin.api_files.edit'); + flextype()->post('/api/files/edit', 'ApiFilesController:editProcess')->setName('admin.api_files.editProcess'); + flextype()->post('/api/files/delete', 'ApiFilesController:deleteProcess')->setName('admin.api_files.deleteProcess'); - $flextype->get('/api/folders', 'ApiFoldersController:index')->setName('admin.api_folders.index'); - $flextype->get('/api/folders/add', 'ApiFoldersController:add')->setName('admin.api_folders.add'); - $flextype->post('/api/folders/add', 'ApiFoldersController:addProcess')->setName('admin.api_folders.addProcess'); - $flextype->get('/api/folders/edit', 'ApiFoldersController:edit')->setName('admin.api_folders.edit'); - $flextype->post('/api/folders/edit', 'ApiFoldersController:editProcess')->setName('admin.api_folders.editProcess'); - $flextype->post('/api/folders/delete', 'ApiFoldersController:deleteProcess')->setName('admin.api_folders.deleteProcess'); + flextype()->get('/api/folders', 'ApiFoldersController:index')->setName('admin.api_folders.index'); + flextype()->get('/api/folders/add', 'ApiFoldersController:add')->setName('admin.api_folders.add'); + flextype()->post('/api/folders/add', 'ApiFoldersController:addProcess')->setName('admin.api_folders.addProcess'); + flextype()->get('/api/folders/edit', 'ApiFoldersController:edit')->setName('admin.api_folders.edit'); + flextype()->post('/api/folders/edit', 'ApiFoldersController:editProcess')->setName('admin.api_folders.editProcess'); + flextype()->post('/api/folders/delete', 'ApiFoldersController:deleteProcess')->setName('admin.api_folders.deleteProcess'); - $flextype->get('/api/registry', 'ApiRegistryController:index')->setName('admin.api_registry.index'); - $flextype->get('/api/registry/add', 'ApiRegistryController:add')->setName('admin.api_registry.add'); - $flextype->post('/api/registry/add', 'ApiRegistryController:addProcess')->setName('admin.api_registry.addProcess'); - $flextype->get('/api/registry/edit', 'ApiRegistryController:edit')->setName('admin.api_registry.edit'); - $flextype->post('/api/registry/edit', 'ApiRegistryController:editProcess')->setName('admin.api_registry.editProcess'); - $flextype->post('/api/registry/delete', 'ApiRegistryController:deleteProcess')->setName('admin.api_registry.deleteProcess'); + flextype()->get('/api/registry', 'ApiRegistryController:index')->setName('admin.api_registry.index'); + flextype()->get('/api/registry/add', 'ApiRegistryController:add')->setName('admin.api_registry.add'); + flextype()->post('/api/registry/add', 'ApiRegistryController:addProcess')->setName('admin.api_registry.addProcess'); + flextype()->get('/api/registry/edit', 'ApiRegistryController:edit')->setName('admin.api_registry.edit'); + flextype()->post('/api/registry/edit', 'ApiRegistryController:editProcess')->setName('admin.api_registry.editProcess'); + flextype()->post('/api/registry/delete', 'ApiRegistryController:deleteProcess')->setName('admin.api_registry.deleteProcess'); - $flextype->get('/api/images', 'ApiImagesController:index')->setName('admin.api_images.index'); - $flextype->get('/api/images/add', 'ApiImagesController:add')->setName('admin.api_images.add'); - $flextype->post('/api/images/add', 'ApiImagesController:addProcess')->setName('admin.api_images.addProcess'); - $flextype->get('/api/images/edit', 'ApiImagesController:edit')->setName('admin.api_images.edit'); - $flextype->post('/api/images/edit', 'ApiImagesController:editProcess')->setName('admin.api_images.editProcess'); - $flextype->post('/api/images/delete', 'ApiImagesController:deleteProcess')->setName('admin.api_images.deleteProcess'); + flextype()->get('/api/images', 'ApiImagesController:index')->setName('admin.api_images.index'); + flextype()->get('/api/images/add', 'ApiImagesController:add')->setName('admin.api_images.add'); + flextype()->post('/api/images/add', 'ApiImagesController:addProcess')->setName('admin.api_images.addProcess'); + flextype()->get('/api/images/edit', 'ApiImagesController:edit')->setName('admin.api_images.edit'); + flextype()->post('/api/images/edit', 'ApiImagesController:editProcess')->setName('admin.api_images.editProcess'); + flextype()->post('/api/images/delete', 'ApiImagesController:deleteProcess')->setName('admin.api_images.deleteProcess'); - $flextype->get('/api/access', 'ApiAccessController:index')->setName('admin.api_access.index'); - $flextype->get('/api/access/add', 'ApiAccessController:add')->setName('admin.api_access.add'); - $flextype->post('/api/access/add', 'ApiAccessController:addProcess')->setName('admin.api_access.addProcess'); - $flextype->get('/api/access/edit', 'ApiAccessController:edit')->setName('admin.api_access.edit'); - $flextype->post('/api/access/edit', 'ApiAccessController:editProcess')->setName('admin.api_access.editProcess'); - $flextype->post('/api/access/delete', 'ApiAccessController:deleteProcess')->setName('admin.api_access.deleteProcess'); + flextype()->get('/api/access', 'ApiAccessController:index')->setName('admin.api_access.index'); + flextype()->get('/api/access/add', 'ApiAccessController:add')->setName('admin.api_access.add'); + flextype()->post('/api/access/add', 'ApiAccessController:addProcess')->setName('admin.api_access.addProcess'); + flextype()->get('/api/access/edit', 'ApiAccessController:edit')->setName('admin.api_access.edit'); + flextype()->post('/api/access/edit', 'ApiAccessController:editProcess')->setName('admin.api_access.editProcess'); + flextype()->post('/api/access/delete', 'ApiAccessController:deleteProcess')->setName('admin.api_access.deleteProcess'); -})->add(new AclIsUserLoggedInMiddleware($flextype, ['redirect' => 'admin.accounts.login'])) - ->add(new AclIsUserLoggedInRolesInMiddleware($flextype, ['redirect' => ($flextype->getContainer()->acl->isUserLoggedIn() ? 'admin.accounts.no-access' : 'admin.accounts.login'), +})->add(new AclIsUserLoggedInMiddleware(['redirect' => 'admin.accounts.login'])) + ->add(new AclIsUserLoggedInRolesInMiddleware(['redirect' => (flextype()->getContainer()->acl->isUserLoggedIn() ? 'admin.accounts.no-access' : 'admin.accounts.login'), 'roles' => 'admin'])) ->add('csrf');