mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-10-27 16:26:32 +01:00
Update taskGetChildTypes() to use Flex Pages (works without the plugin) [#2087]
This commit is contained in:
@@ -26,6 +26,7 @@ use Grav\Common\Security;
|
|||||||
use Grav\Common\User\Interfaces\UserCollectionInterface;
|
use Grav\Common\User\Interfaces\UserCollectionInterface;
|
||||||
use Grav\Common\User\Interfaces\UserInterface;
|
use Grav\Common\User\Interfaces\UserInterface;
|
||||||
use Grav\Common\Utils;
|
use Grav\Common\Utils;
|
||||||
|
use Grav\Framework\Flex\Flex;
|
||||||
use Grav\Framework\Psr7\Response;
|
use Grav\Framework\Psr7\Response;
|
||||||
use Grav\Framework\RequestHandler\Exception\RequestException;
|
use Grav\Framework\RequestHandler\Exception\RequestException;
|
||||||
use Grav\Plugin\Login\TwoFactorAuth\TwoFactorAuth;
|
use Grav\Plugin\Login\TwoFactorAuth\TwoFactorAuth;
|
||||||
@@ -1851,17 +1852,13 @@ class AdminController extends AdminBaseController
|
|||||||
|
|
||||||
$data = $this->post;
|
$data = $this->post;
|
||||||
|
|
||||||
$rawroute = $data['rawroute'] ?? null;
|
$route = $data['rawroute'] ?? null;
|
||||||
|
if ($route) {
|
||||||
if ($rawroute) {
|
/** @var Flex $flex */
|
||||||
$pages = $this->admin::enablePages();
|
$flex = $this->grav['flex'];
|
||||||
|
$page = $flex->getObject(trim($route, '/'), 'pages');
|
||||||
/** @var PageInterface $page */
|
if ($page instanceof PageInterface) {
|
||||||
$page = $pages->find($rawroute);
|
|
||||||
|
|
||||||
if ($page) {
|
|
||||||
$child_type = $page->childType();
|
$child_type = $page->childType();
|
||||||
|
|
||||||
if ($child_type !== '') {
|
if ($child_type !== '') {
|
||||||
$this->admin->json_response = [
|
$this->admin->json_response = [
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
@@ -1875,7 +1872,6 @@ class AdminController extends AdminBaseController
|
|||||||
$this->admin->json_response = [
|
$this->admin->json_response = [
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'child_type' => '',
|
'child_type' => '',
|
||||||
// 'message' => $this->admin::translate('PLUGIN_ADMIN.NO_CHILD_TYPE')
|
|
||||||
];
|
];
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user