diff --git a/bundles/AdminBundle/Event/AdminEvents.php b/bundles/AdminBundle/Event/AdminEvents.php new file mode 100644 index 00000000000..ab25e0bb912 --- /dev/null +++ b/bundles/AdminBundle/Event/AdminEvents.php @@ -0,0 +1,554 @@ +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; + } + + /** + * Returns the context. e.g. CONTEXT_TREE or CONTEXT_EDITOR. + * + * @return null|int + */ + public function getContext() + { + return $this->context; + } + + /** + * @param null|int $context + */ + public function setContext($context): void + { + $this->context = $context; + } +} diff --git a/bundles/AdminBundle/Event/IndexActionSettingsEvent.php b/bundles/AdminBundle/Event/IndexActionSettingsEvent.php new file mode 100644 index 00000000000..573b2dd3b48 --- /dev/null +++ b/bundles/AdminBundle/Event/IndexActionSettingsEvent.php @@ -0,0 +1,52 @@ +settings = $settings; + } + + public function getSettings(): array + { + return $this->settings; + } + + public function setSettings(array $settings) + { + $this->settings = $settings; + } + + /** + * @param string $key + * @param mixed $value + */ + public function addSetting(string $key, $value) + { + $this->settings[$key] = $value; + } +} diff --git a/bundles/AdminBundle/Event/Login/LoginCredentialsEvent.php b/bundles/AdminBundle/Event/Login/LoginCredentialsEvent.php new file mode 100644 index 00000000000..438ee536314 --- /dev/null +++ b/bundles/AdminBundle/Event/Login/LoginCredentialsEvent.php @@ -0,0 +1,56 @@ +request = $request; + $this->credentials = $credentials; + } + + /** + * @return array + */ + public function getCredentials() + { + return $this->credentials; + } + + /** + * @param array $credentials + */ + public function setCredentials(array $credentials) + { + $this->credentials = $credentials; + } +} diff --git a/bundles/AdminBundle/Event/Login/LoginFailedEvent.php b/bundles/AdminBundle/Event/Login/LoginFailedEvent.php new file mode 100644 index 00000000000..0cdb7dbb236 --- /dev/null +++ b/bundles/AdminBundle/Event/Login/LoginFailedEvent.php @@ -0,0 +1,91 @@ +credentials = $credentials; + } + + /** + * @return array + */ + public function getCredentials() + { + return $this->credentials; + } + + /** + * @param string $name + * @param mixed $default + * + * @return mixed + */ + public function getCredential($name, $default = null) + { + if (isset($this->credentials[$name])) { + return $this->credentials[$name]; + } + + return $default; + } + + /** + * @return User + */ + public function getUser() + { + return $this->user; + } + + /** + * @param User $user + * + * @return $this + */ + public function setUser(User $user) + { + $this->user = $user; + + return $this; + } + + /** + * @return bool + */ + public function hasUser() + { + return null !== $this->user; + } +} diff --git a/bundles/AdminBundle/Event/Login/LoginRedirectEvent.php b/bundles/AdminBundle/Event/Login/LoginRedirectEvent.php new file mode 100644 index 00000000000..94321293525 --- /dev/null +++ b/bundles/AdminBundle/Event/Login/LoginRedirectEvent.php @@ -0,0 +1,73 @@ +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 new file mode 100644 index 00000000000..a992ede18f2 --- /dev/null +++ b/bundles/AdminBundle/Event/Login/LogoutEvent.php @@ -0,0 +1,51 @@ +request = $request; + $this->user = $user; + } + + /** + * @return User + */ + public function getUser() + { + return $this->user; + } +} diff --git a/bundles/AdminBundle/Event/Login/LostPasswordEvent.php b/bundles/AdminBundle/Event/Login/LostPasswordEvent.php new file mode 100644 index 00000000000..66e76d9e89a --- /dev/null +++ b/bundles/AdminBundle/Event/Login/LostPasswordEvent.php @@ -0,0 +1,90 @@ +user = $user; + $this->loginUrl = $loginUrl; + } + + /** + * @return User + */ + public function getUser() + { + return $this->user; + } + + /** + * @return string + */ + public function getLoginUrl() + { + return $this->loginUrl; + } + + /** + * Determines if lost password mail should be sent + * + * @return bool + */ + public function getSendMail() + { + return $this->sendMail; + } + + /** + * Sets flag whether to send lost password mail or not + * + * @param bool $sendMail + * + * @return $this + */ + public function setSendMail($sendMail) + { + $this->sendMail = (bool)$sendMail; + + return $this; + } +} diff --git a/bundles/AdminBundle/Event/Model/AssetDeleteInfoEvent.php b/bundles/AdminBundle/Event/Model/AssetDeleteInfoEvent.php new file mode 100644 index 00000000000..757f59d37ed --- /dev/null +++ b/bundles/AdminBundle/Event/Model/AssetDeleteInfoEvent.php @@ -0,0 +1,29 @@ +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/bundles/AdminBundle/public/js/pimcore/object/classes/class.js b/bundles/AdminBundle/public/js/pimcore/object/classes/class.js index b67ba9d5fd5..33023b03e08 100644 --- a/bundles/AdminBundle/public/js/pimcore/object/classes/class.js +++ b/bundles/AdminBundle/public/js/pimcore/object/classes/class.js @@ -1076,7 +1076,14 @@ pimcore.object.classes.klass = Class.create({ fieldLabel: t("key"), labelWidth: 100, width: 250, - value: data.index_key + value: data.index_key, + validator: function (value) { + if(value !== value.replace(/[^a-za-z0-9_\-+]/g,'')){ + this.setvalue(value.replace(/[^a-za-z0-9_\-+]/g,'')); + } + + return true; + } }; //fixes data to match store model diff --git a/bundles/AdminBundle/public/js/pimcore/object/fieldcollection.js b/bundles/AdminBundle/public/js/pimcore/object/fieldcollection.js index 9387b8b2736..ee73e8d1b11 100644 --- a/bundles/AdminBundle/public/js/pimcore/object/fieldcollection.js +++ b/bundles/AdminBundle/public/js/pimcore/object/fieldcollection.js @@ -18,7 +18,8 @@ pimcore.registerNS("pimcore.object.fieldcollection"); pimcore.object.fieldcollection = Class.create({ forbiddenNames: [ - "abstract", "class", "data", "folder", "list", "permissions", "resource", "concrete", "interface", "default" + "abstract", "class", "data", "folder", "list", "permissions", "resource", "dao", "concrete", "items", + "object", "interface", "default" ], initialize: function () { diff --git a/bundles/AdminBundle/public/js/pimcore/object/helpers/imageGalleryDropZone.js b/bundles/AdminBundle/public/js/pimcore/object/helpers/imageGalleryDropZone.js index 4337dcef46c..a8f8e4043c2 100644 --- a/bundles/AdminBundle/public/js/pimcore/object/helpers/imageGalleryDropZone.js +++ b/bundles/AdminBundle/public/js/pimcore/object/helpers/imageGalleryDropZone.js @@ -73,7 +73,7 @@ Ext.define('pimcore.object.helpers.ImageGalleryDropZone', { var y = p.el.getY(); var w = p.el.getWidth(); - if(xy[1] >y && (xy[1] < (y + h)) && xy[0] > x && (xy[0] < (x + w))) { + if(pos != currentPosition && (xy[1] >y && (xy[1] < (y + h)) && xy[0] > x && (xy[0] < (x + w)))) { match = true; break; }else if (pos == len -1 && currentPosition != len - 1) { diff --git a/bundles/AdminBundle/public/js/pimcore/object/tags/manyToOneRelation.js b/bundles/AdminBundle/public/js/pimcore/object/tags/manyToOneRelation.js index f2a2dcb266a..99139216c4d 100644 --- a/bundles/AdminBundle/public/js/pimcore/object/tags/manyToOneRelation.js +++ b/bundles/AdminBundle/public/js/pimcore/object/tags/manyToOneRelation.js @@ -205,6 +205,12 @@ pimcore.object.tags.manyToOneRelation = Class.create(pimcore.object.tags.abstrac pimcore.helpers.openElement(this.data.id, this.data.type, subtype); }.bind(this)); }.bind(this)); + this.component.on('afterrender', function (el) { + el.inputEl.setWidth(href.width); + el.inputEl.setStyle({ + 'overflow': 'hidden' + }); + }); var items = [this.component, { xtype: "button", diff --git a/bundles/AdminBundle/src/Controller/Admin/DataObject/ClassController.php b/bundles/AdminBundle/src/Controller/Admin/DataObject/ClassController.php index f570aa3a8cb..f5c4ce76371 100644 --- a/bundles/AdminBundle/src/Controller/Admin/DataObject/ClassController.php +++ b/bundles/AdminBundle/src/Controller/Admin/DataObject/ClassController.php @@ -470,6 +470,14 @@ public function saveAction(Request $request): JsonResponse $class->rename($values['name']); } + if ($values['compositeIndices']) { + foreach ($values['compositeIndices'] as $index => $compositeIndex) { + if ($compositeIndex['index_key'] !== ($sanitizedKey = preg_replace('/[^a-za-z0-9_\-+]/', '', $compositeIndex['index_key']))) { + $values['compositeIndices'][$index]['index_key'] = $sanitizedKey; + } + } + } + unset($values['creationDate']); unset($values['userOwner']); unset($values['layoutDefinitions']); diff --git a/bundles/CoreBundle/config/message_handler.yaml b/bundles/CoreBundle/config/message_handler.yaml index 8e3905ad291..aa86945f740 100644 --- a/bundles/CoreBundle/config/message_handler.yaml +++ b/bundles/CoreBundle/config/message_handler.yaml @@ -17,6 +17,7 @@ services: Pimcore\Messenger\Handler\AssetUpdateTasksHandler: arguments: - '@logger' + - '@Pimcore\Helper\LongRunningHelper' tags: - { name: messenger.message_handler } diff --git a/bundles/CustomReportsBundle/public/js/pimcore/report/custom/item.js b/bundles/CustomReportsBundle/public/js/pimcore/report/custom/item.js index 1b3838416d8..ddcddf4a0f8 100644 --- a/bundles/CustomReportsBundle/public/js/pimcore/report/custom/item.js +++ b/bundles/CustomReportsBundle/public/js/pimcore/report/custom/item.js @@ -934,12 +934,13 @@ pimcore.bundle.customreports.custom.item = Class.create({ }, saveOnComplete: function () { - this.parentPanel.tree.getStore().load(); pimcore.helpers.showNotification(t("success"), t("saved_successfully"), "success"); Ext.MessageBox.confirm(t("info"), t("reload_pimcore_changes"), function (buttonValue) { if (buttonValue == "yes") { window.location.reload(); + } else { + this.parentPanel.tree.getStore().load(); } }.bind(this)); } diff --git a/composer.json b/composer.json index a8c11670e45..8367884f1c2 100644 --- a/composer.json +++ b/composer.json @@ -152,7 +152,7 @@ "codeception/codeception": "^5.0.3", "codeception/module-symfony": "^3.1.0", "codeception/phpunit-wrapper": "^9", - "phpstan/phpstan": "1.9.17", + "phpstan/phpstan": "1.10.5", "phpstan/phpstan-symfony": "^1.2.20", "phpunit/phpunit": "^9.3", "gotenberg/gotenberg-php": "^1.1", diff --git a/doc/18_Tools_and_Features/02_Custom_Icons.md b/doc/18_Tools_and_Features/02_Custom_Icons.md index 2c8e2e5504f..d221e120886 100644 --- a/doc/18_Tools_and_Features/02_Custom_Icons.md +++ b/doc/18_Tools_and_Features/02_Custom_Icons.md @@ -13,7 +13,7 @@ be changed. The basic idea is to provide one's own implementation of `Pimcore\Model\Element\AdminStyle`. -This can be achieved by attaching a listener to the [`AdminEvents::RESOLVE_ELEMENT_ADMIN_STYLE`](https://github.com/pimcore/pimcore/blob/11.x/lib/Event/AdminEvents.php#L396-L407) event. +This can be achieved by attaching a listener to the [`AdminEvents::RESOLVE_ELEMENT_ADMIN_STYLE`](https://github.com/pimcore/pimcore/blob/11.x/bundles/AdminBundle/Event/AdminEvents.php#L396-L407) event. Example: diff --git a/doc/20_Extending_Pimcore/11_Event_API_and_Event_Manager.md b/doc/20_Extending_Pimcore/11_Event_API_and_Event_Manager.md index 03ab81dd51e..75877c683ef 100644 --- a/doc/20_Extending_Pimcore/11_Event_API_and_Event_Manager.md +++ b/doc/20_Extending_Pimcore/11_Event_API_and_Event_Manager.md @@ -33,7 +33,7 @@ All Pimcore events are defined and documented as a constant on component specifi - [Mail](https://github.com/pimcore/pimcore/blob/11.x/lib/Event/MailEvents.php) - [Notifications](https://github.com/pimcore/pimcore/blob/11.x/lib/Event/NotificationEvents.php) - [Redirect](https://github.com/pimcore/pimcore/blob/11.x/lib/Event/RedirectEvents.php) -- [Admin](https://github.com/pimcore/pimcore/blob/11.x/lib/Event/AdminEvents.php) +- [Admin](https://github.com/pimcore/pimcore/blob/11.x/bundles/AdminBundle/Event/AdminEvents.php) - [Frontend](https://github.com/pimcore/pimcore/blob/11.x/lib/Event/FrontendEvents.php) - [Cache](https://github.com/pimcore/pimcore/blob/11.x/lib/Event/CoreCacheEvents.php) - [Full-Page Cache](https://github.com/pimcore/pimcore/blob/11.x/lib/Event/FullPageCacheEvents.php) @@ -104,7 +104,7 @@ To ensure maximum security, it is advisable to combine this with an object DI to ### Hook into the Open Document|Asset|Data Object dialog By the default, Pimcore tries to a resolve an element by its ID or path. -You can change this behavior by handling the [AdminEvents::RESOLVE_ELEMENT](https://github.com/pimcore/pimcore/blob/11.x/lib/Event/AdminEvents.php) event +You can change this behavior by handling the [AdminEvents::RESOLVE_ELEMENT](https://github.com/pimcore/pimcore/blob/11.x/bundles/AdminBundle/Event/AdminEvents.php) event and implement your own logic. ```php @@ -161,3 +161,4 @@ into the /news/in-enim-justo_2/image_1 asset folder. } }); ``` + diff --git a/doc/26_Best_Practice/60_Modifying_Permissions_based_on_Object_Data.md b/doc/26_Best_Practice/60_Modifying_Permissions_based_on_Object_Data.md index 824788b182b..f5a620e3a33 100644 --- a/doc/26_Best_Practice/60_Modifying_Permissions_based_on_Object_Data.md +++ b/doc/26_Best_Practice/60_Modifying_Permissions_based_on_Object_Data.md @@ -1,6 +1,6 @@ # Modifying Permissions based on Object Data -The event [`OBJECT_GET_PRE_SEND_DATA`](https://github.com/pimcore/pimcore/blob/11.x/lib/Event/AdminEvents.php#L292-L304) +The event [`OBJECT_GET_PRE_SEND_DATA`](https://github.com/pimcore/pimcore/blob/11.x/bundles/AdminBundle/Event/AdminEvents.php#L292-L304) can be used to manipulate the server response before object data is sent to Pimcore Backend UI when opening the detail view of an Pimcore object. diff --git a/lib/Console/ConsoleCommandPluginTrait.php b/lib/Console/ConsoleCommandPluginTrait.php index 5261858af07..1d9725deb81 100644 --- a/lib/Console/ConsoleCommandPluginTrait.php +++ b/lib/Console/ConsoleCommandPluginTrait.php @@ -20,6 +20,11 @@ use Pimcore\Event\SystemEvents; use Symfony\Component\Console\Command\Command; +trigger_deprecation('pimcore/pimcore', '10.6', 'The "%s" trait is deprecated and will be removed in Pimcore 11.', ConsoleCommandPluginTrait::class); + +/** + * @deprecated since Pimcore 10.6 and will be removed in Pimcore 11 + */ trait ConsoleCommandPluginTrait { /** diff --git a/lib/Event/Admin/ElementAdminStyleEvent.php b/lib/Event/Admin/ElementAdminStyleEvent.php index df34185ba53..9693dfcbc91 100644 --- a/lib/Event/Admin/ElementAdminStyleEvent.php +++ b/lib/Event/Admin/ElementAdminStyleEvent.php @@ -17,79 +17,9 @@ namespace Pimcore\Event\Admin; -use Pimcore\Model\Element\AdminStyle; -use Pimcore\Model\Element\ElementInterface; -use Symfony\Contracts\EventDispatcher\Event; - -class ElementAdminStyleEvent extends Event +/** + * @deprecated and will be removed in Pimcore 11. Use Pimcore\Bundle\AdminBundle\Event\ElementAdminStyleEvent instead + */ +class ElementAdminStyleEvent extends \Pimcore\Bundle\AdminBundle\Event\ElementAdminStyleEvent { - /** - * Style needed for tree - */ - const CONTEXT_TREE = 1; - - /** - * Style needed for element editor - */ - const CONTEXT_EDITOR = 2; - - /** - * Style needed for quicksearch - */ - const CONTEXT_SEARCH = 3; - - protected ?int $context = null; - - protected ElementInterface $element; - - protected AdminStyle $adminStyle; - - /** - * ElementAdminStyleEvent constructor. - * - * @param ElementInterface $element - * @param AdminStyle $adminStyle - * @param int|null $context - */ - public function __construct(ElementInterface $element, AdminStyle $adminStyle, int $context = null) - { - $this->element = $element; - $this->adminStyle = $adminStyle; - $this->context = $context; - } - - public function getElement(): ElementInterface - { - return $this->element; - } - - public function setElement(ElementInterface $element): void - { - $this->element = $element; - } - - public function getAdminStyle(): AdminStyle - { - return $this->adminStyle; - } - - public function setAdminStyle(AdminStyle $adminStyle): void - { - $this->adminStyle = $adminStyle; - } - - /** - * Returns the context. e.g. CONTEXT_TREE or CONTEXT_EDITOR. - * - * @return null|int - */ - public function getContext(): ?int - { - return $this->context; - } - - public function setContext(?int $context): void - { - $this->context = $context; - } } diff --git a/lib/Event/Admin/IndexActionSettingsEvent.php b/lib/Event/Admin/IndexActionSettingsEvent.php index f0410d6f1c6..882ca884c7c 100644 --- a/lib/Event/Admin/IndexActionSettingsEvent.php +++ b/lib/Event/Admin/IndexActionSettingsEvent.php @@ -17,29 +17,9 @@ namespace Pimcore\Event\Admin; -use Symfony\Contracts\EventDispatcher\Event; - -class IndexActionSettingsEvent extends Event +/** + * @deprecated and will be removed in Pimcore 11. Use Pimcore\Bundle\AdminBundle\Event\IndexActionSettingsEvent instead + */ +class IndexActionSettingsEvent extends \Pimcore\Bundle\AdminBundle\Event\IndexActionSettingsEvent { - private array $settings; - - public function __construct(array $settings) - { - $this->settings = $settings; - } - - public function getSettings(): array - { - return $this->settings; - } - - public function setSettings(array $settings): void - { - $this->settings = $settings; - } - - public function addSetting(string $key, mixed $value): void - { - $this->settings[$key] = $value; - } } diff --git a/lib/Event/Admin/Login/LoginCredentialsEvent.php b/lib/Event/Admin/Login/LoginCredentialsEvent.php index 99753099ff0..40a2be19d15 100644 --- a/lib/Event/Admin/Login/LoginCredentialsEvent.php +++ b/lib/Event/Admin/Login/LoginCredentialsEvent.php @@ -16,29 +16,9 @@ namespace Pimcore\Event\Admin\Login; -use Pimcore\Event\Traits\RequestAwareTrait; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Contracts\EventDispatcher\Event; - -class LoginCredentialsEvent extends Event +/** + * @deprecated and will be removed in Pimcore 11. Use Pimcore\Bundle\AdminBundle\Event\Login\LoginCredentialsEvent instead + */ +class LoginCredentialsEvent extends \Pimcore\Bundle\AdminBundle\Event\Login\LoginCredentialsEvent { - use RequestAwareTrait; - - protected array $credentials; - - public function __construct(Request $request, array $credentials) - { - $this->request = $request; - $this->credentials = $credentials; - } - - public function getCredentials(): array - { - return $this->credentials; - } - - public function setCredentials(array $credentials): void - { - $this->credentials = $credentials; - } } diff --git a/lib/Event/Admin/Login/LoginFailedEvent.php b/lib/Event/Admin/Login/LoginFailedEvent.php index 6451cb2f685..787324c63de 100644 --- a/lib/Event/Admin/Login/LoginFailedEvent.php +++ b/lib/Event/Admin/Login/LoginFailedEvent.php @@ -16,57 +16,9 @@ namespace Pimcore\Event\Admin\Login; -use Pimcore\Model\User; -use Symfony\Contracts\EventDispatcher\Event; - -class LoginFailedEvent extends Event +/** + * @deprecated and will be removed in Pimcore 11. Use Pimcore\Bundle\AdminBundle\Event\Login\LoginFailedEvent instead + */ +class LoginFailedEvent extends \Pimcore\Bundle\AdminBundle\Event\Login\LoginFailedEvent { - protected array $credentials; - - protected ?User $user = null; - - public function __construct(array $credentials) - { - $this->credentials = $credentials; - } - - public function getCredentials(): array - { - return $this->credentials; - } - - /** - * @param string $name - * @param mixed $default - * - * @return mixed - */ - public function getCredential(string $name, mixed $default = null): mixed - { - if (isset($this->credentials[$name])) { - return $this->credentials[$name]; - } - - return $default; - } - - public function getUser(): ?User - { - return $this->user; - } - - /** - * @return $this - */ - public function setUser(User $user): static - { - $this->user = $user; - - return $this; - } - - public function hasUser(): bool - { - return null !== $this->user; - } } diff --git a/lib/Event/Admin/Login/LoginRedirectEvent.php b/lib/Event/Admin/Login/LoginRedirectEvent.php index cb3f1b9e908..dff8e90b98a 100644 --- a/lib/Event/Admin/Login/LoginRedirectEvent.php +++ b/lib/Event/Admin/Login/LoginRedirectEvent.php @@ -1,5 +1,4 @@ routeName = $routeName; - $this->routeParams = $routeParams; - } - - public function getRouteName(): string - { - return $this->routeName; - } - - public function setRouteName(string $routeName): void - { - $this->routeName = $routeName; - } - - public function getRouteParams(): array - { - return $this->routeParams; - } - - public function setRouteParams(array $routeParams): void - { - $this->routeParams = $routeParams; - } } diff --git a/lib/Event/Admin/Login/LogoutEvent.php b/lib/Event/Admin/Login/LogoutEvent.php index 77523aea642..4a8aecc728f 100644 --- a/lib/Event/Admin/Login/LogoutEvent.php +++ b/lib/Event/Admin/Login/LogoutEvent.php @@ -16,27 +16,9 @@ namespace Pimcore\Event\Admin\Login; -use Pimcore\Event\Traits\RequestAwareTrait; -use Pimcore\Event\Traits\ResponseAwareTrait; -use Pimcore\Model\User; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Contracts\EventDispatcher\Event; - -class LogoutEvent extends Event +/** + * @deprecated and will be removed in Pimcore 11. Use Pimcore\Bundle\AdminBundle\Event\Login\LogoutEvent instead + */ +class LogoutEvent extends \Pimcore\Bundle\AdminBundle\Event\Login\LogoutEvent { - use RequestAwareTrait; - use ResponseAwareTrait; - - protected User $user; - - public function __construct(Request $request, User $user) - { - $this->request = $request; - $this->user = $user; - } - - public function getUser(): User - { - return $this->user; - } } diff --git a/lib/Event/Admin/Login/LostPasswordEvent.php b/lib/Event/Admin/Login/LostPasswordEvent.php index 0be0067b63a..eaa4a9955bd 100644 --- a/lib/Event/Admin/Login/LostPasswordEvent.php +++ b/lib/Event/Admin/Login/LostPasswordEvent.php @@ -16,57 +16,9 @@ namespace Pimcore\Event\Admin\Login; -use Pimcore\Event\Traits\ResponseAwareTrait; -use Pimcore\Model\User; -use Symfony\Contracts\EventDispatcher\Event; - -class LostPasswordEvent extends Event +/** + * @deprecated and will be removed in Pimcore 11. Use Pimcore\Bundle\AdminBundle\Event\Login\LostPasswordEvent instead + */ +class LostPasswordEvent extends \Pimcore\Bundle\AdminBundle\Event\Login\LostPasswordEvent { - use ResponseAwareTrait; - - protected User $user; - - protected string $loginUrl; - - protected bool $sendMail = true; - - public function __construct(User $user, string $loginUrl) - { - $this->user = $user; - $this->loginUrl = $loginUrl; - } - - public function getUser(): User - { - return $this->user; - } - - public function getLoginUrl(): string - { - return $this->loginUrl; - } - - /** - * Determines if lost password mail should be sent - * - * @return bool - */ - public function getSendMail(): bool - { - return $this->sendMail; - } - - /** - * Sets flag whether to send lost password mail or not - * - * @param bool $sendMail - * - * @return $this - */ - public function setSendMail(bool $sendMail): static - { - $this->sendMail = (bool)$sendMail; - - return $this; - } } diff --git a/lib/Event/AdminEvents.php b/lib/Event/AdminEvents.php index 1aca46f40f1..a3e8c5d23f0 100644 --- a/lib/Event/AdminEvents.php +++ b/lib/Event/AdminEvents.php @@ -16,544 +16,9 @@ namespace Pimcore\Event; -final class AdminEvents +/** + * @deprecated and will be removed in Pimcore 11. Use Pimcore\Bundle\AdminBundle\Event\AdminEvents instead + */ +final class AdminEvents extends \Pimcore\Bundle\AdminBundle\Event\AdminEvents { - /** - * The LOGIN_REDIRECT event is triggered before user is redirected to login page. - * - * This event allows you to influence path of the login page, e.g. for SSO integrations. - * - * @Event("Pimcore\Event\Admin\Login\LoginRedirectEvent") - * - * @var string - */ - const LOGIN_REDIRECT = 'pimcore.admin.login.redirect'; - - /** - * The LOGIN_LOSTPASSWORD event is triggered before the lost password email - * is sent. - * - * This event allows you to alter the lost password mail or to prevent - * mail sending at all. For full control, it allows you to set the response - * to be returned. - * - * @Event("Pimcore\Event\Admin\Login\LostPasswordEvent") - * - * @var string - */ - const LOGIN_LOSTPASSWORD = 'pimcore.admin.login.lostpassword'; - - /** - * The LOGIN_LOGOUT event is triggered before the user is logged out. - * - * By setting a response on the event, you're able to control the response - * returned after logout. - * - * @Event("Pimcore\Event\Admin\Login\LogoutEvent") - * - * @var string - */ - 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. - * - * @Event("Pimcore\Event\Admin\IndexActionSettingsEvent") - * - * @var string - */ - 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. - * - * Subject: \Pimcore\Bundle\AdminBundle\Controller\Searchadmin\SearchController - * Arguments: - * - requestParams | contains the request parameters - * - * @Event("Symfony\Component\EventDispatcher\GenericEvent") - * - * @var string - */ - const SEARCH_LIST_BEFORE_FILTER_PREPARE = 'pimcore.admin.search.list.beforeFilterPrepare'; - - /** - * Allows you to modify the search backend list before it is loaded. - * - * Subject: \Pimcore\Bundle\AdminBundle\Controller\Searchadmin\SearchController - * Arguments: - * - list | the search backend list - * - context | contains contextual information - * - * @Event("Symfony\Component\EventDispatcher\GenericEvent") - * - * @var string - */ - const SEARCH_LIST_BEFORE_LIST_LOAD = 'pimcore.admin.search.list.beforeListLoad'; - - /** - * Allows you to modify the the result after the list was loaded. - * - * Subject: \Pimcore\Bundle\AdminBundle\Controller\Searchadmin\SearchController - * Arguments: - * - list | raw result as an array - * - context | contains contextual information - * - * @Event("Symfony\Component\EventDispatcher\GenericEvent") - * - * @var string - */ - const SEARCH_LIST_AFTER_LIST_LOAD = 'pimcore.admin.search.list.afterListLoad'; - - /** - * Fired before the request params are parsed. This event apply to the grid list. - * - * Subject: A controller extending \Pimcore\Bundle\AdminBundle\Controller\AdminController - * Arguments: - * - requestParams | contains the request parameters - * - * @Event("Symfony\Component\EventDispatcher\GenericEvent") - * - * @var string - */ - const OBJECT_LIST_BEFORE_FILTER_PREPARE = 'pimcore.admin.object.list.beforeFilterPrepare'; - - /** - * Allows you to modify the object list before it is loaded. This is a global event (search list, grid list, tree list, ...). - * - * Subject: A controller extending \Pimcore\Bundle\AdminBundle\Controller\AdminController - * Arguments: - * - list | the object list - * - context | contains contextual information - * - * @Event("Symfony\Component\EventDispatcher\GenericEvent") - * - * @var string - */ - const OBJECT_LIST_BEFORE_LIST_LOAD = 'pimcore.admin.object.list.beforeListLoad'; - - /** - * Allows you to modify the object list before it is prepared for export. - * - * Subject: A controller extending \Pimcore\Bundle\AdminBundle\Controller\AdminController - * Arguments: - * - list | the object list - * - context | contains contextual information - * - * @Event("Symfony\Component\EventDispatcher\GenericEvent") - * - * @var string - */ - const OBJECT_LIST_BEFORE_EXPORT_PREPARE = 'pimcore.admin.object.list.beforeExportPrepare'; - - /** - * Allows you to modify the object list before it is exported. - * - * Subject: A controller extending \Pimcore\Bundle\AdminBundle\Controller\AdminController - * Arguments: - * - list | the object list - * - context | contains contextual information - * - * @Event("Symfony\Component\EventDispatcher\GenericEvent") - * - * @var string - */ - const OBJECT_LIST_BEFORE_EXPORT = 'pimcore.admin.object.list.beforeExport'; - - /** - * Allows you to modify the the result after the list was loaded. This event apply to the grid list. - * - * Subject: A controller extending \Pimcore\Bundle\AdminBundle\Controller\AdminController - * Arguments: - * - list | raw result as an array - * - context | contains contextual information - * - * @Event("Symfony\Component\EventDispatcher\GenericEvent") - * - * @var string - */ - const OBJECT_LIST_AFTER_LIST_LOAD = 'pimcore.admin.object.list.afterListLoad'; - - /** - * Fired before the request params are parsed. This event apply to both the folder content preview list and the grid list. - * - * Subject: A controller extending \Pimcore\Bundle\AdminBundle\Controller\AdminController - * Arguments: - * - requestParams | contains the request parameters - * - * @Event("Symfony\Component\EventDispatcher\GenericEvent") - * - * @var string - */ - const ASSET_LIST_BEFORE_FILTER_PREPARE = 'pimcore.admin.asset.list.beforeFilterPrepare'; - - /** - * Allows you to modify the asset list before it is loaded. This is a global event (folder content preview list, grid list, tree list, ...). - * - * Subject: A controller extending \Pimcore\Bundle\AdminBundle\Controller\AdminController - * Arguments: - * - list | the object list - * - context | contains contextual information - * - * @Event("Symfony\Component\EventDispatcher\GenericEvent") - * - * @var string - */ - const ASSET_LIST_BEFORE_LIST_LOAD = 'pimcore.admin.asset.list.beforeListLoad'; - - /** - * Arguments: - * - field - * - language - * - keyPrefix - * - processed - * - result - * - * @Event("Symfony\Component\EventDispatcher\GenericEvent") - * - * @var string - */ - const ASSET_GET_FIELD_GRID_CONFIG = 'pimcore.admin.asset.getFieldGridConfig'; - - /** - * Allows you to modify the the result after the list was loaded. This event apply to both the folder content preview list and the grid list. - * - * Subject: A controller extending \Pimcore\Bundle\AdminBundle\Controller\AdminController - * Arguments: - * - list | raw result as an array - * - context | contains contextual information - * - * @Event("Symfony\Component\EventDispatcher\GenericEvent") - * - * @var string - */ - const ASSET_LIST_AFTER_LIST_LOAD = 'pimcore.admin.asset.list.afterListLoad'; - - /** - * Allows you to modify the data from the listfolder grid before it gets processed - * - * Subject: A controller extending \Pimcore\Bundle\AdminBundle\Controller\AdminController - * Arguments: - * - data | raw data as an array - * - processed | true to stop processing - * - * @Event("Symfony\Component\EventDispatcher\GenericEvent") - * - * @var string - */ - const ASSET_LIST_BEFORE_UPDATE = 'pimcore.admin.asset.list.beforeUpdate'; - - /** - * Allows you to modify the batch update data from the listfolder grid before it gets processed - * - * Subject: A controller extending \Pimcore\Bundle\AdminBundle\Controller\AdminController - * Arguments: - * - params | - * - processed | true to stop processing - * - * @Event("Symfony\Component\EventDispatcher\GenericEvent") - * - * @var string - */ - const ASSET_LIST_BEFORE_BATCH_UPDATE = 'pimcore.admin.asset.list.beforeBatchUpdate'; - - /** - * Fired before the request params are parsed. This event apply to the seo panel tree. - * - * Subject: A controller extending \Pimcore\Bundle\AdminBundle\Controller\AdminController - * Arguments: - * - requestParams | contains the request parameters - * - * @Event("Symfony\Component\EventDispatcher\GenericEvent") - * - * @var string - */ - const DOCUMENT_LIST_BEFORE_FILTER_PREPARE = 'pimcore.admin.document.list.beforeFilterPrepare'; - - /** - * Allows you to modify the document list before it is loaded. This is a global event (seo panel tree, tree list, ...). - * - * Subject: A controller extending \Pimcore\Bundle\AdminBundle\Controller\AdminController - * Arguments: - * - list | the object list - * - context | contains contextual information - * - * @Event("Symfony\Component\EventDispatcher\GenericEvent") - * - * @var string - */ - const DOCUMENT_LIST_BEFORE_LIST_LOAD = 'pimcore.admin.document.list.beforeListLoad'; - - /** - * Allows you to modify the the result after the list was loaded. This event apply to the seo panel tree. - * - * Subject: A controller extending \Pimcore\Bundle\AdminBundle\Controller\AdminController - * Arguments: - * - list | raw result as an array - * - context | contains contextual information - * - * @Event("Symfony\Component\EventDispatcher\GenericEvent") - * - * @var string - */ - const DOCUMENT_LIST_AFTER_LIST_LOAD = 'pimcore.admin.document.list.afterListLoad'; - - /** - * Fired before the request params are parsed. - * - * Subject: \Pimcore\Bundle\AdminBundle\Controller\Admin\Asset\AssetController - * Arguments: - * - data | array | the response data, this can be modified - * - asset | Asset | the current asset - * - * @Event("Symfony\Component\EventDispatcher\GenericEvent") - * - * @var string - */ - const ASSET_GET_PRE_SEND_DATA = 'pimcore.admin.asset.get.preSendData'; - - /** - * Subject: \Pimcore\Bundle\AdminBundle\Controller\Admin\Asset\AssetController - * Arguments: - * - assets | array | the list of asset tree nodes - * - * @Event("Symfony\Component\EventDispatcher\GenericEvent") - * - * @var string - */ - const ASSET_TREE_GET_CHILDREN_BY_ID_PRE_SEND_DATA = 'pimcore.admin.asset.treeGetChildrenById.preSendData'; - - /** - * Fired before the request params are parsed. - * - * Subject: \Pimcore\Bundle\AdminBundle\Controller\Admin\ElementControllerBase - * Arguments: - * - data | array | the response data, this can be modified - * - document | Document | the current document - * - * @Event("Symfony\Component\EventDispatcher\GenericEvent") - * - * @var string - */ - const DOCUMENT_GET_PRE_SEND_DATA = 'pimcore.admin.document.get.preSendData'; - - /** - * Subject: \Pimcore\Bundle\AdminBundle\Controller\Admin\DocumentController - * Arguments: - * - documents | array | the list of document tree nodes - * - * @Event("Symfony\Component\EventDispatcher\GenericEvent") - * - * @var string - */ - const DOCUMENT_TREE_GET_CHILDREN_BY_ID_PRE_SEND_DATA = 'pimcore.admin.document.treeGetChildrenById.preSendData'; - - /** - * Fired before the request params are parsed. - * - * Subject: \Pimcore\Bundle\AdminBundle\Controller\Admin\DataObjectController - * Arguments: - * - data | array | the response data, this can be modified - * - object | AbstractObject | the current object - * - * @Event("Symfony\Component\EventDispatcher\GenericEvent") - * - * @var string - */ - const OBJECT_GET_PRE_SEND_DATA = 'pimcore.admin.dataobject.get.preSendData'; - - /** - * Subject: \Pimcore\Bundle\AdminBundle\Controller\Admin\DataObject\DataObjectHelperController - * Arguments: - * - data | array | the response data which this can be modified - * - request | Request | the Request object passed to the action - * - config | Config | the Config object passed to the action - * - context | string | 'get' or 'delete' - * - * @Event("Symfony\Component\EventDispatcher\GenericEvent") - * - * @var string - */ - const OBJECT_GRID_GET_COLUMN_CONFIG_PRE_SEND_DATA = 'pimcore.admin.dataobject.gridGetColumnConfig.preSendData'; - - /** - * Subject: \Pimcore\Bundle\AdminBundle\Controller\Admin\DataObjectController - * Arguments: - * - objects | array | the list of object tree nodes - * - * @Event("Symfony\Component\EventDispatcher\GenericEvent") - * - * @var string - */ - const OBJECT_TREE_GET_CHILDREN_BY_ID_PRE_SEND_DATA = 'pimcore.admin.dataobject.treeGetChildrenById.preSendData'; - - /** - * Subject: \Pimcore\Bundle\AdminBundle\Controller\Admin\ClassController - * Arguments: - * - list | array | the list of field collections - * - objectId | int | id of the origin object - * - * @Event("Symfony\Component\EventDispatcher\GenericEvent") - * - * @var string - */ - const CLASS_FIELDCOLLECTION_LIST_PRE_SEND_DATA = 'pimcore.admin.class.fieldcollectionList.preSendData'; - - /** - * Subject: \Pimcore\Bundle\AdminBundle\Controller\Admin\ClassController - * Arguments: - * - icons | array | the list of selectable icons - * - classId | string | classid of class definition - * - * @Event("Symfony\Component\EventDispatcher\GenericEvent") - * - * @var string - */ - const CLASS_OBJECT_ICONS_PRE_SEND_DATA = 'pimcore.admin.class.dataobject.preSendData'; - - /** - * Subject: \Pimcore\Bundle\AdminBundle\Controller\Admin\ClassController - * Arguments: - * - list | array | the list of object bricks - * - objectId | int | id of the origin object - * - * @Event("Symfony\Component\EventDispatcher\GenericEvent") - * - * @var string - */ - const CLASS_OBJECTBRICK_LIST_PRE_SEND_DATA = 'pimcore.admin.class.objectbrickList.preSendData'; - - /** - * Subject: \Pimcore\Bundle\AdminBundle\Controller\Admin\ClassController - * Arguments: - * - brickDefinition | the brick definition - * - * @Event("Symfony\Component\EventDispatcher\GenericEvent") - * - * @var string - */ - const CLASS_OBJECTBRICK_UPDATE_DEFINITION = 'pimcore.admin.class.objectbrick.updateDefinition'; - - /** - * Allows you to modify the search backend list before it is loaded. - * - * Subject: \Pimcore\Bundle\AdminBundle\Controller\Searchadmin\SearchController - * Arguments: - * - list | the search backend list - * - context | contains contextual information - * - * @Event("Symfony\Component\EventDispatcher\GenericEvent") - * - * @var string - */ - const QUICKSEARCH_LIST_BEFORE_LIST_LOAD = 'pimcore.admin.quickSearch.list.beforeListLoad'; - - /** - * Allows you to modify the the result after the list was loaded. - * - * Subject: \Pimcore\Bundle\AdminBundle\Controller\Searchadmin\SearchController - * Arguments: - * - list | raw result as an array - * - context | contains contextual information - * - * @Event("Symfony\Component\EventDispatcher\GenericEvent") - * - * @var string - */ - const QUICKSEARCH_LIST_AFTER_LIST_LOAD = 'pimcore.admin.quickSearch.list.afterListLoad'; - - /** - * Fired before the an element is opened - * - * Subject: \Pimcore\Bundle\AdminBundle\Controller\Admin\ElementController - * Arguments: - * - type element type - * - id - * - * @Event("Pimcore\Event\Model\ResolveElementEvent") - * - * @var string - */ - const RESOLVE_ELEMENT = 'pimcore.admin.resolve.element'; - - /** - * Fired before the an element is opened - * - * Subject: \Pimcore\Bundle\AdminBundle\Controller\Admin\ElementController - * Arguments: - * none - * - * @Event("Pimcore\Event\Admin\ElementAdminStyleEvent") - * - * @var string - */ - const RESOLVE_ELEMENT_ADMIN_STYLE = 'pimcore.admin.resolve.elementAdminStyle'; - - /** - * Allows you to modify whether a permission on an element is granted or not - * - * Subject: \Pimcore\Model\Element\AbstractElement - * Arguments: - * - isAllowed | bool | the original "isAllowed" value as determined by pimcore. This can be modfied - * - permissionType | string | the permission that is checked - * - user | \Pimcore\Model\User | user the permission is checked for - * - * @Event("Pimcore\Event\Model\ElementEvent") - * - * @var string - */ - const ELEMENT_PERMISSION_IS_ALLOWED = 'pimcore.admin.permissions.elementIsAllowed'; - - /** - * Subject: \Pimcore\Bundle\AdminBundle\Controller\Admin\Asset\AssetController - * Arguments: - * - id | int | asset id - * - metadata | array | contains the data received from the editor UI - * - * @Event("Symfony\Component\EventDispatcher\GenericEvent") - * - * @var string - */ - const ASSET_METADATA_PRE_SET = 'pimcore.admin.asset.metadata.preSave'; - - /** - * This event is fired after Pimcore generates the runtime Perspective - * - * Arguments: - * - result | The result array - * - configName | Name of the current perspective - * - * @Event("Symfony\Component\EventDispatcher\GenericEvent") - * - * @var string - */ - public const PERSPECTIVE_POST_GET_RUNTIME = 'pimcore.admin.perspective.postGetRuntime'; } diff --git a/lib/Event/Model/AssetDeleteInfoEvent.php b/lib/Event/Model/AssetDeleteInfoEvent.php index d7c9ef0230e..76391e02325 100644 --- a/lib/Event/Model/AssetDeleteInfoEvent.php +++ b/lib/Event/Model/AssetDeleteInfoEvent.php @@ -16,14 +16,13 @@ namespace Pimcore\Event\Model; -use Pimcore\Event\Traits\ElementDeleteInfoEventTrait; - /** * Class AssetDeleteInfoEvent * * @package Pimcore\Event\Model + * + * @deprecated and will be removed in Pimcore 11. Use Pimcore\Bundle\AdminBundle\Event\Model\AssetDeleteInfoEvent instead */ -class AssetDeleteInfoEvent extends AssetEvent implements ElementDeleteInfoEventInterface +class AssetDeleteInfoEvent extends \Pimcore\Bundle\AdminBundle\Event\Model\AssetDeleteInfoEvent { - use ElementDeleteInfoEventTrait; } diff --git a/lib/Event/Model/DataObjectDeleteInfoEvent.php b/lib/Event/Model/DataObjectDeleteInfoEvent.php index 246cd64d874..61910d89b9f 100644 --- a/lib/Event/Model/DataObjectDeleteInfoEvent.php +++ b/lib/Event/Model/DataObjectDeleteInfoEvent.php @@ -16,14 +16,13 @@ namespace Pimcore\Event\Model; -use Pimcore\Event\Traits\ElementDeleteInfoEventTrait; - /** * Class DataObjectDeleteInfoEvent * * @package Pimcore\Event\Model + * + * @deprecated and will be removed in Pimcore 11. Use Pimcore\Bundle\AdminBundle\Event\Model\DataObjectDeleteInfoEvent instead */ -class DataObjectDeleteInfoEvent extends DataObjectEvent implements ElementDeleteInfoEventInterface +class DataObjectDeleteInfoEvent extends \Pimcore\Bundle\AdminBundle\Event\Model\DataObjectDeleteInfoEvent { - use ElementDeleteInfoEventTrait; } diff --git a/lib/Event/Model/DocumentDeleteInfoEvent.php b/lib/Event/Model/DocumentDeleteInfoEvent.php index 481f6a520b2..bf2c8106bda 100644 --- a/lib/Event/Model/DocumentDeleteInfoEvent.php +++ b/lib/Event/Model/DocumentDeleteInfoEvent.php @@ -16,14 +16,13 @@ namespace Pimcore\Event\Model; -use Pimcore\Event\Traits\ElementDeleteInfoEventTrait; - /** * Class DocumentDeleteInfoEvent * * @package Pimcore\Event\Model + * + * @deprecated and will be removed in Pimcore 11. Use Pimcore\Bundle\AdminBundle\Event\Model\DocumentDeleteInfoEvent instead */ -class DocumentDeleteInfoEvent extends DocumentEvent implements ElementDeleteInfoEventInterface +class DocumentDeleteInfoEvent extends \Pimcore\Bundle\AdminBundle\Event\Model\DocumentDeleteInfoEvent { - use ElementDeleteInfoEventTrait; } diff --git a/lib/Event/Model/ElementDeleteInfoEventInterface.php b/lib/Event/Model/ElementDeleteInfoEventInterface.php index 220f218665c..c36c8ebbd13 100644 --- a/lib/Event/Model/ElementDeleteInfoEventInterface.php +++ b/lib/Event/Model/ElementDeleteInfoEventInterface.php @@ -16,13 +16,9 @@ namespace Pimcore\Event\Model; -interface ElementDeleteInfoEventInterface extends ElementEventInterface +/** + * @deprecated and will be removed in Pimcore 11. Use Pimcore\Bundle\AdminBundle\Event\Model\ElementDeleteInfoEventInterface instead + */ +interface ElementDeleteInfoEventInterface extends \Pimcore\Bundle\AdminBundle\Event\Model\ElementDeleteInfoEventInterface { - public function getDeletionAllowed(): bool; - - public function setDeletionAllowed(bool $deletionAllowed): void; - - public function getReason(): string; - - public function setReason(string $reason): void; } diff --git a/lib/Event/Traits/ElementDeleteInfoEventTrait.php b/lib/Event/Traits/ElementDeleteInfoEventTrait.php index ad5004d0498..0bf83fb06f7 100644 --- a/lib/Event/Traits/ElementDeleteInfoEventTrait.php +++ b/lib/Event/Traits/ElementDeleteInfoEventTrait.php @@ -20,30 +20,10 @@ * Trait ElementDeleteInfoEventTrait * * @package Pimcore\Event\Traits + * + * @deprecated and will be removed in Pimcore 11. Use Pimcore\Bundle\AdminBundle\Event\Traits\ElementDeleteInfoEventTrait instead */ trait ElementDeleteInfoEventTrait { - protected bool $deletionAllowed = true; - - protected string $reason; - - public function getDeletionAllowed(): bool - { - return $this->deletionAllowed; - } - - public function setDeletionAllowed(bool $deletionAllowed): void - { - $this->deletionAllowed = $deletionAllowed; - } - - public function getReason(): string - { - return $this->reason; - } - - public function setReason(string $reason): void - { - $this->reason = $reason; - } + use \Pimcore\Bundle\AdminBundle\Event\Traits\ElementDeleteInfoEventTrait; } diff --git a/lib/Messenger/Handler/AssetUpdateTasksHandler.php b/lib/Messenger/Handler/AssetUpdateTasksHandler.php index 98a9aec627d..aaef20cad4b 100644 --- a/lib/Messenger/Handler/AssetUpdateTasksHandler.php +++ b/lib/Messenger/Handler/AssetUpdateTasksHandler.php @@ -16,6 +16,7 @@ namespace Pimcore\Messenger\Handler; +use Pimcore\Helper\LongRunningHelper; use Pimcore\Messenger\AssetUpdateTasksMessage; use Pimcore\Model\Asset; use Pimcore\Model\Version; @@ -26,7 +27,7 @@ */ class AssetUpdateTasksHandler { - public function __construct(protected LoggerInterface $logger) + public function __construct(protected LoggerInterface $logger, protected LongRunningHelper $longRunningHelper) { } @@ -47,6 +48,8 @@ public function __invoke(AssetUpdateTasksMessage $message): void } elseif ($asset instanceof Asset\Video) { $this->processVideo($asset); } + + $this->longRunningHelper->deleteTemporaryFiles(); } private function saveAsset(Asset $asset): void diff --git a/models/DataObject/ClassDefinition/Dao.php b/models/DataObject/ClassDefinition/Dao.php index 867e6050aad..f7d1d23716c 100644 --- a/models/DataObject/ClassDefinition/Dao.php +++ b/models/DataObject/ClassDefinition/Dao.php @@ -146,6 +146,7 @@ public function update(): void `position` varchar(70) NOT NULL DEFAULT '0', INDEX `forward_lookup` (`src_id`, `ownertype`, `ownername`, `position`), INDEX `reverse_lookup` (`dest_id`, `type`), + INDEX `fieldname` (`fieldname`), CONSTRAINT `".self::getForeignKeyName($objectDatastoreTableRelation, 'src_id').'` FOREIGN KEY (`src_id`) REFERENCES objects (`id`) ON DELETE CASCADE ) DEFAULT CHARSET=utf8mb4;'); diff --git a/models/DataObject/ClassDefinition/Data/Input.php b/models/DataObject/ClassDefinition/Data/Input.php index 26c024de6e4..eb96cb87226 100644 --- a/models/DataObject/ClassDefinition/Data/Input.php +++ b/models/DataObject/ClassDefinition/Data/Input.php @@ -226,7 +226,19 @@ public function getQueryColumnType(): string public function checkValidity(mixed $data, bool $omitMandatoryCheck = false, array $params = []): void { if (!$omitMandatoryCheck && $this->getRegex() && is_string($data) && strlen($data) > 0) { - if (!preg_match('#' . $this->getRegex() . '#' . implode('', $this->getRegexFlags()), $data)) { + $throwException = false; + if (in_array('g', $this->getRegexFlags())) { + $flags = str_replace('g', '', implode('', $this->getRegexFlags())); + if (!preg_match_all('#' . $this->getRegex() . '#' . $flags, $data)) { + $throwException = true; + } + } else { + if (!preg_match('#' . $this->getRegex() . '#' . implode('', $this->getRegexFlags()), $data)) { + $throwException = true; + } + } + + if ($throwException) { throw new Model\Element\ValidationException('Value in field [ ' . $this->getName() . " ] doesn't match input validation '" . $this->getRegex() . "'"); } } diff --git a/models/DataObject/Fieldcollection/Definition.php b/models/DataObject/Fieldcollection/Definition.php index b7060590800..fe1ffbbdcbc 100644 --- a/models/DataObject/Fieldcollection/Definition.php +++ b/models/DataObject/Fieldcollection/Definition.php @@ -36,6 +36,14 @@ class Definition extends Model\AbstractModel use DataObject\Traits\LocateFileTrait; use Model\DataObject\ClassDefinition\Helper\VarExport; + /** + * @var array + */ + protected const FORBIDDEN_NAMES = [ + 'abstract', 'class', 'data', 'folder', 'list', 'permissions', 'resource', 'dao', 'concrete', 'items', + 'object', 'interface', 'default', + ]; + /** * {@inheritdoc} */ @@ -125,7 +133,7 @@ public function save(bool $saveDefinitionFile = true): void throw new \Exception('A field-collection needs a key to be saved!'); } - if (!preg_match('/[a-zA-Z]+/', $this->getKey())) { + if (!preg_match('/^[a-zA-Z][a-zA-Z0-9]*$/', $this->getKey()) || $this->isForbiddenName()) { throw new \Exception(sprintf('Invalid key for field-collection: %s', $this->getKey())); } @@ -282,4 +290,9 @@ protected function getInfoDocBlock(): string return $cd; } + + public function isForbiddenName(): bool + { + return in_array($this->getKey(), self::FORBIDDEN_NAMES); + } } diff --git a/models/DataObject/Objectbrick/Definition.php b/models/DataObject/Objectbrick/Definition.php index 012e053f438..42c4d2626a1 100644 --- a/models/DataObject/Objectbrick/Definition.php +++ b/models/DataObject/Objectbrick/Definition.php @@ -148,7 +148,7 @@ public function save(bool $saveDefinitionFile = true): void throw new \Exception('A object-brick needs a key to be saved!'); } - if (!preg_match('/[a-zA-Z]+[a-zA-Z0-9]+/', $this->getKey())) { + if (!preg_match('/^[a-zA-Z][a-zA-Z0-9]*$/', $this->getKey()) || $this->isForbiddenName()) { throw new \Exception(sprintf('Invalid key for object-brick: %s', $this->getKey())); } diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 2297537291d..27320368414 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -114,3 +114,22 @@ parameters: message: "#^Negated boolean expression is always true\\.$#" count: 1 path: models/Asset/Video/ImageThumbnail.php + - + message: "#^Method Pimcore\\\\Messenger\\\\Handler\\\\CleanupThumbnailsHandler\\:\\:process\\(\\) is unused\\.$#" + count: 1 + path: lib/Messenger/Handler/CleanupThumbnailsHandler.php + + - + message: "#^Method Pimcore\\\\Messenger\\\\Handler\\\\SanityCheckHandler\\:\\:process\\(\\) is unused\\.$#" + count: 1 + path: lib/Messenger/Handler/SanityCheckHandler.php + + - + message: "#^Method Pimcore\\\\Messenger\\\\Handler\\\\SearchBackendHandler\\:\\:process\\(\\) is unused\\.$#" + count: 1 + path: lib/Messenger/Handler/SearchBackendHandler.php + + - + message: "#^Method Pimcore\\\\Messenger\\\\Handler\\\\SearchBackendHandler\\:\\:shouldFlush\\(\\) is unused\\.$#" + count: 1 + path: lib/Messenger/Handler/SearchBackendHandler.php