Skip to content

Commit

Permalink
Pimcore 11 Support
Browse files Browse the repository at this point in the history
  • Loading branch information
solverat committed Sep 22, 2023
1 parent 49d0f78 commit ccd7e53
Show file tree
Hide file tree
Showing 305 changed files with 435 additions and 896 deletions.
1 change: 0 additions & 1 deletion .actrc

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ services:
arguments:
$bundle: "@=service('kernel').getBundle('MembersBundle')"
calls:
- [setTokenStorageUserResolver, ['@Pimcore\Bundle\AdminBundle\Security\User\TokenStorageUserResolver']]
- [setTokenStorageUserResolver, ['@Pimcore\Security\User\TokenStorageUserResolver']]
- [setSerializer, ['@serializer']]
- [setConfiguration, ['@MembersBundle\Configuration\Configuration']]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class MembersCore {
return false;
}

if (type === 'object' && this.settings.restriction.allowed_objects.indexOf(obj.data.general.o_className) === -1) {
if (type === 'object' && this.settings.restriction.allowed_objects.indexOf(obj.data.general.className) === -1) {
isAllowed = false;
} else if (type === 'page' && ['page', 'link'].indexOf(obj.type) === -1) {
isAllowed = false;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,5 @@ interface SsoAwareUserInterface
*/
public function getSsoIdentities(): array;

/**
* @param array|null $ssoIdentities
*
* @return $this
*/
public function setSsoIdentities(?array $ssoIdentities);
public function setSsoIdentities(?array $ssoIdentities): static;
}
81 changes: 81 additions & 0 deletions src/Adapter/User/UserInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php

namespace MembersBundle\Adapter\User;

use Carbon\Carbon;
use Symfony\Component\Security\Core\User\EquatableInterface;
use Symfony\Component\Security\Core\User\UserInterface as BaseUserInterface;

interface UserInterface extends BaseUserInterface, EquatableInterface
{
public const ROLE_DEFAULT = 'ROLE_USER';
public const ROLE_SUPER_ADMIN = 'ROLE_SUPER_ADMIN';

public function setId(?int $id): static;

public function getId(): ?int;

public function setParentId(?int $parentId): static;

public function getParentId(): ?int;

public function setKey(string $key): static;

public function getKey(): ?string;

public function setProperty(string $name, string $type, mixed $data, bool $inherited = false, bool $inheritable = false): static;

public function getProperty(string $name, bool $asContainer = false): mixed;

public function setPublished(bool $published): static;

public function getPublished(): bool;

public function setConfirmationToken(?string $confirmationToken): static;

public function getConfirmationToken(): ?string;

public function setLastLogin(Carbon $time): static;

public function getLastLogin(): ?Carbon;

public function setPassword(string $password): static;

public function getPassword(): ?string;

public function setUserName(?string $userName): static;

public function getUserName(): ?string;

public function setEmail(?string $email): static;

public function getEmail(): ?string;

public function setGroups(array $groups): static;

public function getGroups(): ?array;

public function setPasswordRequestedAt(?Carbon $date): static;

public function getPasswordRequestedAt(): ?Carbon;

/**
* Checks whether the password reset request has expired.
*
* @param int $ttl Requests older than this many seconds will be considered expired
*/
public function isPasswordRequestNonExpired(int $ttl): bool;

public function setPlainPassword(string $password): self;

public function getPlainPassword(): ?string;

public function isAccountNonExpired(): bool;

public function isAccountNonLocked(): bool;

/**
* @throws \Exception
*/
public function save();
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
28 changes: 28 additions & 0 deletions src/Configuration/Configuration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace MembersBundle\Configuration;

class Configuration
{
protected array $config;

public function setConfig(array $config = []): void
{
$this->config = $config;
}

public function getConfigArray(): array
{
return $this->config;
}

public function getConfig(string $slot): mixed
{
return $this->config[$slot];
}

public function getOAuthConfig(string $slot): mixed
{
return $this->config['oauth'][$slot];
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
use MembersBundle\Manager\ClassManagerInterface;
use MembersBundle\Restriction\Restriction;
use MembersBundle\Service\RestrictionService;
use Pimcore\Bundle\AdminBundle\Controller\AdminController;
use Pimcore\Bundle\AdminBundle\Controller\AdminAbstractController;
use MembersBundle\Configuration\Configuration;
use Pimcore\Model\Element\ElementInterface;
use Pimcore\Model\Element\Service;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;

class RestrictionController extends AdminController
class RestrictionController extends AdminAbstractController
{
protected Configuration $configuration;
protected ClassManagerInterface $classManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function loginAction(Request $request): Response
$error = null; // The value does not come from the security component.
}

return $this->renderForm('@Members/auth/login.html.twig', [
return $this->render('@Members/auth/login.html.twig', [
'form' => $form,
'last_username' => $lastUsername,
'error' => $error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ public function changePasswordAction(Request $request): Response
return $response;
}

return $this->renderForm('@Members/change-password/change_password.html.twig', [
'form' => $form,
]);
return $this->render('@Members/change_password/change_password.html.twig', ['form' => $form]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ public function deleteAccountAction(Request $request): Response
return $response;
}

return $this->renderForm('@Members/delete-account/delete_account.html.twig', [
'form' => $form,
]);
return $this->render('@Members/delete_account/delete_account.html.twig', ['form' => $form]);
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,36 +13,23 @@
use MembersBundle\Service\SsoIdentityStatusServiceInterface;
use Pimcore\Http\Request\Resolver\SiteResolver;
use Pimcore\Model\Site;
use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBagInterface;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Session\Attribute\NamespacedAttributeBag;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;

class OAuthController extends AbstractController
{
protected FactoryInterface $formFactory;
protected EventDispatcherInterface $eventDispatcher;
protected UserManagerInterface $userManager;
protected ClientRegistry $clientRegistry;
protected OAuthScopeAllocatorInterface $scopeAllocator;
protected SsoIdentityStatusServiceInterface $identityStatusService;

public function __construct(
FactoryInterface $formFactory,
EventDispatcherInterface $eventDispatcher,
UserManagerInterface $userManager,
ClientRegistry $clientRegistry,
OAuthScopeAllocatorInterface $scopeAllocator,
SsoIdentityStatusServiceInterface $identityStatusService
protected FactoryInterface $formFactory,
protected EventDispatcherInterface $eventDispatcher,
protected UserManagerInterface $userManager,
protected ClientRegistry $clientRegistry,
protected OAuthScopeAllocatorInterface $scopeAllocator,
protected SsoIdentityStatusServiceInterface $identityStatusService
) {
$this->formFactory = $formFactory;
$this->eventDispatcher = $eventDispatcher;
$this->userManager = $userManager;
$this->clientRegistry = $clientRegistry;
$this->scopeAllocator = $scopeAllocator;
$this->identityStatusService = $identityStatusService;
}

public function completeProfileAction(Request $request): Response
Expand Down Expand Up @@ -86,9 +73,7 @@ public function completeProfileAction(Request $request): Response
}
}

return $this->renderForm('@Members/sso/complete-profile/complete_profile.html.twig', [
'form' => $form
]);
return $this->render('@Members/sso/complete-profile/complete_profile.html.twig', ['form' => $form]);
}

public function profileCompletedAction(Request $request): Response
Expand Down Expand Up @@ -132,7 +117,7 @@ protected function oAuthConnect(Request $request, string $provider, array $param
]
]);

/** @var NamespacedAttributeBag $session */
/** @var AttributeBagInterface $session */
$session = $request->getSession()->getBag('members_session');
$session->set('oauth_state_data', $params);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,7 @@ public function editAction(Request $request): Response
return $response;
}

return $this->renderForm('@Members/profile/edit.html.twig', [
'form' => $form,
]);
return $this->render('@Members/profile/edit.html.twig', ['form' => $form]);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
use MembersBundle\Manager\UserManagerInterface;
use MembersBundle\MembersEvents;
use MembersBundle\Service\RequestPropertiesForUserExtractorServiceInterface;
use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBagInterface;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\Session\Attribute\NamespacedAttributeBag;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
Expand All @@ -22,24 +22,13 @@

class RegistrationController extends AbstractController
{
protected FactoryInterface $formFactory;
protected EventDispatcherInterface $eventDispatcher;
protected UserManagerInterface $userManager;
protected TokenStorageInterface $tokenStorage;
protected RequestPropertiesForUserExtractorServiceInterface $requestPropertiesForUserExtractorService;

public function __construct(
FactoryInterface $formFactory,
EventDispatcherInterface $eventDispatcher,
UserManagerInterface $userManager,
TokenStorageInterface $tokenStorage,
RequestPropertiesForUserExtractorServiceInterface $requestPropertiesForUserExtractorService
protected FactoryInterface $formFactory,
protected EventDispatcherInterface $eventDispatcher,
protected UserManagerInterface $userManager,
protected TokenStorageInterface $tokenStorage,
protected RequestPropertiesForUserExtractorServiceInterface $requestPropertiesForUserExtractorService
) {
$this->formFactory = $formFactory;
$this->eventDispatcher = $eventDispatcher;
$this->userManager = $userManager;
$this->tokenStorage = $tokenStorage;
$this->requestPropertiesForUserExtractorService = $requestPropertiesForUserExtractorService;
}

public function registerAction(Request $request): Response
Expand Down Expand Up @@ -84,14 +73,12 @@ public function registerAction(Request $request): Response
}
}

return $this->renderForm('@Members/registration/register.html.twig', [
'form' => $form,
]);
return $this->render('@Members/registration/register.html.twig', ['form' => $form]);
}

public function checkEmailAction(Request $request): Response
{
/** @var NamespacedAttributeBag $sessionBag */
/** @var AttributeBagInterface $sessionBag */
$sessionBag = $request->getSession()->getBag('members_session');

$email = $sessionBag->get('members_user_send_confirmation_email/email');
Expand All @@ -112,7 +99,7 @@ public function checkEmailAction(Request $request): Response

public function checkAdminAction(Request $request): Response
{
/** @var NamespacedAttributeBag $sessionBag */
/** @var AttributeBagInterface $sessionBag */
$sessionBag = $request->getSession()->getBag('members_session');

$email = $sessionBag->get('members_user_send_confirmation_email/email');
Expand Down Expand Up @@ -177,7 +164,7 @@ public function confirmedAction(Request $request): Response
]);
}

private function getTargetUrlFromSession(NamespacedAttributeBag $session): ?string
private function getTargetUrlFromSession(AttributeBagInterface $session): ?string
{
$token = $this->tokenStorage->getToken();

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ public function requestAction(Request $request): Response
$form = $this->requestResettingFormFactory->createUnnamedForm();
$form->handleRequest($request);

return $this->renderForm('@Members/resetting/request.html.twig', [
'form' => $form,
]);
return $this->render('@Members/resetting/request.html.twig', ['form' => $form]);
}

public function sendEmailAction(Request $request): Response
Expand Down Expand Up @@ -161,7 +159,7 @@ public function resetAction(Request $request, ?string $token = null): Response
return $response;
}

return $this->renderForm('@Members/resetting/reset.html.twig', [
return $this->render('@Members/resetting/reset.html.twig', [
'token' => $token,
'form' => $form,
]);
Expand Down
Loading

0 comments on commit ccd7e53

Please sign in to comment.