From 79a99c5ec991a4c309835235b8eb7c21d8ae9d54 Mon Sep 17 00:00:00 2001 From: Andrew Embler Date: Wed, 7 Dec 2016 09:32:00 -0800 Subject: [PATCH] Backporting page controller tweaks Former-commit-id: 9a89f1fbf5120567d237598fded04711c5ac5538 Former-commit-id: fd2c4d65ff0eb5bf27404a8f39ad3b0fdc8f8f7a --- .../Controller/DashboardPageController.php | 4 ++++ .../src/Page/Controller/PageController.php | 21 ++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/web/concrete/src/Page/Controller/DashboardPageController.php b/web/concrete/src/Page/Controller/DashboardPageController.php index 829078ae55f..d181f615d4e 100644 --- a/web/concrete/src/Page/Controller/DashboardPageController.php +++ b/web/concrete/src/Page/Controller/DashboardPageController.php @@ -11,6 +11,10 @@ class DashboardPageController extends PageController /** @var Error */ protected $error; + protected $restrictedMethods = array( + 'enableNativeMobile' + ); + /** @var Token */ public $token; protected $helpers = array('form'); diff --git a/web/concrete/src/Page/Controller/PageController.php b/web/concrete/src/Page/Controller/PageController.php index 9f0d5257f55..6cf1a03cc1a 100644 --- a/web/concrete/src/Page/Controller/PageController.php +++ b/web/concrete/src/Page/Controller/PageController.php @@ -20,6 +20,12 @@ class PageController extends Controller protected $passThruBlocks = array(); protected $parameters = array(); + /** + * array of method names that can't be called through the url + * @var array + */ + protected $restrictedMethods = array(); + public function supportsPageCache() { return $this->supportsPageCache; @@ -166,11 +172,24 @@ public function setupRequestActionAndParameters(Request $request) } $foundTask = false; + $restrictedControllers = array( + 'Concrete\Core\Controller\Controller', + 'Concrete\Core\Controller\AbstractController', + 'Concrete\Core\Page\Controller\PageController' + + ); try { $r = new \ReflectionMethod(get_class($this), $method); $cl = $r->getDeclaringClass(); if (is_object($cl)) { - if ($cl->getName() != 'Concrete\Core\Controller\Controller' && strpos($method, 'on_') !== 0 && strpos($method, '__') !== 0 && $r->isPublic()) { + if ( + !in_array($cl->getName(), $restrictedControllers) + && strpos($method, 'on_') !== 0 + && strpos($method, '__') !== 0 + && $r->isPublic() + && !$r->isConstructor() + && (is_array($this->restrictedMethods) && !in_array($method, $this->restrictedMethods)) + ) { $foundTask = true; } }