Skip to content

Commit 5b45d02

Browse files
committed
Merge branch 'sw-26913/improve-backend-routing' into 'v5.7.15'
SW-26913 - improve backend See merge request shopware/5/product/shopware!912
2 parents cc87efc + de92d3a commit 5b45d02

File tree

3 files changed

+67
-31
lines changed

3 files changed

+67
-31
lines changed

.phpstan-baseline.neon

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -39225,11 +39225,6 @@ parameters:
3922539225
count: 1
3922639226
path: engine/Shopware/Models/Widget/Widget.php
3922739227

39228-
-
39229-
message: "#^Call to an undefined method Enlight_Event_EventArgs\\:\\:getSubject\\(\\)\\.$#"
39230-
count: 1
39231-
path: engine/Shopware/Plugins/Default/Backend/Auth/Bootstrap.php
39232-
3923339228
-
3923439229
message: "#^Call to an undefined method Enlight_Template_Default\\:\\:setCompileId\\(\\)\\.$#"
3923539230
count: 1
@@ -39245,36 +39240,11 @@ parameters:
3924539240
count: 1
3924639241
path: engine/Shopware/Plugins/Default/Backend/Auth/Bootstrap.php
3924739242

39248-
-
39249-
message: "#^Method Shopware_Plugins_Backend_Auth_Bootstrap\\:\\:initLocale\\(\\) has no return type specified\\.$#"
39250-
count: 1
39251-
path: engine/Shopware/Plugins/Default/Backend/Auth/Bootstrap.php
39252-
3925339243
-
3925439244
message: "#^Method Shopware_Plugins_Backend_Auth_Bootstrap\\:\\:isAllowed\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#"
3925539245
count: 1
3925639246
path: engine/Shopware/Plugins/Default/Backend/Auth/Bootstrap.php
3925739247

39258-
-
39259-
message: "#^Method Shopware_Plugins_Backend_Auth_Bootstrap\\:\\:onPreDispatchBackend\\(\\) has no return type specified\\.$#"
39260-
count: 1
39261-
path: engine/Shopware/Plugins/Default/Backend/Auth/Bootstrap.php
39262-
39263-
-
39264-
message: "#^Method Shopware_Plugins_Backend_Auth_Bootstrap\\:\\:registerAclPlugin\\(\\) has no return type specified\\.$#"
39265-
count: 1
39266-
path: engine/Shopware/Plugins/Default/Backend/Auth/Bootstrap.php
39267-
39268-
-
39269-
message: "#^Method Shopware_Plugins_Backend_Auth_Bootstrap\\:\\:setNoAcl\\(\\) has no return type specified\\.$#"
39270-
count: 1
39271-
path: engine/Shopware/Plugins/Default/Backend/Auth/Bootstrap.php
39272-
39273-
-
39274-
message: "#^Method Shopware_Plugins_Backend_Auth_Bootstrap\\:\\:setNoAuth\\(\\) has no return type specified\\.$#"
39275-
count: 1
39276-
path: engine/Shopware/Plugins/Default/Backend/Auth/Bootstrap.php
39277-
3927839248
-
3927939249
message: "#^Method Shopware_Plugins_Backend_SwagUpdate_Bootstrap\\:\\:afterInit\\(\\) has no return type specified\\.$#"
3928039250
count: 1

engine/Shopware/Plugins/Default/Backend/Auth/Bootstrap.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ public function isAllowed($params)
149149
* Set local no auth property
150150
*
151151
* @param bool $flag
152+
*
153+
* @return void
152154
*/
153155
public function setNoAuth($flag = true)
154156
{
@@ -159,6 +161,8 @@ public function setNoAuth($flag = true)
159161
* Set local no acl property
160162
*
161163
* @param bool $flag
164+
*
165+
* @return void
162166
*/
163167
public function setNoAcl($flag = true)
164168
{
@@ -188,13 +192,17 @@ public function shouldUseAcl()
188192
/**
189193
* This pre-dispatch event-hook checks backend permissions
190194
*
195+
* @param Enlight_Controller_ActionEventArgs $args
196+
*
191197
* @throws Enlight_Controller_Exception
198+
*
199+
* @return void
192200
*/
193201
public function onPreDispatchBackend(Enlight_Event_EventArgs $args)
194202
{
195203
$this->action = $args->getSubject();
196204
$this->request = $this->action->Request();
197-
$this->aclResource = strtolower($this->request->getControllerName());
205+
$this->aclResource = strtolower(str_replace('_', '', $this->request->getControllerName()));
198206

199207
if ($this->aclResource === 'error' || $this->request->getModuleName() !== 'backend') {
200208
return;
@@ -264,6 +272,8 @@ public function checkAuth()
264272
*
265273
* @throws Exception
266274
* @throws SmartyException
275+
*
276+
* @return void
267277
*/
268278
public function registerAclPlugin($auth)
269279
{
@@ -436,6 +446,8 @@ public function getCapabilities()
436446
* Init backend locales
437447
*
438448
* @throws Exception
449+
*
450+
* @return void
439451
*/
440452
protected function initLocale()
441453
{
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
/**
3+
* Shopware 5
4+
* Copyright (c) shopware AG
5+
*
6+
* According to our dual licensing model, this program can be used either
7+
* under the terms of the GNU Affero General Public License, version 3,
8+
* or under a proprietary license.
9+
*
10+
* The texts of the GNU Affero General Public License with an additional
11+
* permission and of our proprietary license can be found at and
12+
* in the LICENSE file you have received along with this program.
13+
*
14+
* This program is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
* GNU Affero General Public License for more details.
18+
*
19+
* "Shopware" is a registered trademark of shopware AG.
20+
* The licensing of the program under the AGPLv3 does not imply a
21+
* trademark license. Therefore any rights, title and interest in
22+
* our trademarks remain entirely with us.
23+
*/
24+
25+
namespace Shopware\Tests\Unit\Plugins\Backend\Auth;
26+
27+
use Enlight_Controller_Action;
28+
use Enlight_Controller_ActionEventArgs;
29+
use Enlight_Controller_Request_RequestTestCase;
30+
use PHPUnit\Framework\TestCase;
31+
use Shopware\Tests\Functional\Helper\Utils;
32+
use Shopware_Plugins_Backend_Auth_Bootstrap;
33+
34+
class BootstrapTest extends TestCase
35+
{
36+
public function testValidatesAlsoSnakeCaseControllers(): void
37+
{
38+
/** @var Shopware_Plugins_Backend_Auth_Bootstrap $authPlugin */
39+
$authPlugin = $this->createPartialMock(Shopware_Plugins_Backend_Auth_Bootstrap::class, ['initLocale', 'checkAuth']);
40+
$authPlugin->setNoAcl(true);
41+
42+
$action = $this->getMockBuilder(Enlight_Controller_Action::class)->disableOriginalConstructor()->getMock();
43+
$testRequest = new Enlight_Controller_Request_RequestTestCase();
44+
$testRequest->setControllerName('user_manager');
45+
$testRequest->setModuleName('Backend');
46+
$action->method('Request')->willReturn($testRequest);
47+
$eventArgs = new Enlight_Controller_ActionEventArgs();
48+
$eventArgs->set('subject', $action);
49+
50+
$authPlugin->onPreDispatchBackend($eventArgs);
51+
52+
static::assertEquals('usermanager', Utils::hijackAndReadProperty($authPlugin, 'aclResource'));
53+
}
54+
}

0 commit comments

Comments
 (0)