Skip to content

Commit

Permalink
Upgrade: Fix usage of $this->request to $this->getRequest()
Browse files Browse the repository at this point in the history
  • Loading branch information
rchavik committed Sep 17, 2020
1 parent f4676e6 commit b35986a
Show file tree
Hide file tree
Showing 16 changed files with 42 additions and 35 deletions.
5 changes: 3 additions & 2 deletions Acl/src/Controller/Component/AccessComponent.php
Expand Up @@ -61,8 +61,9 @@ protected function _setupRole()
Croogo::hookAdminTab('Admin/Roles/edit', $title, $element);

$id = null;
if (!empty($this->_controller->request->getParam('pass')[0])) {
$id = $this->_controller->request->getParam('pass')[0];
$request = $this->_controller->getRequest();
if (!empty($request->getParam('pass')[0])) {
$id = $request->getParam('pass')[0];
}
$this->_controller->set('parents', $this->_controller->Roles->allowedParents($id));
}
Expand Down
2 changes: 1 addition & 1 deletion Acl/src/Controller/Component/AutoLoginComponent.php
Expand Up @@ -101,7 +101,7 @@ protected function _cookie($request)
*/
public function onAdminLoginSuccessful(EventInterface $event)
{
$request = $event->getSubject()->request;
$request = $event->getSubject()->getRequest();
$remember = $request->getData('remember');
$expires = Configure::read('Access Control.autoLoginDuration');
if (strtotime($expires) === false) {
Expand Down
16 changes: 8 additions & 8 deletions Acl/src/Controller/Component/FilterComponent.php
Expand Up @@ -97,7 +97,7 @@ protected function _configure()
if (!function_exists('mcrypt_encrypt') && !function_exists('openssl_encrypt')) {
$notice = __d('croogo', '"AutoLogin" (Remember Me) disabled since mcrypt_encrypt or openssl_encrypt is not available');
$this->log($notice, LOG_CRIT);
if ($this->_controller->request->getParam('prefix') == 'admin') {
if ($this->_controller->getRequest()->getParam('prefix') == 'admin') {
$this->_controller->Flash->error($notice);
}
if (isset($this->_controller->Settings)) {
Expand Down Expand Up @@ -125,7 +125,7 @@ protected function _configure()
]
]);

if ($this->_controller->request->getParam('prefix') == 'admin' &&
if ($this->_controller->getRequest()->getParam('prefix') == 'admin' &&
!$this->_controller->Auth->user()) {
$this->_controller->Auth->setConfig('authError', false);
}
Expand All @@ -146,7 +146,7 @@ public function configureLoginActions()
'controller' => 'Users',
'action' => 'login',
]);
if ($this->request->getParam('prefix') === 'admin') {
if ($this->_controller->getRequest()->getParam('prefix') === 'admin') {
$this->_controller->Auth->setConfig('loginAction', [
'prefix' => 'admin',
'plugin' => 'Croogo/Users',
Expand All @@ -159,7 +159,7 @@ public function configureLoginActions()
'controller' => 'Users',
'action' => 'login',
]);
if ($this->request->getParam('prefix') == 'admin') {
if ($this->_controller->getRequest()->getParam('prefix') == 'admin') {
$dashboardUrl = Configure::read('Site.dashboard_url');
if (is_string($dashboardUrl)) {
$converter = new StringConverter();
Expand All @@ -172,7 +172,7 @@ public function configureLoginActions()
$this->_controller->Auth->setConfig('loginRedirect', $loginRedirect);
}

if ($this->_controller->request->is('ajax')) {
if ($this->_controller->getRequest()->is('ajax')) {
$this->_controller->Auth->setConfig('unauthorizedRedirect', false);
} else {
$this->_controller->Auth->setConfig('unauthorizedRedirect', [
Expand All @@ -184,7 +184,7 @@ public function configureLoginActions()

$config = Configure::read('Acl');
if (!empty($config['Auth']) && is_array($config['Auth'])) {
$isAdminRequest = !empty($this->_controller->request->getParam('admin'));
$isAdminRequest = !empty($this->_controller->getRequest()->getParam('admin'));
$authActions = [
'loginAction',
'loginRedirect',
Expand Down Expand Up @@ -219,9 +219,9 @@ public function auth()

$authorizer = $this->_controller->Auth->getAuthorize('Croogo/Acl.AclCached');

if ($this->_controller->Acl->check('Role-public', $authorizer->action($this->_controller->request))) {
if ($this->_controller->Acl->check('Role-public', $authorizer->action($this->_controller->getRequest()))) {
$this->_controller->Auth->allow(
$this->_controller->request->getParam('action')
$this->_controller->getRequest()->getParam('action')
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion Blocks/src/Controller/Component/BlocksComponent.php
Expand Up @@ -103,7 +103,7 @@ public function blocks()
$alias = $this->Blocks->getAlias();
$roleId = $this->controller->Croogo->roleId();
$status = $this->Blocks->status();
$request = $this->controller->request;
$request = $this->controller->getRequest();
$slug = Text::slug(strtolower($request->getPath()));
$Filter = new VisibilityFilter($request);
foreach ($regions as $regionId => $regionAlias) {
Expand Down
5 changes: 4 additions & 1 deletion Contacts/src/Controller/Admin/MessagesController.php
Expand Up @@ -13,6 +13,9 @@
* @author Fahad Ibnay Heylaal <contact@fahad19.com>
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
* @link http://www.croogo.org
*
* @property \Croogo\Core\Controller\Component\BulkProcessComponent $BulkProcess
* @property \Croogo\Contacts\Model\Table\MessagesTable $Messages
*/
class MessagesController extends AppController
{
Expand Down Expand Up @@ -40,7 +43,7 @@ public function initialize(): void
public function process()
{
$Messages = $this->Messages;
list($action, $ids) = $this->BulkProcess->getRequestVars($Messages->alias());
list($action, $ids) = $this->BulkProcess->getRequestVars($Messages->aliasField($Messages->getPrimaryKey()));

$messageMap = [
'delete' => __d('croogo', 'Messages deleted'),
Expand Down
8 changes: 4 additions & 4 deletions Core/src/Controller/Component/AkismetComponent.php
Expand Up @@ -109,13 +109,13 @@ public function startup(Event $event)

// Start to populate the comment data
$this->comment['blog'] = $this->blogURL;
$this->comment['user_agent'] = $this->request->header('user-agent') ?: 'Unknown';
$this->comment['user_agent'] = $this->getController()->getRequest()->getHeader('user-agent') ?: 'Unknown';

if ($this->request->referer()) {
$this->comment['referrer'] = $this->request->referer();
if ($this->getController()->getRequest()->referer()) {
$this->comment['referrer'] = $this->getController()->getRequest()->referer();
}

$this->comment['user_ip'] = $this->request->clientIp();
$this->comment['user_ip'] = $this->getController()->getRequest()->clientIp();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Core/src/Controller/Component/BulkProcessComponent.php
Expand Up @@ -40,7 +40,7 @@ class BulkProcessComponent extends Component
public function beforeFilter(Event $event)
{
$this->_controller = $event->getSubject();
if ($this->_controller->request->getParam('action') == 'process') {
if ($this->_controller->getRequest()->getParam('action') == 'process') {
$this->_controller->Security->setConfig('validatePost', false);
}
}
Expand Down
15 changes: 8 additions & 7 deletions Core/src/Controller/Component/CroogoComponent.php
Expand Up @@ -81,8 +81,9 @@ public function startup(Event $event)
{
$this->_controller = $event->getSubject();

if ($this->_controller->request->getParam('prefix') == 'admin') {
if (!$this->_controller->request->getParam('requested')) {
$request = $this->_controller->getRequest();
if ($request->getParam('prefix') == 'Admin') {
if (!$request->getParam('requested')) {
$this->_adminData();
}
}
Expand Down Expand Up @@ -115,7 +116,7 @@ protected function _adminMenus()
],
]);

$user = $this->getController()->request->getSession()->read('Auth.User');
$user = $this->_controller->getRequest()->getSession()->read('Auth.User');
if (empty($user)) {
return;
}
Expand Down Expand Up @@ -161,7 +162,7 @@ protected function _adminMenus()
*/
public function roleId()
{
$roleId = $this->_controller->request->getSession()->read('Auth.User.role_id');
$roleId = $this->_controller->getRequest()->getSession()->read('Auth.User.role_id');
if ($roleId) {
return $roleId;
}
Expand Down Expand Up @@ -285,7 +286,7 @@ public function viewFallback($templates)
foreach ($templatePaths as $templatePath) {
$templatePath = $templatePath . $this->_viewPath() . DS . $template;
if (file_exists($templatePath . '.ctp')) {
$controller->viewBuilder()->template($this->_viewPath() . DS . $template);
$controller->viewBuilder()->setTemplate($this->_viewPath() . DS . $template);

return;
}
Expand All @@ -296,10 +297,10 @@ public function viewFallback($templates)
protected function _viewPath()
{
$viewPath = $this->_controller->getName();
if (!empty($this->request->getParam('prefix'))) {
if (!empty($this->_controller->getRequest()->getParam('prefix'))) {
$prefixes = array_map(
'Cake\Utility\Inflector::camelize',
explode('/', $this->_controller->request->params['prefix'])
explode('/', $this->_controller->getRequest()->getParam('prefix'))
);
$viewPath = implode(DS, $prefixes) . DS . $viewPath;
}
Expand Down
2 changes: 1 addition & 1 deletion Core/src/Controller/Component/RecaptchaComponent.php
Expand Up @@ -48,7 +48,7 @@ public function initialize(array $config): void
return;
}

if (in_array($this->request->getParam('action'), $this->getConfig('actions'))) {
if (in_array($controller->getRequest()->getParam('action'), $this->getConfig('actions'))) {
$controller->Security->validatePost = false;
}

Expand Down
2 changes: 1 addition & 1 deletion Core/src/Controller/Component/ThemeComponent.php
Expand Up @@ -48,7 +48,7 @@ public function beforeFilter(Event $event)
*/
public function loadThemeSettings($theme)
{
$prefix = $this->request->getParam('prefix');
$prefix = $this->_controller->getRequest()->getParam('prefix');
$croogoTheme = new CroogoTheme();
$settings = $croogoTheme->getData($theme)['settings'];

Expand Down
2 changes: 1 addition & 1 deletion Core/src/Listener/ChooserListener.php
Expand Up @@ -9,7 +9,7 @@ class ChooserListener extends BaseListener
{
public function beforeFilter(Event $event)
{
if (!$this->_controller()->request->getQuery('chooser')) {
if (!$this->_controller()->getRequest()->getQuery('chooser')) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion Core/templates/element/admin/navigation.php
Expand Up @@ -4,7 +4,7 @@
use Cake\Cache\Cache;
use Croogo\Core\Nav;

$cacheKey = 'adminnav_' . $this->Layout->getRoleId() . '_' . $this->getRequest()->getPath() . '_' . md5(serialize($this->getRequest()->getQuery()));
$cacheKey = 'adminnav_' . $this->Layout->getRoleId() . '_' . str_replace('/', '-', $this->getRequest()->getPath()) . '_' . md5(serialize($this->getRequest()->getQuery()));
echo Cache::remember($cacheKey, function () {
return $this->Croogo->adminMenus(Nav::items(), [
'htmlAttributes' => [
Expand Down
2 changes: 1 addition & 1 deletion Extensions/src/Event/HookableComponentEventHandler.php
Expand Up @@ -95,7 +95,7 @@ public function loadComponent($name, array $config = [])
*/
private function _getComponents(Controller $controller)
{
$properties = Croogo::options('Hook.controller_properties', $controller->request);
$properties = Croogo::options('Hook.controller_properties', $controller->getRequest());

$components = [];
foreach ($properties['_appComponents'] as $component => $config) {
Expand Down
3 changes: 2 additions & 1 deletion Menus/src/Controller/Component/MenuComponent.php
Expand Up @@ -53,7 +53,8 @@ public function startup(Event $event)
}

$controller = $event->getSubject();
if (($controller->request->getParam('prefix') !== 'admin') && !$controller->request->getParam('requested')) {
$request = $controller->getRequest();
if (($request->getParam('prefix') !== 'Admin') && !$request->getParam('requested')) {
$this->menus();
} else {
$this->_adminData();
Expand Down
7 changes: 4 additions & 3 deletions Meta/src/Controller/Component/MetaComponent.php
Expand Up @@ -20,14 +20,15 @@ class MetaComponent extends Component
public function startup()
{
$controller = $this->_registry->getController();
if ($controller->request->getParam('prefix') === 'admin') {
$request = $controller->getRequest();
if ($request->getParam('prefix') === 'Admin') {
$this->_adminTabs();

if (empty($controller->request->getData('meta'))) {
if (empty($request->getData('meta'))) {
return;
}
$unlockedFields = [];
foreach ($controller->request->getData('meta') as $uuid => $fields) {
foreach ($request->getData('meta') as $uuid => $fields) {
foreach ($fields as $field => $vals) {
$unlockedFields[] = 'meta.' . $uuid . '.' . $field;
}
Expand Down
2 changes: 1 addition & 1 deletion Taxonomy/src/Controller/Component/TaxonomyComponent.php
Expand Up @@ -251,7 +251,7 @@ public function getDefaultType($vocabulary)
if (isset($vocabulary->types[0])) {
$defaultType = $vocabulary->types[0];
}
$typeId = $this->request->getQuery('type_id');
$typeId = $this->getController()->getRequest()->getQuery('type_id');
if ($typeId) {
$defaultType = collection($vocabulary['types'])->match([
'id' => $typeId,
Expand Down

0 comments on commit b35986a

Please sign in to comment.