-
Notifications
You must be signed in to change notification settings - Fork 571
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #737 from cakephp/port-734
DebugKitController beforeFilter check if debug is enabled
- Loading branch information
Showing
12 changed files
with
174 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
/** | ||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org) | ||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||
* | ||
* Licensed under The MIT License | ||
* Redistributions of files must retain the above copyright notice. | ||
* | ||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||
* @link http://cakephp.org CakePHP(tm) Project | ||
* @license http://www.opensource.org/licenses/mit-license.php MIT License | ||
*/ | ||
namespace DebugKit\Controller; | ||
|
||
use Cake\Controller\Controller; | ||
use Cake\Core\Configure; | ||
use Cake\Event\EventInterface; | ||
use Cake\Http\Exception\NotFoundException; | ||
use Cake\Log\Log; | ||
|
||
/** | ||
* DebugKit Controller. | ||
*/ | ||
class DebugKitController extends Controller | ||
{ | ||
/** | ||
* Before filter handler. | ||
* | ||
* @param \Cake\Event\EventInterface $event The event. | ||
* @return void | ||
* @throws \Cake\Http\Exception\NotFoundException | ||
*/ | ||
public function beforeFilter(EventInterface $event) | ||
{ | ||
if (!Configure::read('debug')) { | ||
throw new NotFoundException('Not available without debug mode on.'); | ||
} | ||
|
||
// If CakePHP Authorization\Authorization plugin is enabled, | ||
// ignore it, only if `DebugKit.ignoreAuthorization` is set to true | ||
$authorizationService = $this->getRequest()->getAttribute('authorization'); | ||
if ($authorizationService instanceof \Authorization\AuthorizationService) { | ||
if (Configure::read('DebugKit.ignoreAuthorization')) { | ||
$authorizationService->skipAuthorization(); | ||
} else { | ||
Log::info( | ||
"Cake Authorization plugin is enabled. If you would like " . | ||
"to force DebugKit to ignore it, set `DebugKit.ignoreAuthorization` " . | ||
" Configure option to true." | ||
); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.