diff --git a/src/Adapter/Group/AbstractGroup.php b/src/Adapter/Group/AbstractGroup.php index fd6f9320..7adc35aa 100644 --- a/src/Adapter/Group/AbstractGroup.php +++ b/src/Adapter/Group/AbstractGroup.php @@ -1,5 +1,16 @@ getId() === $this->getId(); + return $user instanceof self && $user->getId() === $this->getId(); } public function getRoles(): array diff --git a/src/Command/ClassInstallerCommand.php b/src/Command/ClassInstallerCommand.php index d121c5d6..0ce7c120 100644 --- a/src/Command/ClassInstallerCommand.php +++ b/src/Command/ClassInstallerCommand.php @@ -1,5 +1,16 @@ renderTemplate('@Members/email/email.html.twig', array_filter($request->attributes->all(), static function($parameterKey) { + return $this->renderTemplate('@Members/email/email.html.twig', array_filter($request->attributes->all(), static function ($parameterKey) { return !str_starts_with($parameterKey, '_'); }, ARRAY_FILTER_USE_KEY)); } diff --git a/src/Controller/OAuthController.php b/src/Controller/OAuthController.php index 30ec8bbe..64d92da5 100644 --- a/src/Controller/OAuthController.php +++ b/src/Controller/OAuthController.php @@ -1,5 +1,16 @@ ['key' => $role, 'value' => $role], + static fn ($role): array => ['key' => $role, 'value' => $role], array_unique($roles) ); } diff --git a/src/DependencyInjection/CompilerPass/OAuthLoginStrategyPass.php b/src/DependencyInjection/CompilerPass/OAuthLoginStrategyPass.php index 557ed6b1..0a7bc6ae 100644 --- a/src/DependencyInjection/CompilerPass/OAuthLoginStrategyPass.php +++ b/src/DependencyInjection/CompilerPass/OAuthLoginStrategyPass.php @@ -1,5 +1,16 @@ getExtensionConfig($this->getAlias()); $config = $this->processConfiguration($this->getConfiguration([], $container), $configs); - /** @phpstan-ignore-next-line */ + /* @phpstan-ignore-next-line */ if (!$container->hasParameter('members.firewall_name')) { $container->setParameter('members.firewall_name', 'members_fe'); } diff --git a/src/Document/Areabrick/MembersLogin/MembersLogin.php b/src/Document/Areabrick/MembersLogin/MembersLogin.php index c230fe61..2776ca87 100644 --- a/src/Document/Areabrick/MembersLogin/MembersLogin.php +++ b/src/Document/Areabrick/MembersLogin/MembersLogin.php @@ -1,5 +1,16 @@ setItems([ [ - 'type' => 'relation', - 'label' => $this->translator->trans('redirect after successful login', [], 'admin'), - 'name' => 'redirectAfterSuccess', + 'type' => 'relation', + 'label' => $this->translator->trans('redirect after successful login', [], 'admin'), + 'name' => 'redirectAfterSuccess', 'config' => [ - 'types' => ['document'], + 'types' => ['document'], 'subtypes' => [ 'document' => ['page', 'link', 'hardlink'] ] ] ], [ - 'type' => 'checkbox', + 'type' => 'checkbox', 'label' => $this->translator->trans('Hide when logged in', [], 'admin'), - 'name' => 'hideWhenLoggedIn', + 'name' => 'hideWhenLoggedIn', ], [ - 'type' => 'relation', - 'label' => $this->translator->trans('Show this snippet when logged in', [], 'admin'), - 'name' => 'showSnippedWhenLoggedIn', + 'type' => 'relation', + 'label' => $this->translator->trans('Show this snippet when logged in', [], 'admin'), + 'name' => 'showSnippedWhenLoggedIn', 'config' => [ - 'types' => ['document'], + 'types' => ['document'], 'subtypes' => [ 'document' => ['snippet'] ] diff --git a/src/Document/Builder/BrickBuilder.php b/src/Document/Builder/BrickBuilder.php index 8c7e9ca3..2c81c87b 100644 --- a/src/Document/Builder/BrickBuilder.php +++ b/src/Document/Builder/BrickBuilder.php @@ -1,5 +1,16 @@ 'auth/area/login_area', 'area-logged-in' => 'auth/area/login_area_logged_in', diff --git a/src/Event/FilterUserResponseEvent.php b/src/Event/FilterUserResponseEvent.php index 327e03b1..5dd418ae 100755 --- a/src/Event/FilterUserResponseEvent.php +++ b/src/Event/FilterUserResponseEvent.php @@ -1,5 +1,16 @@ getArgument('assets'); foreach ($assets as &$asset) { - if (!isset($asset['basePath'])) { continue; } diff --git a/src/EventListener/UserChangeListener.php b/src/EventListener/UserChangeListener.php index 9fc534e9..99c63fdb 100644 --- a/src/EventListener/UserChangeListener.php +++ b/src/EventListener/UserChangeListener.php @@ -1,5 +1,16 @@ setSection($this->isFrontendRequestByAdmin() || !$this->elementIsInProtectedStorageFolder($element) + $elementRestriction->setSection( + $this->isFrontendRequestByAdmin() || !$this->elementIsInProtectedStorageFolder($element) ? self::RESTRICTION_SECTION_ALLOWED : self::RESTRICTION_SECTION_NOT_ALLOWED ); @@ -91,7 +102,6 @@ public function getElementRestrictionStatus(ElementInterface $element): ElementR } return $elementRestriction->setSection($this->filterAllowedSectionToUser($user->getGroups(), $restriction->getRelatedGroups())); - } private function filterAllowedSectionToUser(array $userGroups, array $elementGroups): string diff --git a/src/Manager/RestrictionManagerInterface.php b/src/Manager/RestrictionManagerInterface.php index 4ccdc57c..21a2478c 100644 --- a/src/Manager/RestrictionManagerInterface.php +++ b/src/Manager/RestrictionManagerInterface.php @@ -1,5 +1,16 @@ classManager->getUserListing(); $memberListing->setCondition($condition, $conditionVariables); $memberListing->setUnpublished($includeUnpublished); diff --git a/src/Manager/UserManagerInterface.php b/src/Manager/UserManagerInterface.php index 7c7e767c..745de370 100644 --- a/src/Manager/UserManagerInterface.php +++ b/src/Manager/UserManagerInterface.php @@ -1,5 +1,16 @@ getDao()->getById($id); @@ -24,7 +35,7 @@ public static function getById(int $id): Restriction return $obj; } - public static function getByTargetId(int $id, string $cType = 'page'): Restriction + public static function getByTargetId(int $id, string $cType = 'page'): self { $obj = new self(); $obj->getDao()->getByField('targetId', $id, $cType); diff --git a/src/Security/Authenticator/OAuthIdentityAuthenticator.php b/src/Security/Authenticator/OAuthIdentityAuthenticator.php index 8e512e0a..a014b87d 100644 --- a/src/Security/Authenticator/OAuthIdentityAuthenticator.php +++ b/src/Security/Authenticator/OAuthIdentityAuthenticator.php @@ -1,5 +1,16 @@ getToken(), function () use ($accessToken, $client, $provider, $type, $parameter) { - $user = $client->fetchUserFromToken($accessToken); $oAuthResponse = new OAuthResponse($provider, $accessToken, $user, $parameter); $memberUser = $this->oAuthRegistrationHandler->getRefreshedUserFromUserResponse($oAuthResponse); diff --git a/src/Security/OAuth/AccountConnector.php b/src/Security/OAuth/AccountConnector.php index 7737dcc8..2d801508 100755 --- a/src/Security/OAuth/AccountConnector.php +++ b/src/Security/OAuth/AccountConnector.php @@ -1,5 +1,16 @@ leftJoin($aliasFrom, 'members_restrictions', 'mr', + $query->leftJoin( + $aliasFrom, + 'members_restrictions', + 'mr', sprintf('mr.targetId = %s.%s AND mr.ctype = "%s"', $aliasFrom, $queryIdentifier, $cType), ); - $query->leftJoin($aliasFrom, 'members_group_relations', 'mgr', + $query->leftJoin( + $aliasFrom, + 'members_group_relations', + 'mgr', 'mgr.restrictionId = mr.id' ); diff --git a/src/Security/RestrictionUri.php b/src/Security/RestrictionUri.php index 910f6e82..19925abe 100644 --- a/src/Security/RestrictionUri.php +++ b/src/Security/RestrictionUri.php @@ -1,5 +1,16 @@ restrictionManager->elementIsInProtectedStorageFolder($asset)) { - throw new \Exception(sprintf( + throw new \Exception( + sprintf( 'Asset "%s" is not in protected environment. Please move it to "%s"', $asset->getFullPath(), RestrictionManager::PROTECTED_ASSET_FOLDER diff --git a/src/Security/UserChecker.php b/src/Security/UserChecker.php index 682764f7..1864cca4 100644 --- a/src/Security/UserChecker.php +++ b/src/Security/UserChecker.php @@ -1,5 +1,16 @@ hasChanged() === false) { throw new EntityNotRefreshedException(sprintf('entity %d has not changed', $user->getId())); } - } public function addDefaults(UserInterface $user, ResourceOwnerInterface $resourceOwner, string $type): void diff --git a/src/Service/RestrictionService.php b/src/Service/RestrictionService.php index 2c944681..791748b2 100644 --- a/src/Service/RestrictionService.php +++ b/src/Service/RestrictionService.php @@ -1,13 +1,24 @@ isInherited() === false) { - $restriction->getDao()->delete(); $this->triggerEvent($obj, $restriction, MembersEvents::ENTITY_DELETE_RESTRICTION); @@ -235,7 +244,6 @@ public function findClosestInheritanceParent(int $elementId, string $cType): arr } foreach ($paths as $p) { - /** @var ElementInterface $el */ if ($el = $class::getByPath($p)) { $restriction = false; @@ -290,7 +298,6 @@ protected function updateRestrictionContext(ElementInterface $obj, string $cType if (!$hasParentRestriction) { if ($objectRestriction->isInherited()) { - $objectRestriction->getDao()->delete(); $this->triggerEvent($obj, $objectRestriction, MembersEvents::ENTITY_DELETE_RESTRICTION); diff --git a/src/Service/SsoIdentityStatusService.php b/src/Service/SsoIdentityStatusService.php index cd9171b2..ee65917c 100644 --- a/src/Service/SsoIdentityStatusService.php +++ b/src/Service/SsoIdentityStatusService.php @@ -1,13 +1,24 @@ getDao()->getIdByName($className); - } catch(NotFoundException $e) { + } catch (NotFoundException $e) { // fail silently } @@ -52,7 +63,6 @@ protected function getClasses(array $classes): array $result = []; foreach ($classes as $className) { - $filename = sprintf('class_%s_export.json', $className); $path = realpath(sprintf('%s/config/install/classes/%s', dirname(__DIR__, 2), $filename)); diff --git a/src/Tool/Install.php b/src/Tool/Install.php index f64e9fdb..08c21b1f 100644 --- a/src/Tool/Install.php +++ b/src/Tool/Install.php @@ -1,10 +1,20 @@ getGroups(); if (!empty($allowedGroups)) { - /** @var GroupInterface $group */ foreach ($allowedGroups as $group) { $groupIds[] = $group->getId(); diff --git a/src/Twig/Extension/OAuthExtension.php b/src/Twig/Extension/OAuthExtension.php index 3df42855..05696fe3 100644 --- a/src/Twig/Extension/OAuthExtension.php +++ b/src/Twig/Extension/OAuthExtension.php @@ -1,5 +1,16 @@