Skip to content

Commit 797e483

Browse files
authored
Adapt admin bundle refactoring (#454)
* Adapt admin bundle refactorings - related to pimcore/pimcore#14971 * Apply php-cs-fixer changes * remove unavailable config * add conflict * [Action] register admin bundle * add conflict for admin bundle beta * add beta conflict for other dependencies --------- Co-authored-by: dvesh3 <[email protected]>
1 parent ca2791e commit 797e483

30 files changed

+257
-420
lines changed

.github/ci/files/config/bundles.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
return [
44
Pimcore\Bundle\EcommerceFrameworkBundle\PimcoreEcommerceFrameworkBundle::class => ['all' => false],
55
CustomerManagementFrameworkBundle\PimcoreCustomerManagementFrameworkBundle::class => ['all' => true],
6+
Pimcore\Bundle\AdminBundle\PimcoreAdminBundle::class => ['all' => true],
67
];

.github/ci/files/config/packages/security.yaml

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,47 +3,21 @@ security:
33

44
providers:
55
pimcore_admin:
6-
id: Pimcore\Bundle\AdminBundle\Security\User\UserProvider
6+
id: Pimcore\Security\User\UserProvider
77

88
firewalls:
99
dev:
1010
pattern: ^/(_(profiler|wdt)|css|images|js)/
1111
security: false
1212

1313
# Pimcore WebDAV HTTP basic // DO NOT CHANGE!
14-
pimcore_admin_webdav:
15-
pattern: ^/admin/asset/webdav
14+
pimcore_webdav:
15+
pattern: ^/asset/webdav
1616
provider: pimcore_admin
1717
http_basic: ~
1818

19-
# Pimcore admin form login // DO NOT CHANGE!
20-
pimcore_admin:
21-
pattern: ^/admin(/.*)?$
22-
user_checker: Pimcore\Bundle\AdminBundle\Security\User\UserChecker
23-
provider: pimcore_admin
24-
login_throttling:
25-
max_attempts: 3
26-
interval: '5 minutes'
27-
logout:
28-
path: pimcore_admin_logout
29-
target: pimcore_admin_login
30-
form_login:
31-
default_target_path: pimcore_admin_index
32-
always_use_default_target_path: true
33-
login_path: pimcore_admin_login
34-
check_path: pimcore_admin_login_check
35-
username_parameter: username
36-
password_parameter: password
37-
custom_authenticators:
38-
- Pimcore\Bundle\AdminBundle\Security\Authenticator\AdminTokenAuthenticator
39-
two_factor:
40-
auth_form_path: /admin/login/2fa # Path or route name of the two-factor form
41-
check_path: /admin/login/2fa-verify # Path or route name of the two-factor code check
42-
default_target_path: /admin # Where to redirect by default after successful authentication
43-
always_use_default_target_path: false # If it should always redirect to default_target_path
44-
auth_code_parameter_name: _auth_code # Name of the parameter for the two-factor authentication code
45-
trusted_parameter_name: _trusted # Name of the parameter for the trusted device option
46-
multi_factor: false # If ALL active two-factor methods need to be fulfilled (multi-factor authentication)
19+
# Pimcore Admin Bundle firewall
20+
pimcore_admin: '%pimcore_admin_bundle.firewall_settings%'
4721

4822
access_control:
4923
# Pimcore admin ACl // DO NOT CHANGE!
@@ -54,6 +28,7 @@ security:
5428
- { path: ^/admin/login$, roles: PUBLIC_ACCESS }
5529
- { path: ^/admin/login/(login|lostpassword|deeplink|csrf-token)$, roles: PUBLIC_ACCESS }
5630
- { path: ^/admin, roles: ROLE_PIMCORE_USER }
31+
- { path: ^/asset/webdav, roles: ROLE_PIMCORE_USER }
5732

5833
role_hierarchy:
5934
# Pimcore admin // DO NOT CHANGE!

.github/ci/files/config/system.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ pimcore:
2929
steps: 10
3030
icc_rgb_profile: ''
3131
icc_cmyk_profile: ''
32-
hide_edit_image: false
33-
disable_tree_preview: false
3432
full_page_cache:
3533
enabled: false
3634
lifetime: null

composer.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"pimcore/admin-ui-classic-bundle": "^1.0",
3030
"pimcore/object-merger": "^4.0",
3131
"pimcore/pimcore": "^11.0",
32+
"pimcore/admin-ui-classic-bundle": "^1.0",
3233
"pimcore/search-query-parser": "^1.3",
3334
"pimcore/personalization-bundle": "^1.0",
3435
"symfony/asset": "^6.2",
@@ -45,6 +46,12 @@
4546
"symfony/security-http": "^6.2",
4647
"symfony/stopwatch": "^6.2"
4748
},
49+
"conflict": {
50+
"pimcore/pimcore": "v11.0.0-ALPHA1 || v11.0.0-ALPHA2 || v11.0.0-ALPHA3 || v11.0.0-ALPHA4 || v11.0.0-ALPHA5 || v11.0.0-ALPHA6 || v11.0.0-ALPHA7 || v11.0.0-ALPHA8 || v11.0.0-BETA1",
51+
"pimcore/admin-ui-classic-bundle": "v1.0.0-BETA1",
52+
"pimcore/personalization-bundle": "v1.0.0-BETA1",
53+
"pimcore/newsletter-bundle": "v1.0.0-BETA1"
54+
},
4855
"require-dev": {
4956
"phpunit/phpunit": "^9.5",
5057
"codeception/codeception": "^5.0.3",

src/Controller/Admin.php

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,16 @@
1818
use CustomerManagementFrameworkBundle\Helper\JsConfigService;
1919
use Knp\Component\Pager\Pagination\PaginationInterface;
2020
use Knp\Component\Pager\PaginatorInterface;
21-
use Pimcore\Bundle\AdminBundle\Controller\AdminController;
2221
use Pimcore\Controller\KernelControllerEventInterface;
22+
use Pimcore\Controller\Traits\JsonHelperTrait;
23+
use Pimcore\Controller\UserAwareController;
2324
use Symfony\Component\HttpFoundation\Request;
2425
use Symfony\Component\HttpKernel\Event\ControllerEvent;
2526

26-
class Admin extends AdminController implements KernelControllerEventInterface
27+
class Admin extends UserAwareController implements KernelControllerEventInterface
2728
{
29+
use JsonHelperTrait;
30+
2831
/**
2932
* @var JsConfigService
3033
*/
@@ -70,7 +73,7 @@ protected function initJsConfig()
7073
/**
7174
* @return JsConfigService
7275
*/
73-
protected function getJsConfigService()
76+
protected function getJsConfigService(): JsConfigService
7477
{
7578
return $this->jsConfigService;
7679
}
@@ -80,7 +83,7 @@ protected function getJsConfigService()
8083
*
8184
* @return array
8285
*/
83-
protected function getJsConfigFeatures()
86+
protected function getJsConfigFeatures(): array
8487
{
8588
return [
8689
'_init',
@@ -101,23 +104,16 @@ protected function getJsConfigFeatures()
101104

102105
/**
103106
* Build object paginator for filtered list
104-
*
105-
* @param Request $request
106-
* @param mixed $data
107-
* @param int $defaultPageSize
108-
*
109-
* @return PaginationInterface
110107
*/
111-
protected function buildPaginator(Request $request, $data, $defaultPageSize = null)
108+
protected function buildPaginator(Request $request, mixed $data, int $defaultPageSize = null): PaginationInterface
112109
{
113110
if (is_null($defaultPageSize)) {
114111
$defaultPageSize = $this->defaultPageSize;
115112
}
116113

117114
$page = (int)$request->get('page', 1);
118115
$pageSize = (int)$request->get('perPage', $defaultPageSize);
119-
$paginator = $this->paginator->paginate($data, $page, $pageSize);
120116

121-
return $paginator;
117+
return $this->paginator->paginate($data, $page, $pageSize);
122118
}
123119
}

src/Controller/Admin/ActivitiesController.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,16 @@
1919
use CustomerManagementFrameworkBundle\CustomerProvider\CustomerProviderInterface;
2020
use Knp\Component\Pager\PaginatorInterface;
2121
use Pimcore\Controller\KernelControllerEventInterface;
22+
use Pimcore\Controller\UserAwareController;
2223
use Symfony\Component\HttpFoundation\Request;
24+
use Symfony\Component\HttpFoundation\Response;
2325
use Symfony\Component\HttpKernel\Event\ControllerEvent;
2426
use Symfony\Component\Routing\Annotation\Route;
2527

2628
/**
2729
* @Route("/activities")
2830
*/
29-
class ActivitiesController extends \Pimcore\Bundle\AdminBundle\Controller\AdminController implements KernelControllerEventInterface
31+
class ActivitiesController extends UserAwareController implements KernelControllerEventInterface
3032
{
3133
/**
3234
* @var PaginatorInterface
@@ -44,10 +46,9 @@ public function onKernelControllerEvent(ControllerEvent $event): void
4446
}
4547

4648
/**
47-
* @param Request $request
4849
* @Route("/list")
4950
*/
50-
public function listAction(Request $request, CustomerProviderInterface $customerProvider)
51+
public function listAction(Request $request, CustomerProviderInterface $customerProvider): Response
5152
{
5253
if ($customer = $customerProvider->getById($request->get('customerId'))) {
5354
$list = \Pimcore::getContainer()->get('cmf.activity_store')->getActivityList();
@@ -88,10 +89,9 @@ public function listAction(Request $request, CustomerProviderInterface $customer
8889
}
8990

9091
/**
91-
* @param Request $request
9292
* @Route("/detail")
9393
*/
94-
public function detailAction(Request $request)
94+
public function detailAction(Request $request): Response
9595
{
9696
$activity = \Pimcore::getContainer()->get('cmf.activity_store')->getEntryById($request->get('activityId'));
9797

0 commit comments

Comments
 (0)