From 683bbf86b59ff18982b60a50c1bc4bdf11fdd9d0 Mon Sep 17 00:00:00 2001 From: Divesh Pahuja Date: Fri, 24 Mar 2023 16:30:07 +0100 Subject: [PATCH] Fix Merge conflicts --- bundles/AdminBundle/Event/AdminEvents.php | 58 ++++++++++--------- .../Event/ElementAdminStyleEvent.php | 38 +++--------- .../Event/IndexActionSettingsEvent.php | 13 +---- .../Event/Login/LoginCredentialsEvent.php | 21 ++----- .../Event/Login/LoginFailedEvent.php | 34 +++-------- .../Event/Login/LoginRedirectEvent.php | 26 +-------- .../AdminBundle/Event/Login/LogoutEvent.php | 14 +---- .../Event/Login/LostPasswordEvent.php | 35 +++-------- .../Model/ElementDeleteInfoEventInterface.php | 12 ---- .../Traits/ElementDeleteInfoEventTrait.php | 22 +------ phpstan-baseline.neon | 8 +-- 11 files changed, 70 insertions(+), 211 deletions(-) diff --git a/bundles/AdminBundle/Event/AdminEvents.php b/bundles/AdminBundle/Event/AdminEvents.php index ab25e0bb912..1ebb47eebb2 100644 --- a/bundles/AdminBundle/Event/AdminEvents.php +++ b/bundles/AdminBundle/Event/AdminEvents.php @@ -28,30 +28,6 @@ class AdminEvents */ const LOGIN_REDIRECT = 'pimcore.admin.login.redirect'; - /** - * The LOGIN_CREDENTIALS event is triggered after login credentials were resolved from request. - * - * This event allows you to influence the credentials resolved in the authenticator before - * they are passed to getUser(). - * - * @Event("Pimcore\Event\Admin\Login\LoginCredentialsEvent") - * - * @var string - */ - const LOGIN_CREDENTIALS = 'pimcore.admin.login.credentials'; - - /** - * The LOGIN_FAILED event is triggered when credentials were invalid. - * - * This event allows you to set a custom user which is resolved from the given credentials - * from a third-party authentication system (e.g. an external service). - * - * @Event("Pimcore\Event\Admin\Login\LoginFailedEvent") - * - * @var string - */ - const LOGIN_FAILED = 'pimcore.admin.login.failed'; - /** * The LOGIN_LOSTPASSWORD event is triggered before the lost password email * is sent. @@ -78,6 +54,25 @@ class AdminEvents */ const LOGIN_LOGOUT = 'pimcore.admin.login.logout'; + /** + * The LOGIN_BEFORE_RENDER event is triggered before the login view is rendered. + * + * Allows overriding the parameters and including templates. + * ```php + * public function getContent(GenericEvent $event): void + * { + * $parameters = $event->getArgument('parameters'); + * $parameters['includeTemplates']['VendorBundleName'] = '@VendorBundleName/path/to/template.html.twig'; + * $event->setArgument('parameters', $parameters); + * } + * ``` + * + * @Event("Symfony\Component\EventDispatcher\GenericEvent") + * + * @var string + */ + const LOGIN_BEFORE_RENDER = 'pimcore.admin.login.beforeRender'; + /** * The INDEX_SETTINGS event is triggered when the settings object is built for the index page. * @@ -87,6 +82,15 @@ class AdminEvents */ const INDEX_ACTION_SETTINGS = 'pimcore.admin.indexAction.settings'; + /** + * The SAVE_SYSTEM_SETTINGS event is triggered when the system settings are saved. + * + * @Event("Symfony\Component\EventDispatcher\GenericEvent") + * + * @var string + */ + const SAVE_ACTION_SYSTEM_SETTINGS = 'pimcore.admin.saveAction.system.settings'; + /** * Fired before the request params are parsed. * @@ -344,7 +348,7 @@ class AdminEvents * * @var string */ - const ASSET_TREE_GET_CHILDREN_BY_ID_PRE_SEND_DATA = 'pimcore.admin.asset.treeGetChildsById.preSendData'; + const ASSET_TREE_GET_CHILDREN_BY_ID_PRE_SEND_DATA = 'pimcore.admin.asset.treeGetChildrenById.preSendData'; /** * Fired before the request params are parsed. @@ -369,7 +373,7 @@ class AdminEvents * * @var string */ - const DOCUMENT_TREE_GET_CHILDREN_BY_ID_PRE_SEND_DATA = 'pimcore.admin.document.treeGetChildsById.preSendData'; + const DOCUMENT_TREE_GET_CHILDREN_BY_ID_PRE_SEND_DATA = 'pimcore.admin.document.treeGetChildrenById.preSendData'; /** * Fired before the request params are parsed. @@ -408,7 +412,7 @@ class AdminEvents * * @var string */ - const OBJECT_TREE_GET_CHILDREN_BY_ID_PRE_SEND_DATA = 'pimcore.admin.dataobject.treeGetChildsById.preSendData'; + const OBJECT_TREE_GET_CHILDREN_BY_ID_PRE_SEND_DATA = 'pimcore.admin.dataobject.treeGetChildrenById.preSendData'; /** * Subject: \Pimcore\Bundle\AdminBundle\Controller\Admin\ClassController diff --git a/bundles/AdminBundle/Event/ElementAdminStyleEvent.php b/bundles/AdminBundle/Event/ElementAdminStyleEvent.php index e070831d61b..5d1b22cf77f 100644 --- a/bundles/AdminBundle/Event/ElementAdminStyleEvent.php +++ b/bundles/AdminBundle/Event/ElementAdminStyleEvent.php @@ -38,62 +38,41 @@ class ElementAdminStyleEvent extends Event */ const CONTEXT_SEARCH = 3; - /** - * @var int - */ - protected $context; + protected ?int $context = null; - /** - * @var ElementInterface - */ - protected $element; + protected ElementInterface $element; - /** - * @var AdminStyle - */ - protected $adminStyle; + protected AdminStyle $adminStyle; /** * ElementAdminStyleEvent constructor. * * @param ElementInterface $element * @param AdminStyle $adminStyle - * @param null|int $context + * @param int|null $context */ - public function __construct(ElementInterface $element, AdminStyle $adminStyle, $context = null) + public function __construct(ElementInterface $element, AdminStyle $adminStyle, int $context = null) { $this->element = $element; $this->adminStyle = $adminStyle; $this->context = $context; } - /** - * @return ElementInterface - */ public function getElement(): ElementInterface { return $this->element; } - /** - * @param ElementInterface $element - */ public function setElement(ElementInterface $element): void { $this->element = $element; } - /** - * @return AdminStyle - */ public function getAdminStyle(): AdminStyle { return $this->adminStyle; } - /** - * @param AdminStyle $adminStyle - */ public function setAdminStyle(AdminStyle $adminStyle): void { $this->adminStyle = $adminStyle; @@ -104,15 +83,12 @@ public function setAdminStyle(AdminStyle $adminStyle): void * * @return null|int */ - public function getContext() + public function getContext(): ?int { return $this->context; } - /** - * @param null|int $context - */ - public function setContext($context): void + public function setContext(?int $context): void { $this->context = $context; } diff --git a/bundles/AdminBundle/Event/IndexActionSettingsEvent.php b/bundles/AdminBundle/Event/IndexActionSettingsEvent.php index 573b2dd3b48..4fff7485609 100644 --- a/bundles/AdminBundle/Event/IndexActionSettingsEvent.php +++ b/bundles/AdminBundle/Event/IndexActionSettingsEvent.php @@ -21,10 +21,7 @@ class IndexActionSettingsEvent extends Event { - /** - * @var array - */ - private $settings; + private array $settings; public function __construct(array $settings) { @@ -36,16 +33,12 @@ public function getSettings(): array return $this->settings; } - public function setSettings(array $settings) + public function setSettings(array $settings): void { $this->settings = $settings; } - /** - * @param string $key - * @param mixed $value - */ - public function addSetting(string $key, $value) + public function addSetting(string $key, mixed $value): void { $this->settings[$key] = $value; } diff --git a/bundles/AdminBundle/Event/Login/LoginCredentialsEvent.php b/bundles/AdminBundle/Event/Login/LoginCredentialsEvent.php index 438ee536314..2a294a9e21c 100644 --- a/bundles/AdminBundle/Event/Login/LoginCredentialsEvent.php +++ b/bundles/AdminBundle/Event/Login/LoginCredentialsEvent.php @@ -23,33 +23,20 @@ class LoginCredentialsEvent extends Event { use RequestAwareTrait; - /** - * @var array - */ - protected $credentials; - - /** - * @param Request $request - * @param array $credentials - */ + protected array $credentials; + public function __construct(Request $request, array $credentials) { $this->request = $request; $this->credentials = $credentials; } - /** - * @return array - */ - public function getCredentials() + public function getCredentials(): array { return $this->credentials; } - /** - * @param array $credentials - */ - public function setCredentials(array $credentials) + public function setCredentials(array $credentials): void { $this->credentials = $credentials; } diff --git a/bundles/AdminBundle/Event/Login/LoginFailedEvent.php b/bundles/AdminBundle/Event/Login/LoginFailedEvent.php index 0cdb7dbb236..eda4c8b1487 100644 --- a/bundles/AdminBundle/Event/Login/LoginFailedEvent.php +++ b/bundles/AdminBundle/Event/Login/LoginFailedEvent.php @@ -20,28 +20,16 @@ class LoginFailedEvent extends Event { - /** - * @var array - */ - protected $credentials; + protected array $credentials; - /** - * @var User - */ - protected $user; + protected ?User $user = null; - /** - * @param array $credentials - */ public function __construct(array $credentials) { $this->credentials = $credentials; } - /** - * @return array - */ - public function getCredentials() + public function getCredentials(): array { return $this->credentials; } @@ -52,7 +40,7 @@ public function getCredentials() * * @return mixed */ - public function getCredential($name, $default = null) + public function getCredential(string $name, mixed $default = null): mixed { if (isset($this->credentials[$name])) { return $this->credentials[$name]; @@ -61,30 +49,22 @@ public function getCredential($name, $default = null) return $default; } - /** - * @return User - */ - public function getUser() + public function getUser(): ?User { return $this->user; } /** - * @param User $user - * * @return $this */ - public function setUser(User $user) + public function setUser(User $user): static { $this->user = $user; return $this; } - /** - * @return bool - */ - public function hasUser() + public function hasUser(): bool { return null !== $this->user; } diff --git a/bundles/AdminBundle/Event/Login/LoginRedirectEvent.php b/bundles/AdminBundle/Event/Login/LoginRedirectEvent.php index 94321293525..f13f76e7838 100644 --- a/bundles/AdminBundle/Event/Login/LoginRedirectEvent.php +++ b/bundles/AdminBundle/Event/Login/LoginRedirectEvent.php @@ -19,53 +19,31 @@ class LoginRedirectEvent extends Event { - /** - * @var string - */ - protected $routeName; + protected string $routeName; - /** - * @var array - */ - protected $routeParams; + protected array $routeParams; - /** - * @param string $routeName - * @param array $routeParams - */ public function __construct(string $routeName, array $routeParams = []) { $this->routeName = $routeName; $this->routeParams = $routeParams; } - /** - * @return string - */ public function getRouteName(): string { return $this->routeName; } - /** - * @param string $routeName - */ public function setRouteName(string $routeName): void { $this->routeName = $routeName; } - /** - * @return array - */ public function getRouteParams(): array { return $this->routeParams; } - /** - * @param array $routeParams - */ public function setRouteParams(array $routeParams): void { $this->routeParams = $routeParams; diff --git a/bundles/AdminBundle/Event/Login/LogoutEvent.php b/bundles/AdminBundle/Event/Login/LogoutEvent.php index a992ede18f2..0ba45625307 100644 --- a/bundles/AdminBundle/Event/Login/LogoutEvent.php +++ b/bundles/AdminBundle/Event/Login/LogoutEvent.php @@ -26,25 +26,15 @@ class LogoutEvent extends Event use RequestAwareTrait; use ResponseAwareTrait; - /** - * @var User - */ - protected $user; + protected User $user; - /** - * @param Request $request - * @param User $user - */ public function __construct(Request $request, User $user) { $this->request = $request; $this->user = $user; } - /** - * @return User - */ - public function getUser() + public function getUser(): User { return $this->user; } diff --git a/bundles/AdminBundle/Event/Login/LostPasswordEvent.php b/bundles/AdminBundle/Event/Login/LostPasswordEvent.php index 66e76d9e89a..003d5c51d03 100644 --- a/bundles/AdminBundle/Event/Login/LostPasswordEvent.php +++ b/bundles/AdminBundle/Event/Login/LostPasswordEvent.php @@ -23,43 +23,24 @@ class LostPasswordEvent extends Event { use ResponseAwareTrait; - /** - * @var User - */ - protected $user; + protected User $user; - /** - * @var string - */ - protected $loginUrl; + protected string $loginUrl; - /** - * @var bool - */ - protected $sendMail = true; + protected bool $sendMail = true; - /** - * @param User $user - * @param string $loginUrl - */ - public function __construct(User $user, $loginUrl) + public function __construct(User $user, string $loginUrl) { $this->user = $user; $this->loginUrl = $loginUrl; } - /** - * @return User - */ - public function getUser() + public function getUser(): User { return $this->user; } - /** - * @return string - */ - public function getLoginUrl() + public function getLoginUrl(): string { return $this->loginUrl; } @@ -69,7 +50,7 @@ public function getLoginUrl() * * @return bool */ - public function getSendMail() + public function getSendMail(): bool { return $this->sendMail; } @@ -81,7 +62,7 @@ public function getSendMail() * * @return $this */ - public function setSendMail($sendMail) + public function setSendMail(bool $sendMail): static { $this->sendMail = (bool)$sendMail; diff --git a/bundles/AdminBundle/Event/Model/ElementDeleteInfoEventInterface.php b/bundles/AdminBundle/Event/Model/ElementDeleteInfoEventInterface.php index c6ff9b5952b..21cd3d1e851 100644 --- a/bundles/AdminBundle/Event/Model/ElementDeleteInfoEventInterface.php +++ b/bundles/AdminBundle/Event/Model/ElementDeleteInfoEventInterface.php @@ -19,23 +19,11 @@ interface ElementDeleteInfoEventInterface extends ElementEventInterface { - /** - * @return bool - */ public function getDeletionAllowed(): bool; - /** - * @param bool $deletionAllowed - */ public function setDeletionAllowed(bool $deletionAllowed): void; - /** - * @return string - */ public function getReason(): string; - /** - * @param string $reason - */ public function setReason(string $reason): void; } diff --git a/bundles/AdminBundle/Event/Traits/ElementDeleteInfoEventTrait.php b/bundles/AdminBundle/Event/Traits/ElementDeleteInfoEventTrait.php index 03ab0e5266a..c0e8b9137e6 100644 --- a/bundles/AdminBundle/Event/Traits/ElementDeleteInfoEventTrait.php +++ b/bundles/AdminBundle/Event/Traits/ElementDeleteInfoEventTrait.php @@ -22,43 +22,25 @@ */ trait ElementDeleteInfoEventTrait { - /** - * @var bool - */ - protected $deletionAllowed = true; + protected bool $deletionAllowed = true; - /** - * @var string - */ - protected $reason; + protected string $reason; - /** - * @return bool - */ public function getDeletionAllowed(): bool { return $this->deletionAllowed; } - /** - * @param bool $deletionAllowed - */ public function setDeletionAllowed(bool $deletionAllowed): void { $this->deletionAllowed = $deletionAllowed; } - /** - * @return string - */ public function getReason(): string { return $this->reason; } - /** - * @param string $reason - */ public function setReason(string $reason): void { $this->reason = $reason; diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 27320368414..8dffab40933 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -125,11 +125,11 @@ parameters: path: lib/Messenger/Handler/SanityCheckHandler.php - - message: "#^Method Pimcore\\\\Messenger\\\\Handler\\\\SearchBackendHandler\\:\\:process\\(\\) is unused\\.$#" + message: "#^Method Pimcore\\\\Bundle\\\\SimpleBackendSearchBundle\\\\MessageHandler\\\\SearchBackendHandler\\:\\:process\\(\\) is unused\\.$#" count: 1 - path: lib/Messenger/Handler/SearchBackendHandler.php + path: bundles/SimpleBackendSearchBundle/src/MessageHandler/SearchBackendHandler.php - - message: "#^Method Pimcore\\\\Messenger\\\\Handler\\\\SearchBackendHandler\\:\\:shouldFlush\\(\\) is unused\\.$#" + message: "#^Method Pimcore\\\\Bundle\\\\SimpleBackendSearchBundle\\\\MessageHandler\\\\SearchBackendHandler\\:\\:shouldFlush\\(\\) is unused\\.$#" count: 1 - path: lib/Messenger/Handler/SearchBackendHandler.php + path: bundles/SimpleBackendSearchBundle/src/MessageHandler/SearchBackendHandler.php