Update taskGetChildTypes() to use Flex Pages (works without the plugin) [#2087]

This commit is contained in:
Matias Griese
2021-06-10 11:10:06 +03:00
parent 1e2fb67ba3
commit f42e996138

View File

@@ -26,6 +26,7 @@ use Grav\Common\Security;
use Grav\Common\User\Interfaces\UserCollectionInterface;
use Grav\Common\User\Interfaces\UserInterface;
use Grav\Common\Utils;
use Grav\Framework\Flex\Flex;
use Grav\Framework\Psr7\Response;
use Grav\Framework\RequestHandler\Exception\RequestException;
use Grav\Plugin\Login\TwoFactorAuth\TwoFactorAuth;
@@ -1851,17 +1852,13 @@ class AdminController extends AdminBaseController
$data = $this->post;
$rawroute = $data['rawroute'] ?? null;
if ($rawroute) {
$pages = $this->admin::enablePages();
/** @var PageInterface $page */
$page = $pages->find($rawroute);
if ($page) {
$route = $data['rawroute'] ?? null;
if ($route) {
/** @var Flex $flex */
$flex = $this->grav['flex'];
$page = $flex->getObject(trim($route, '/'), 'pages');
if ($page instanceof PageInterface) {
$child_type = $page->childType();
if ($child_type !== '') {
$this->admin->json_response = [
'status' => 'success',
@@ -1875,7 +1872,6 @@ class AdminController extends AdminBaseController
$this->admin->json_response = [
'status' => 'success',
'child_type' => '',
// 'message' => $this->admin::translate('PLUGIN_ADMIN.NO_CHILD_TYPE')
];
return true;