Skip to content

Commit

Permalink
Backporting page controller tweaks
Browse files Browse the repository at this point in the history
Former-commit-id: 9a89f1f
Former-commit-id: fd2c4d65ff0eb5bf27404a8f39ad3b0fdc8f8f7a
  • Loading branch information
aembler committed Dec 7, 2016
1 parent 35498f0 commit 79a99c5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
4 changes: 4 additions & 0 deletions web/concrete/src/Page/Controller/DashboardPageController.php
Expand Up @@ -11,6 +11,10 @@ class DashboardPageController extends PageController
/** @var Error */
protected $error;

protected $restrictedMethods = array(
'enableNativeMobile'
);

/** @var Token */
public $token;
protected $helpers = array('form');
Expand Down
21 changes: 20 additions & 1 deletion web/concrete/src/Page/Controller/PageController.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}
Expand Down

0 comments on commit 79a99c5

Please sign in to comment.