From f587d93a00e11157b9f62be37a1029c7df5082b3 Mon Sep 17 00:00:00 2001 From: Niklas Date: Fri, 17 Mar 2023 11:28:49 +0100 Subject: [PATCH 01/17] Relation performance fix (#14563) * Add fieldname to object_relation_ indices * Move to table->addIndex --- .../Migrations/Version20230307135459.php | 50 +++++++++++++++++++ models/DataObject/ClassDefinition/Dao.php | 1 + 2 files changed, 51 insertions(+) create mode 100644 bundles/CoreBundle/Migrations/Version20230307135459.php diff --git a/bundles/CoreBundle/Migrations/Version20230307135459.php b/bundles/CoreBundle/Migrations/Version20230307135459.php new file mode 100644 index 00000000000..a35cf1b2486 --- /dev/null +++ b/bundles/CoreBundle/Migrations/Version20230307135459.php @@ -0,0 +1,50 @@ +getTables() as $table) { + if (str_starts_with($table->getName(), InheritanceHelper::RELATION_TABLE) && !$table->hasIndex($this->fieldname)) { + $table->addIndex([$this->fieldname], $this->fieldname); + } + } + } + + public function down(Schema $schema): void + { + foreach ($schema->getTables() as $table) { + if (str_starts_with($table->getName(), InheritanceHelper::RELATION_TABLE) && $table->hasIndex($this->fieldname)) { + $table->dropIndex($this->fieldname); + } + } + } +} diff --git a/models/DataObject/ClassDefinition/Dao.php b/models/DataObject/ClassDefinition/Dao.php index 853accab0be..c737e77d9cd 100644 --- a/models/DataObject/ClassDefinition/Dao.php +++ b/models/DataObject/ClassDefinition/Dao.php @@ -154,6 +154,7 @@ public function update() `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 (`o_id`) ON DELETE CASCADE ) DEFAULT CHARSET=utf8mb4;'); From af9c3d03d3dc2806fccd0ab662dae4bc7d81a9f7 Mon Sep 17 00:00:00 2001 From: torqdev <67965755+torqdev@users.noreply.github.com> Date: Mon, 20 Mar 2023 07:32:59 -0300 Subject: [PATCH 02/17] make sure image isnt self before swapping (#14694) Co-authored-by: Cameron Jenkins --- .../public/js/pimcore/object/helpers/imageGalleryDropZone.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundles/AdminBundle/Resources/public/js/pimcore/object/helpers/imageGalleryDropZone.js b/bundles/AdminBundle/Resources/public/js/pimcore/object/helpers/imageGalleryDropZone.js index b11c372a65a..9bfc9ae86a5 100644 --- a/bundles/AdminBundle/Resources/public/js/pimcore/object/helpers/imageGalleryDropZone.js +++ b/bundles/AdminBundle/Resources/public/js/pimcore/object/helpers/imageGalleryDropZone.js @@ -69,7 +69,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) { From e6032e0ef7a8075599163f5b164008c630ef4648 Mon Sep 17 00:00:00 2001 From: mcop1 <89011527+mcop1@users.noreply.github.com> Date: Mon, 20 Mar 2023 12:28:07 +0100 Subject: [PATCH 03/17] [Bug]: PHP API does not validate the objectbrick definition key (or not as in the javascript) (#14651) * Adapted regex and added check for forbidden names (keys) * Adapted values for forbidden names * Update models/DataObject/Fieldcollection/Definition.php --- .../public/js/pimcore/object/fieldcollection.js | 3 ++- models/DataObject/Fieldcollection/Definition.php | 15 ++++++++++++++- models/DataObject/Objectbrick/Definition.php | 2 +- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/bundles/AdminBundle/Resources/public/js/pimcore/object/fieldcollection.js b/bundles/AdminBundle/Resources/public/js/pimcore/object/fieldcollection.js index a1628c03992..6a714356c46 100644 --- a/bundles/AdminBundle/Resources/public/js/pimcore/object/fieldcollection.js +++ b/bundles/AdminBundle/Resources/public/js/pimcore/object/fieldcollection.js @@ -15,7 +15,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/models/DataObject/Fieldcollection/Definition.php b/models/DataObject/Fieldcollection/Definition.php index c7b4c3348aa..fecb00afaa1 100644 --- a/models/DataObject/Fieldcollection/Definition.php +++ b/models/DataObject/Fieldcollection/Definition.php @@ -34,6 +34,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} */ @@ -129,7 +137,7 @@ public function save($saveDefinitionFile = true) 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())); } @@ -288,4 +296,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 7b97ad41390..01afb23f115 100644 --- a/models/DataObject/Objectbrick/Definition.php +++ b/models/DataObject/Objectbrick/Definition.php @@ -160,7 +160,7 @@ public function save($saveDefinitionFile = true) 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())); } From ddad22b5d47c346a3eac0c1115f931b21b6c0c35 Mon Sep 17 00:00:00 2001 From: lukmzig Date: Mon, 20 Mar 2023 11:29:59 +0000 Subject: [PATCH 04/17] Apply php-cs-fixer changes --- models/DataObject/Fieldcollection/Definition.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/DataObject/Fieldcollection/Definition.php b/models/DataObject/Fieldcollection/Definition.php index fecb00afaa1..1e367c56f8d 100644 --- a/models/DataObject/Fieldcollection/Definition.php +++ b/models/DataObject/Fieldcollection/Definition.php @@ -39,7 +39,7 @@ class Definition extends Model\AbstractModel */ protected const FORBIDDEN_NAMES = [ 'abstract', 'class', 'data', 'folder', 'list', 'permissions', 'resource', 'dao', 'concrete', 'items', - 'object', 'interface', 'default' + 'object', 'interface', 'default', ]; /** From d3b5f458477de12bb863563cf81cab1bf6f15b85 Mon Sep 17 00:00:00 2001 From: Christian F Date: Mon, 20 Mar 2023 12:34:35 +0100 Subject: [PATCH 05/17] added overflow of manyToOneRelation (#14676) --- .../public/js/pimcore/object/tags/manyToOneRelation.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bundles/AdminBundle/Resources/public/js/pimcore/object/tags/manyToOneRelation.js b/bundles/AdminBundle/Resources/public/js/pimcore/object/tags/manyToOneRelation.js index 82d86235099..11f099c2a3b 100644 --- a/bundles/AdminBundle/Resources/public/js/pimcore/object/tags/manyToOneRelation.js +++ b/bundles/AdminBundle/Resources/public/js/pimcore/object/tags/manyToOneRelation.js @@ -128,6 +128,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", From 27fca6144ab7a5e341fe41fd25d11924b059effb Mon Sep 17 00:00:00 2001 From: Dominik Date: Tue, 21 Mar 2023 14:04:19 +0100 Subject: [PATCH 06/17] Cleanup Temp files after Processing Assets (#14688) --- bundles/CoreBundle/Resources/config/message_handler.yaml | 1 + lib/Messenger/Handler/AssetUpdateTasksHandler.php | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/bundles/CoreBundle/Resources/config/message_handler.yaml b/bundles/CoreBundle/Resources/config/message_handler.yaml index 5e59f10e13f..05dbad0c1f6 100644 --- a/bundles/CoreBundle/Resources/config/message_handler.yaml +++ b/bundles/CoreBundle/Resources/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/lib/Messenger/Handler/AssetUpdateTasksHandler.php b/lib/Messenger/Handler/AssetUpdateTasksHandler.php index abb0a232783..afdcc0c7310 100644 --- a/lib/Messenger/Handler/AssetUpdateTasksHandler.php +++ b/lib/Messenger/Handler/AssetUpdateTasksHandler.php @@ -15,6 +15,7 @@ namespace Pimcore\Messenger\Handler; +use Pimcore\Helper\LongRunningHelper; use Pimcore\Messenger\AssetUpdateTasksMessage; use Pimcore\Model\Asset; use Pimcore\Model\Version; @@ -25,7 +26,7 @@ */ class AssetUpdateTasksHandler { - public function __construct(protected LoggerInterface $logger) + public function __construct(protected LoggerInterface $logger, protected LongRunningHelper $longRunningHelper) { } @@ -46,6 +47,8 @@ public function __invoke(AssetUpdateTasksMessage $message) } elseif ($asset instanceof Asset\Video) { $this->processVideo($asset); } + + $this->longRunningHelper->deleteTemporaryFiles(); } private function saveAsset(Asset $asset) From 765832f0dc5f6cfb296a82e089b701066f27bcef Mon Sep 17 00:00:00 2001 From: lukmzig <30526586+lukmzig@users.noreply.github.com> Date: Tue, 21 Mar 2023 16:12:33 +0100 Subject: [PATCH 07/17] [Task] Optimized composite index key (#14636) * chore: validate composite index key * fix: add php validation --- .../Controller/Admin/DataObject/ClassController.php | 8 ++++++++ .../Resources/public/js/pimcore/object/classes/class.js | 9 ++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/bundles/AdminBundle/Controller/Admin/DataObject/ClassController.php b/bundles/AdminBundle/Controller/Admin/DataObject/ClassController.php index ce44ed65340..58959ce1cba 100644 --- a/bundles/AdminBundle/Controller/Admin/DataObject/ClassController.php +++ b/bundles/AdminBundle/Controller/Admin/DataObject/ClassController.php @@ -455,6 +455,14 @@ public function saveAction(Request $request) $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/AdminBundle/Resources/public/js/pimcore/object/classes/class.js b/bundles/AdminBundle/Resources/public/js/pimcore/object/classes/class.js index 28602a94fda..ebedbe757d2 100644 --- a/bundles/AdminBundle/Resources/public/js/pimcore/object/classes/class.js +++ b/bundles/AdminBundle/Resources/public/js/pimcore/object/classes/class.js @@ -1085,7 +1085,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 From ab691db44a65c6d777729ccdad5d145633232063 Mon Sep 17 00:00:00 2001 From: mattamon Date: Tue, 14 Mar 2023 08:15:59 +0100 Subject: [PATCH 08/17] Deprecate ConsoleCommandPluginTrait --- .../23_Installation_and_Upgrade/09_Upgrade_Notes/README.md | 1 + lib/Console/ConsoleCommandPluginTrait.php | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/doc/Development_Documentation/23_Installation_and_Upgrade/09_Upgrade_Notes/README.md b/doc/Development_Documentation/23_Installation_and_Upgrade/09_Upgrade_Notes/README.md index 0fbd5793b21..ba0f787a24b 100644 --- a/doc/Development_Documentation/23_Installation_and_Upgrade/09_Upgrade_Notes/README.md +++ b/doc/Development_Documentation/23_Installation_and_Upgrade/09_Upgrade_Notes/README.md @@ -16,6 +16,7 @@ - [DataObject]: The usage of `getO_` or `setO_` methods is deprecated. The BC layer supporting these methods will be removed in Pimcore 11. - [Classification Store] Deleting the data from deleted groups and keys. - [Commands] Calling `configureParallelization` on `Parallelization` trait is deprecated and will be removed in Pimcore 11. Please call `Parallelization::configureCommand` instead. +- [Console] Trait `ConsoleCommandPluginTrait` is deprecated and will be removed in Pimcore 11. - [Events] Event `pimcore.element.note.postAdd` has been deprecated. Use `pimcore.note.postAdd` instead. Note: The event type changed from `ElementEvent` to `ModelEvent`. - [Document] Deprecated loading documents via fixed namespace only. It will be removed in Pimcore 11. Use `pimcore:type_definitions` instead. - [Annotations] Using Annotations `@ResponseHeader` & `@ParamConverter`, `@Template` and rest from [SensioFrameworkExtraBundle](https://symfony.com/bundles/SensioFrameworkExtraBundle/current/index.html#annotations-for-controllers) is deprecated and will not be supported on Pimcore 11. Use `#[ResponseHeader]`,`#[DataObjectParam]` argument, `#[Template]` and other attributes instead. diff --git a/lib/Console/ConsoleCommandPluginTrait.php b/lib/Console/ConsoleCommandPluginTrait.php index 5c4457524ff..92a0c896cce 100644 --- a/lib/Console/ConsoleCommandPluginTrait.php +++ b/lib/Console/ConsoleCommandPluginTrait.php @@ -19,6 +19,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 { /** From 64e3a09c2d73b95e0f33ed79f5272b12c1171ba6 Mon Sep 17 00:00:00 2001 From: Matthias Schuhmayer <38959016+mattamon@users.noreply.github.com> Date: Wed, 22 Mar 2023 12:46:37 +0100 Subject: [PATCH 09/17] [Task] Bump phpstan version (#14571) * Bump phpstan version to 1.10.5 * Fixing phpstan errors excecpt unused methods * Fixing phpstan errors excecpt unused methods * Fix typo for unused method * Remove unused method, add Messenger/Handler to ignoreErrors * Fixed typo * Adding null to docs for redirects --- .../Controller/Admin/SettingsController.php | 15 ++++----- .../DependencyInjection/Configuration.php | 4 +-- .../PimcoreCoreExtension.php | 19 ----------- .../PriceSystem/CachingPriceSystem.php | 2 +- composer.json | 2 +- lib/Config/Config.php | 2 +- lib/DataObject/ClassBuilder/ClassBuilder.php | 8 ++--- .../FieldCollectionClassBuilder.php | 8 ++--- .../ClassBuilder/ObjectBrickClassBuilder.php | 28 ++++++++-------- lib/Log/ApplicationLogger.php | 2 +- lib/Maintenance/Tasks/VersionsCleanupTask.php | 2 +- lib/Routing/RedirectHandler.php | 4 +-- .../ExpressionSupportStrategy.php | 10 +++--- .../DataObject/ClassDefinition/Data/Block.php | 10 +++--- .../ClassDefinition/Data/Localizedfields.php | 10 +++--- models/Document/Service.php | 33 ------------------- models/Staticroute.php | 8 ----- models/Version/Dao.php | 2 +- phpstan-baseline.neon | 19 +++++++++++ 19 files changed, 73 insertions(+), 115 deletions(-) diff --git a/bundles/AdminBundle/Controller/Admin/SettingsController.php b/bundles/AdminBundle/Controller/Admin/SettingsController.php index dd549e26d19..acd9c55fc07 100644 --- a/bundles/AdminBundle/Controller/Admin/SettingsController.php +++ b/bundles/AdminBundle/Controller/Admin/SettingsController.php @@ -404,17 +404,16 @@ public function getSystemAction(Request $request, Config $config) $valueArray['general']['valid_language'] = explode(',', $valueArray['general']['valid_languages']); //for "wrong" legacy values - if (is_array($valueArray['general']['valid_language'])) { - foreach ($valueArray['general']['valid_language'] as $existingValue) { - if (!in_array($existingValue, $validLanguages)) { - $languageOptions[] = [ - 'language' => $existingValue, - 'display' => $existingValue, - ]; - } + foreach ($valueArray['general']['valid_language'] as $existingValue) { + if (!in_array($existingValue, $validLanguages)) { + $languageOptions[] = [ + 'language' => $existingValue, + 'display' => $existingValue, + ]; } } + $response = [ 'values' => $valueArray, 'config' => [ diff --git a/bundles/CoreBundle/DependencyInjection/Configuration.php b/bundles/CoreBundle/DependencyInjection/Configuration.php index f162bd0bafc..905fd2fe655 100644 --- a/bundles/CoreBundle/DependencyInjection/Configuration.php +++ b/bundles/CoreBundle/DependencyInjection/Configuration.php @@ -2137,7 +2137,7 @@ private function addPredefinedPropertiesNode(ArrayNodeDefinition $rootNode) * * @param ArrayNodeDefinition $rootNode */ - private function addStaticroutesNode(ArrayNodeDefinition $rootNode) + private function addStaticRoutesNode(ArrayNodeDefinition $rootNode) { $rootNode ->children() @@ -2297,7 +2297,7 @@ private function addTemplatingEngineNode(ArrayNodeDefinition $rootNode): void ->addDefaultsIfNotSet() ->children() ->arrayNode('sandbox_security_policy') - ->info('Whitelist tags, filters & functions for evaluating twig + ->info('Whitelist tags, filters & functions for evaluating twig templates in a sandbox environment e.g. used by Mailer & Text layout component.') ->children() ->arrayNode('tags') diff --git a/bundles/CoreBundle/DependencyInjection/PimcoreCoreExtension.php b/bundles/CoreBundle/DependencyInjection/PimcoreCoreExtension.php index 7fffc7dcfb1..e93dc0bdf39 100644 --- a/bundles/CoreBundle/DependencyInjection/PimcoreCoreExtension.php +++ b/bundles/CoreBundle/DependencyInjection/PimcoreCoreExtension.php @@ -315,25 +315,6 @@ private function configureTargeting(ContainerBuilder $container, LoaderInterface ->setArgument('$actionHandlers', $actionHandlerLocator); } - /** - * Configures a "typed locator" (a class exposing get/has for a specific type) wrapping - * a standard service locator. Example: Pimcore\Targeting\DataProviderLocator - * - * @param ContainerBuilder $container - * @param string $locatorClass - * @param array $services - */ - private function configureTypedLocator(ContainerBuilder $container, string $locatorClass, array $services) - { - $serviceLocator = new Definition(ServiceLocator::class, [$services]); - $serviceLocator - ->setPublic(false) - ->addTag('container.service_locator'); - - $locator = $container->getDefinition($locatorClass); - $locator->setArgument('$locator', $serviceLocator); - } - /** * Handle pimcore.security.encoder_factories mapping * diff --git a/bundles/EcommerceFrameworkBundle/PriceSystem/CachingPriceSystem.php b/bundles/EcommerceFrameworkBundle/PriceSystem/CachingPriceSystem.php index 3d051ad1665..2299f5dea66 100644 --- a/bundles/EcommerceFrameworkBundle/PriceSystem/CachingPriceSystem.php +++ b/bundles/EcommerceFrameworkBundle/PriceSystem/CachingPriceSystem.php @@ -34,7 +34,7 @@ abstract class CachingPriceSystem extends AbstractPriceSystem implements Caching public function getPriceInfo(CheckoutableInterface $product, $quantityScale = 1, $products = null): PriceInfoInterface { $pId = $product->getId(); - if (!array_key_exists($pId, $this->priceInfos) || !is_array($this->priceInfos[$pId])) { + if (!array_key_exists($pId, $this->priceInfos)) { $this->priceInfos[$pId] = []; } diff --git a/composer.json b/composer.json index 44f567c02a0..6ad7ea85a9f 100644 --- a/composer.json +++ b/composer.json @@ -173,7 +173,7 @@ "codeception/codeception": "^4.1.12", "codeception/module-symfony": "^1.6.0", "codeception/phpunit-wrapper": "^9", - "phpstan/phpstan": "1.9.17", + "phpstan/phpstan": "1.10.5", "phpstan/phpstan-symfony": "^1.2.19", "phpunit/phpunit": "^9.3", "spiritix/php-chrome-html2pdf": "^1.6", diff --git a/lib/Config/Config.php b/lib/Config/Config.php index 48964ec1196..472ef12989b 100644 --- a/lib/Config/Config.php +++ b/lib/Config/Config.php @@ -394,6 +394,6 @@ public function __toString() return ''; } - return is_string($this->data) ? (string)$this->data : json_encode($this->data, JSON_PRETTY_PRINT); + return json_encode($this->data, JSON_PRETTY_PRINT); } } diff --git a/lib/DataObject/ClassBuilder/ClassBuilder.php b/lib/DataObject/ClassBuilder/ClassBuilder.php index 8f330400429..e063b0a5b00 100644 --- a/lib/DataObject/ClassBuilder/ClassBuilder.php +++ b/lib/DataObject/ClassBuilder/ClassBuilder.php @@ -126,12 +126,12 @@ public function buildClass(ClassDefinition $classDefinition): string $cd .= "\n\n"; - if (is_array($classDefinition->getFieldDefinitions()) && count($classDefinition->getFieldDefinitions())) { - foreach ($classDefinition->getFieldDefinitions() as $def) { - $cd .= $this->fieldDefinitionBuilder->buildFieldDefinition($classDefinition, $def); - } + + foreach ($classDefinition->getFieldDefinitions() as $def) { + $cd .= $this->fieldDefinitionBuilder->buildFieldDefinition($classDefinition, $def); } + $cd .= "}\n"; $cd .= "\n"; diff --git a/lib/DataObject/ClassBuilder/FieldCollectionClassBuilder.php b/lib/DataObject/ClassBuilder/FieldCollectionClassBuilder.php index 424c5dc5d8f..9b051cb0107 100644 --- a/lib/DataObject/ClassBuilder/FieldCollectionClassBuilder.php +++ b/lib/DataObject/ClassBuilder/FieldCollectionClassBuilder.php @@ -62,12 +62,12 @@ public function buildClass(Definition $definition): string $cd .= 'protected $type = "' . $definition->getKey() . "\";\n"; - if (is_array($definition->getFieldDefinitions()) && count($definition->getFieldDefinitions())) { - foreach ($definition->getFieldDefinitions() as $key => $def) { - $cd .= 'protected $' . $key . ";\n"; - } + + foreach ($definition->getFieldDefinitions() as $key => $def) { + $cd .= 'protected $' . $key . ";\n"; } + $cd .= "\n\n"; $fdDefs = $definition->getFieldDefinitions(); diff --git a/lib/DataObject/ClassBuilder/ObjectBrickClassBuilder.php b/lib/DataObject/ClassBuilder/ObjectBrickClassBuilder.php index 2c6f7d8b35c..d1e88477c66 100644 --- a/lib/DataObject/ClassBuilder/ObjectBrickClassBuilder.php +++ b/lib/DataObject/ClassBuilder/ObjectBrickClassBuilder.php @@ -66,12 +66,12 @@ public function buildClass(Definition $definition): string $cd .= 'protected $type = "' . $definition->getKey() . "\";\n"; - if (is_array($definition->getFieldDefinitions()) && count($definition->getFieldDefinitions())) { - foreach ($definition->getFieldDefinitions() as $key => $def) { - $cd .= 'protected $' . $key . ";\n"; - } + + foreach ($definition->getFieldDefinitions() as $key => $def) { + $cd .= 'protected $' . $key . ";\n"; } + $cd .= "\n\n"; $cd .= '/**' ."\n"; @@ -87,22 +87,22 @@ public function buildClass(Definition $definition): string $cd .= "\n\n"; - if (is_array($definition->getFieldDefinitions()) && count($definition->getFieldDefinitions())) { - foreach ($definition->getFieldDefinitions() as $key => $def) { - $cd .= $def->getGetterCodeObjectbrick($definition); - if ($def instanceof ClassDefinition\Data\Localizedfields) { - $cd .= $def->getGetterCode($definition); - } + foreach ($definition->getFieldDefinitions() as $def) { + $cd .= $def->getGetterCodeObjectbrick($definition); - $cd .= $def->getSetterCodeObjectbrick($definition); + if ($def instanceof ClassDefinition\Data\Localizedfields) { + $cd .= $def->getGetterCode($definition); + } + + $cd .= $def->getSetterCodeObjectbrick($definition); - if ($def instanceof ClassDefinition\Data\Localizedfields) { - $cd .= $def->getSetterCode($definition); - } + if ($def instanceof ClassDefinition\Data\Localizedfields) { + $cd .= $def->getSetterCode($definition); } } + $cd .= "}\n"; $cd .= "\n"; diff --git a/lib/Log/ApplicationLogger.php b/lib/Log/ApplicationLogger.php index 8e12f35a322..7e5a7880f09 100644 --- a/lib/Log/ApplicationLogger.php +++ b/lib/Log/ApplicationLogger.php @@ -142,7 +142,7 @@ public function setRelatedObject($relatedObject) */ public function log($level, $message, array $context = [])// : void { - if (!isset($context['component']) || is_null($context['component'])) { + if (!isset($context['component'])) { $context['component'] = $this->component; } diff --git a/lib/Maintenance/Tasks/VersionsCleanupTask.php b/lib/Maintenance/Tasks/VersionsCleanupTask.php index f14ac4a9398..aca2e9fb1d1 100644 --- a/lib/Maintenance/Tasks/VersionsCleanupTask.php +++ b/lib/Maintenance/Tasks/VersionsCleanupTask.php @@ -96,7 +96,7 @@ private function doVersionCleanup() } $value = $tConf['steps'] ?? 10; - if (isset($tConf['days']) && !is_null($tConf['days'])) { + if (isset($tConf['days'])) { $versioningType = 'days'; $value = (int)$tConf['days']; } diff --git a/lib/Routing/RedirectHandler.php b/lib/Routing/RedirectHandler.php index 6014b8f0efc..8dc111af9d4 100644 --- a/lib/Routing/RedirectHandler.php +++ b/lib/Routing/RedirectHandler.php @@ -56,7 +56,7 @@ final class RedirectHandler implements LoggerAwareInterface private $siteResolver; /** - * @var Redirect[] + * @var null|Redirect[] */ private $redirects; @@ -261,7 +261,7 @@ protected function buildRedirectResponse(Redirect $redirect, Request $request, $ */ private function getRegexRedirects() { - if (null !== $this->redirects && is_array($this->redirects)) { + if (is_array($this->redirects)) { return $this->redirects; } diff --git a/lib/Workflow/SupportStrategy/ExpressionSupportStrategy.php b/lib/Workflow/SupportStrategy/ExpressionSupportStrategy.php index 7dfabacadbc..f68bcd1dc07 100644 --- a/lib/Workflow/SupportStrategy/ExpressionSupportStrategy.php +++ b/lib/Workflow/SupportStrategy/ExpressionSupportStrategy.php @@ -76,14 +76,14 @@ private function supportsClass($subject) return $subject instanceof $this->className; } - if (is_array($this->className)) { - foreach ($this->className as $className) { - if ($subject instanceof $className) { - return true; - } + + foreach ($this->className as $className) { + if ($subject instanceof $className) { + return true; } } + return false; } diff --git a/models/DataObject/ClassDefinition/Data/Block.php b/models/DataObject/ClassDefinition/Data/Block.php index 7bae828f9c8..a0f7c1d8e88 100644 --- a/models/DataObject/ClassDefinition/Data/Block.php +++ b/models/DataObject/ClassDefinition/Data/Block.php @@ -665,13 +665,13 @@ public function getFieldDefinitions($context = []) } $enrichedFieldDefinitions = []; - if (is_array($this->fieldDefinitionsCache)) { - foreach ($this->fieldDefinitionsCache as $key => $fieldDefinition) { - $fieldDefinition = $this->doEnrichFieldDefinition($fieldDefinition, $context); - $enrichedFieldDefinitions[$key] = $fieldDefinition; - } + + foreach ($this->fieldDefinitionsCache ?? [] as $key => $fieldDefinition) { + $fieldDefinition = $this->doEnrichFieldDefinition($fieldDefinition, $context); + $enrichedFieldDefinitions[$key] = $fieldDefinition; } + return $enrichedFieldDefinitions; } diff --git a/models/DataObject/ClassDefinition/Data/Localizedfields.php b/models/DataObject/ClassDefinition/Data/Localizedfields.php index c3237572bca..5d289affe98 100644 --- a/models/DataObject/ClassDefinition/Data/Localizedfields.php +++ b/models/DataObject/ClassDefinition/Data/Localizedfields.php @@ -707,13 +707,13 @@ public function getFieldDefinitions($context = []) } $enrichedFieldDefinitions = []; - if (is_array($this->fieldDefinitionsCache)) { - foreach ($this->fieldDefinitionsCache as $key => $fieldDefinition) { - $fieldDefinition = $this->doEnrichFieldDefinition($fieldDefinition, $context); - $enrichedFieldDefinitions[$key] = $fieldDefinition; - } + + foreach ($this->fieldDefinitionsCache ?? [] as $key => $fieldDefinition) { + $fieldDefinition = $this->doEnrichFieldDefinition($fieldDefinition, $context); + $enrichedFieldDefinitions[$key] = $fieldDefinition; } + return $enrichedFieldDefinitions; } diff --git a/models/Document/Service.php b/models/Document/Service.php index 51225d4c96c..bcbabe958c5 100644 --- a/models/Document/Service.php +++ b/models/Document/Service.php @@ -94,39 +94,6 @@ public static function render(Document\PageSnippet $document, array $attributes return $content; } - /** - * Save document and all child documents - * - * @param Document $document - * @param int $collectGarbageAfterIteration - * @param int $saved - * - * @throws \Exception - */ - private static function saveRecursive($document, $collectGarbageAfterIteration = 25, &$saved = 0) - { - if ($document instanceof Document) { - $document->save(); - $saved++; - if ($saved % $collectGarbageAfterIteration === 0) { - \Pimcore::collectGarbage(); - } - } - - foreach ($document->getChildren() as $child) { - if (!$child->hasChildren()) { - $child->save(); - $saved++; - if ($saved % $collectGarbageAfterIteration === 0) { - \Pimcore::collectGarbage(); - } - } - if ($child->hasChildren()) { - self::saveRecursive($child, $collectGarbageAfterIteration, $saved); - } - } - } - /** * @param Document $target * @param Document $source diff --git a/models/Staticroute.php b/models/Staticroute.php index a241d04f595..983379b303a 100644 --- a/models/Staticroute.php +++ b/models/Staticroute.php @@ -434,10 +434,6 @@ public function setSiteId($siteId) */ public function getSiteId() { - if ($this->siteId && !is_array($this->siteId)) { - $this->siteId = explode(',', $this->siteId); - } - return $this->siteId; } @@ -603,10 +599,6 @@ public function match($path, $params = []) */ public function getMethods() { - if ($this->methods && is_string($this->methods)) { - $this->methods = explode(',', $this->methods); - } - return $this->methods; } diff --git a/models/Version/Dao.php b/models/Version/Dao.php index 9b9d4c8b373..62c5c4a3271 100644 --- a/models/Version/Dao.php +++ b/models/Version/Dao.php @@ -143,7 +143,7 @@ public function maintenanceGetOutdatedVersions($elementTypes, $ignoreIds = []) $count = 0; $stop = false; foreach ($elementTypes as $elementType) { - if (isset($elementType['days']) && !is_null($elementType['days'])) { + if (isset($elementType['days'])) { // by days $deadline = time() - ($elementType['days'] * 86400); $tmpVersionIds = $this->db->fetchFirstColumn('SELECT id FROM versions as a WHERE (ctype = ? AND date < ?) AND NOT public AND id NOT IN (' . $ignoreIdsList . ')', [$elementType['elementType'], $deadline]); diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index ff3413d09ee..279d75ddff7 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -255,3 +255,22 @@ parameters: count: 1 path: models/Element/Service.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 \ No newline at end of file From c0dd6648d9d241de270c28c4ca4f6bbb8cda7351 Mon Sep 17 00:00:00 2001 From: dvesh3 Date: Wed, 22 Mar 2023 11:48:36 +0000 Subject: [PATCH 10/17] Apply php-cs-fixer changes --- bundles/AdminBundle/Controller/Admin/SettingsController.php | 1 - lib/DataObject/ClassBuilder/ClassBuilder.php | 2 -- lib/DataObject/ClassBuilder/FieldCollectionClassBuilder.php | 2 -- lib/DataObject/ClassBuilder/ObjectBrickClassBuilder.php | 4 ---- lib/Workflow/SupportStrategy/ExpressionSupportStrategy.php | 2 -- models/DataObject/ClassDefinition/Data/Block.php | 1 - models/DataObject/ClassDefinition/Data/Localizedfields.php | 1 - 7 files changed, 13 deletions(-) diff --git a/bundles/AdminBundle/Controller/Admin/SettingsController.php b/bundles/AdminBundle/Controller/Admin/SettingsController.php index acd9c55fc07..df2ed7af227 100644 --- a/bundles/AdminBundle/Controller/Admin/SettingsController.php +++ b/bundles/AdminBundle/Controller/Admin/SettingsController.php @@ -413,7 +413,6 @@ public function getSystemAction(Request $request, Config $config) } } - $response = [ 'values' => $valueArray, 'config' => [ diff --git a/lib/DataObject/ClassBuilder/ClassBuilder.php b/lib/DataObject/ClassBuilder/ClassBuilder.php index e063b0a5b00..3c24f3e721c 100644 --- a/lib/DataObject/ClassBuilder/ClassBuilder.php +++ b/lib/DataObject/ClassBuilder/ClassBuilder.php @@ -126,12 +126,10 @@ public function buildClass(ClassDefinition $classDefinition): string $cd .= "\n\n"; - foreach ($classDefinition->getFieldDefinitions() as $def) { $cd .= $this->fieldDefinitionBuilder->buildFieldDefinition($classDefinition, $def); } - $cd .= "}\n"; $cd .= "\n"; diff --git a/lib/DataObject/ClassBuilder/FieldCollectionClassBuilder.php b/lib/DataObject/ClassBuilder/FieldCollectionClassBuilder.php index 9b051cb0107..12b0e73e022 100644 --- a/lib/DataObject/ClassBuilder/FieldCollectionClassBuilder.php +++ b/lib/DataObject/ClassBuilder/FieldCollectionClassBuilder.php @@ -62,12 +62,10 @@ public function buildClass(Definition $definition): string $cd .= 'protected $type = "' . $definition->getKey() . "\";\n"; - foreach ($definition->getFieldDefinitions() as $key => $def) { $cd .= 'protected $' . $key . ";\n"; } - $cd .= "\n\n"; $fdDefs = $definition->getFieldDefinitions(); diff --git a/lib/DataObject/ClassBuilder/ObjectBrickClassBuilder.php b/lib/DataObject/ClassBuilder/ObjectBrickClassBuilder.php index d1e88477c66..5737ce6318e 100644 --- a/lib/DataObject/ClassBuilder/ObjectBrickClassBuilder.php +++ b/lib/DataObject/ClassBuilder/ObjectBrickClassBuilder.php @@ -66,12 +66,10 @@ public function buildClass(Definition $definition): string $cd .= 'protected $type = "' . $definition->getKey() . "\";\n"; - foreach ($definition->getFieldDefinitions() as $key => $def) { $cd .= 'protected $' . $key . ";\n"; } - $cd .= "\n\n"; $cd .= '/**' ."\n"; @@ -87,7 +85,6 @@ public function buildClass(Definition $definition): string $cd .= "\n\n"; - foreach ($definition->getFieldDefinitions() as $def) { $cd .= $def->getGetterCodeObjectbrick($definition); @@ -102,7 +99,6 @@ public function buildClass(Definition $definition): string } } - $cd .= "}\n"; $cd .= "\n"; diff --git a/lib/Workflow/SupportStrategy/ExpressionSupportStrategy.php b/lib/Workflow/SupportStrategy/ExpressionSupportStrategy.php index f68bcd1dc07..f796670743e 100644 --- a/lib/Workflow/SupportStrategy/ExpressionSupportStrategy.php +++ b/lib/Workflow/SupportStrategy/ExpressionSupportStrategy.php @@ -76,14 +76,12 @@ private function supportsClass($subject) return $subject instanceof $this->className; } - foreach ($this->className as $className) { if ($subject instanceof $className) { return true; } } - return false; } diff --git a/models/DataObject/ClassDefinition/Data/Block.php b/models/DataObject/ClassDefinition/Data/Block.php index a0f7c1d8e88..276457fc63a 100644 --- a/models/DataObject/ClassDefinition/Data/Block.php +++ b/models/DataObject/ClassDefinition/Data/Block.php @@ -671,7 +671,6 @@ public function getFieldDefinitions($context = []) $enrichedFieldDefinitions[$key] = $fieldDefinition; } - return $enrichedFieldDefinitions; } diff --git a/models/DataObject/ClassDefinition/Data/Localizedfields.php b/models/DataObject/ClassDefinition/Data/Localizedfields.php index 5d289affe98..aedffd63d11 100644 --- a/models/DataObject/ClassDefinition/Data/Localizedfields.php +++ b/models/DataObject/ClassDefinition/Data/Localizedfields.php @@ -713,7 +713,6 @@ public function getFieldDefinitions($context = []) $enrichedFieldDefinitions[$key] = $fieldDefinition; } - return $enrichedFieldDefinitions; } From 06301ab9d6dffedcc61500bf482c9abf86456e68 Mon Sep 17 00:00:00 2001 From: Christian F Date: Wed, 22 Mar 2023 14:05:22 +0100 Subject: [PATCH 11/17] [Task] Cherry-Picked `PimcoreBundleAdminSupportInterface` changes (#14729) * cherry-picked PimcoreBundleAdminSupportInterface changes * added upgrade notes --- .../src/Support/BundleAdminSupportTrait.php | 26 +++++++++++++++++++ .../PimcoreBundleAdminSupportInterface.php | 0 .../13_Loading_Admin_UI_Assets.md | 11 ++++++-- .../09_Upgrade_Notes/README.md | 1 + .../Bundle/AbstractPimcoreBundle.php | 8 ++++++ 5 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 bundles/AdminBundle/src/Support/BundleAdminSupportTrait.php rename bundles/AdminBundle/{ => src}/Support/PimcoreBundleAdminSupportInterface.php (100%) diff --git a/bundles/AdminBundle/src/Support/BundleAdminSupportTrait.php b/bundles/AdminBundle/src/Support/BundleAdminSupportTrait.php new file mode 100644 index 00000000000..a9c306f1748 --- /dev/null +++ b/bundles/AdminBundle/src/Support/BundleAdminSupportTrait.php @@ -0,0 +1,26 @@ + Date: Wed, 22 Mar 2023 13:07:04 +0000 Subject: [PATCH 12/17] Apply php-cs-fixer changes --- .../src/Support/BundleAdminSupportTrait.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/bundles/AdminBundle/src/Support/BundleAdminSupportTrait.php b/bundles/AdminBundle/src/Support/BundleAdminSupportTrait.php index a9c306f1748..99b74146807 100644 --- a/bundles/AdminBundle/src/Support/BundleAdminSupportTrait.php +++ b/bundles/AdminBundle/src/Support/BundleAdminSupportTrait.php @@ -1,5 +1,18 @@ Date: Wed, 22 Mar 2023 14:22:55 +0100 Subject: [PATCH 13/17] [Bug]: Unable to save custom report (#14715) --- .../Resources/public/js/pimcore/report/custom/item.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bundles/AdminBundle/Resources/public/js/pimcore/report/custom/item.js b/bundles/AdminBundle/Resources/public/js/pimcore/report/custom/item.js index fe045f89601..d2d84138fab 100644 --- a/bundles/AdminBundle/Resources/public/js/pimcore/report/custom/item.js +++ b/bundles/AdminBundle/Resources/public/js/pimcore/report/custom/item.js @@ -931,12 +931,13 @@ pimcore.report.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)); } From 8f6d8cab4e05e46673704b24844fb72d5b8c054b Mon Sep 17 00:00:00 2001 From: Christian F Date: Wed, 22 Mar 2023 15:22:08 +0100 Subject: [PATCH 14/17] fixed regex issue (#14711) --- models/DataObject/ClassDefinition/Data/Input.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/models/DataObject/ClassDefinition/Data/Input.php b/models/DataObject/ClassDefinition/Data/Input.php index 21080e62993..e90fc30b869 100644 --- a/models/DataObject/ClassDefinition/Data/Input.php +++ b/models/DataObject/ClassDefinition/Data/Input.php @@ -327,7 +327,20 @@ public function getQueryColumnType() public function checkValidity($data, $omitMandatoryCheck = false, $params = []) { if (!$omitMandatoryCheck && $this->getRegex() && 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() . "'"); } } From d4d577dec5487130cb2c5bd62993080df7438267 Mon Sep 17 00:00:00 2001 From: lukmzig Date: Wed, 22 Mar 2023 14:23:54 +0000 Subject: [PATCH 15/17] Apply php-cs-fixer changes --- models/DataObject/ClassDefinition/Data/Input.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/models/DataObject/ClassDefinition/Data/Input.php b/models/DataObject/ClassDefinition/Data/Input.php index e90fc30b869..987f53e3647 100644 --- a/models/DataObject/ClassDefinition/Data/Input.php +++ b/models/DataObject/ClassDefinition/Data/Input.php @@ -328,19 +328,18 @@ public function checkValidity($data, $omitMandatoryCheck = false, $params = []) { if (!$omitMandatoryCheck && $this->getRegex() && strlen($data) > 0) { $throwException = false; - if(in_array('g', $this->getRegexFlags())){ + if (in_array('g', $this->getRegexFlags())) { $flags = str_replace('g', '', implode('', $this->getRegexFlags())); if (!preg_match_all('#' . $this->getRegex() . '#' . $flags, $data)) { $throwException = true; } - } - else{ + } else { if (!preg_match('#' . $this->getRegex() . '#' . implode('', $this->getRegexFlags()), $data)) { $throwException = true; } } - if($throwException) { + if ($throwException) { throw new Model\Element\ValidationException('Value in field [ ' . $this->getName() . " ] doesn't match input validation '" . $this->getRegex() . "'"); } } From ad561737dd1f2236f0b4c424562fb609548563f9 Mon Sep 17 00:00:00 2001 From: Divesh Pahuja Date: Fri, 24 Mar 2023 12:14:15 +0100 Subject: [PATCH 16/17] Refactor Admin Bundle event classes (#14744) * Refactor Admin Bundle event classes - related to #14642 * Refactor Admin Bundle event classes - related to #14642 * Refactor Admin Bundle event classes - related to #14642 * Refactor Admin Bundle event classes - related to #14642 * upgrade notes * fix AdminEvents * Add missing old classes * Docs --- bundles/AdminBundle/Event/AdminEvents.php | 554 +++++++++++++++++ .../Event/ElementAdminStyleEvent.php | 119 ++++ .../Event/IndexActionSettingsEvent.php | 52 ++ .../Event/Login/LoginCredentialsEvent.php | 56 ++ .../Event/Login/LoginFailedEvent.php | 91 +++ .../Event/Login/LoginRedirectEvent.php | 73 +++ .../AdminBundle/Event/Login/LogoutEvent.php | 51 ++ .../Event/Login/LostPasswordEvent.php | 90 +++ .../Event/Model/AssetDeleteInfoEvent.php | 29 + .../Event/Model/DataObjectDeleteInfoEvent.php | 29 + .../Event/Model/DocumentDeleteInfoEvent.php | 29 + .../Model/ElementDeleteInfoEventInterface.php | 41 ++ .../Traits/ElementDeleteInfoEventTrait.php | 66 ++ .../18_Tools_and_Features/02_Custom_Icons.md | 2 +- .../11_Event_API_and_Event_Manager.md | 6 +- .../09_Upgrade_Notes/README.md | 9 + ...ifying_Permissions_based_on_Object_Data.md | 2 +- lib/Event/Admin/ElementAdminStyleEvent.php | 102 +--- lib/Event/Admin/IndexActionSettingsEvent.php | 35 +- .../Admin/Login/LoginCredentialsEvent.php | 41 +- lib/Event/Admin/Login/LoginFailedEvent.php | 76 +-- lib/Event/Admin/Login/LoginRedirectEvent.php | 58 +- lib/Event/Admin/Login/LogoutEvent.php | 36 +- lib/Event/Admin/Login/LostPasswordEvent.php | 75 +-- lib/Event/AdminEvents.php | 577 +----------------- lib/Event/Model/AssetDeleteInfoEvent.php | 7 +- lib/Event/Model/DataObjectDeleteInfoEvent.php | 7 +- lib/Event/Model/DocumentDeleteInfoEvent.php | 7 +- .../Model/ElementDeleteInfoEventInterface.php | 24 +- .../Traits/ElementDeleteInfoEventTrait.php | 44 +- 30 files changed, 1361 insertions(+), 1027 deletions(-) create mode 100644 bundles/AdminBundle/Event/AdminEvents.php create mode 100644 bundles/AdminBundle/Event/ElementAdminStyleEvent.php create mode 100644 bundles/AdminBundle/Event/IndexActionSettingsEvent.php create mode 100644 bundles/AdminBundle/Event/Login/LoginCredentialsEvent.php create mode 100644 bundles/AdminBundle/Event/Login/LoginFailedEvent.php create mode 100644 bundles/AdminBundle/Event/Login/LoginRedirectEvent.php create mode 100644 bundles/AdminBundle/Event/Login/LogoutEvent.php create mode 100644 bundles/AdminBundle/Event/Login/LostPasswordEvent.php create mode 100644 bundles/AdminBundle/Event/Model/AssetDeleteInfoEvent.php create mode 100644 bundles/AdminBundle/Event/Model/DataObjectDeleteInfoEvent.php create mode 100644 bundles/AdminBundle/Event/Model/DocumentDeleteInfoEvent.php create mode 100644 bundles/AdminBundle/Event/Model/ElementDeleteInfoEventInterface.php create mode 100644 bundles/AdminBundle/Event/Traits/ElementDeleteInfoEventTrait.php 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/doc/Development_Documentation/18_Tools_and_Features/02_Custom_Icons.md b/doc/Development_Documentation/18_Tools_and_Features/02_Custom_Icons.md index 8dc7ee157e6..cb2ce5e350a 100644 --- a/doc/Development_Documentation/18_Tools_and_Features/02_Custom_Icons.md +++ b/doc/Development_Documentation/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/10.5/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/10.5/bundles/AdminBundle/Event/AdminEvents.php#L396-L407) event. Example: diff --git a/doc/Development_Documentation/20_Extending_Pimcore/11_Event_API_and_Event_Manager.md b/doc/Development_Documentation/20_Extending_Pimcore/11_Event_API_and_Event_Manager.md index 0deb2f1e0d7..4ec0c56ca2c 100644 --- a/doc/Development_Documentation/20_Extending_Pimcore/11_Event_API_and_Event_Manager.md +++ b/doc/Development_Documentation/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/10.5/lib/Event/MailEvents.php) - [Notifications](https://github.com/pimcore/pimcore/blob/10.5/lib/Event/NotificationEvents.php) - [Redirect](https://github.com/pimcore/pimcore/blob/10.5/lib/Event/RedirectEvents.php) -- [Admin](https://github.com/pimcore/pimcore/blob/10.5/lib/Event/AdminEvents.php) +- [Admin](https://github.com/pimcore/pimcore/blob/10.5/bundles/AdminBundle/Event/AdminEvents.php) - [Frontend](https://github.com/pimcore/pimcore/blob/10.5/lib/Event/FrontendEvents.php) - [Cache](https://github.com/pimcore/pimcore/blob/10.5/lib/Event/CoreCacheEvents.php) - [Full-Page Cache](https://github.com/pimcore/pimcore/blob/10.5/lib/Event/FullPageCacheEvents.php) @@ -108,7 +108,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/10.5/lib/Event/AdminEvents.php) event +You can change this behavior by handling the [AdminEvents::RESOLVE_ELEMENT](https://github.com/pimcore/pimcore/blob/10.5/bundles/AdminBundle/Event/AdminEvents.php) event and implement your own logic. ```php @@ -164,4 +164,4 @@ into the /news/in-enim-justo_2/image_1 asset folder. } }); -``` \ No newline at end of file +``` diff --git a/doc/Development_Documentation/23_Installation_and_Upgrade/09_Upgrade_Notes/README.md b/doc/Development_Documentation/23_Installation_and_Upgrade/09_Upgrade_Notes/README.md index f20335b0694..d8929189024 100644 --- a/doc/Development_Documentation/23_Installation_and_Upgrade/09_Upgrade_Notes/README.md +++ b/doc/Development_Documentation/23_Installation_and_Upgrade/09_Upgrade_Notes/README.md @@ -42,6 +42,15 @@ - [Web2print] Deprecated `HeadlessChrome` processor, it will be removed and replaced by `Chromium` processor (which doesn't require NodeJS to work) in Pimcore 11. - [Database] Deprecated `Pimcore\Db\Helper::insertOrUpdate()` method, please use `Pimcore\Db\Helper::upsert()` instead. - Deprecated `getJsPaths`, `getCssPaths`, `getEditmodeJsPaths` and `getEditmodeCssPaths` in `AbstractPimcoreBundle`. Please use the `PimcoreBundleAdminSupportInterface` and the `BundleAdminSupportTrait` instead. +- [Events] Deprecated Admin Event classes (below), please use these classes from AdminBundle instead. + - `Pimcore\Event\AdminEvents` + - `Pimcore\Event\Admin\AdminStyleEvent` + - `Pimcore\Event\Admin\IndexActionSettingsEvent` + - `Pimcore\Event\Admin\Login\*` + - `Pimcore\Event\Model\AssetDeleteInfoEvent` + - `Pimcore\Event\Model\DocumentDeleteInfoEvent` + - `Pimcore\Event\Model\ObjectDeleteInfoEvent` + - `Pimcore\Event\Model\ElementDeleteInfoEventInterface` ## 10.5.13 - [Web2Print] Print document twig expressions are now executed in a sandbox with restrictive security policies (just like Sending mails and Dataobject Text Layouts introduced in 10.5.9). diff --git a/doc/Development_Documentation/26_Best_Practice/60_Modifying_Permissions_based_on_Object_Data.md b/doc/Development_Documentation/26_Best_Practice/60_Modifying_Permissions_based_on_Object_Data.md index 566dcef047f..a75b64ae058 100644 --- a/doc/Development_Documentation/26_Best_Practice/60_Modifying_Permissions_based_on_Object_Data.md +++ b/doc/Development_Documentation/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/10.5/lib/Event/AdminEvents.php#L292-L304) +The event [`OBJECT_GET_PRE_SEND_DATA`](https://github.com/pimcore/pimcore/blob/10.5/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/Event/Admin/ElementAdminStyleEvent.php b/lib/Event/Admin/ElementAdminStyleEvent.php index 67d8d79f169..9693dfcbc91 100644 --- a/lib/Event/Admin/ElementAdminStyleEvent.php +++ b/lib/Event/Admin/ElementAdminStyleEvent.php @@ -17,103 +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; - - /** - * @var int - */ - protected $context; - - /** - * @var ElementInterface - */ - protected $element; - - /** - * @var AdminStyle - */ - protected $adminStyle; - - /** - * ElementAdminStyleEvent constructor. - * - * @param ElementInterface $element - * @param AdminStyle $adminStyle - * @param null|int $context - */ - public function __construct(ElementInterface $element, AdminStyle $adminStyle, $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; - } - - /** - * 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/lib/Event/Admin/IndexActionSettingsEvent.php b/lib/Event/Admin/IndexActionSettingsEvent.php index b1d925f2f69..882ca884c7c 100644 --- a/lib/Event/Admin/IndexActionSettingsEvent.php +++ b/lib/Event/Admin/IndexActionSettingsEvent.php @@ -17,36 +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 { - /** - * @var array - */ - private $settings; - - public function __construct(array $settings) - { - $this->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/lib/Event/Admin/Login/LoginCredentialsEvent.php b/lib/Event/Admin/Login/LoginCredentialsEvent.php index e2b1df3e7d9..9b9f15f21f6 100644 --- a/lib/Event/Admin/Login/LoginCredentialsEvent.php +++ b/lib/Event/Admin/Login/LoginCredentialsEvent.php @@ -15,42 +15,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; - - /** - * @var array - */ - protected $credentials; - - /** - * @param Request $request - * @param array $credentials - */ - public function __construct(Request $request, array $credentials) - { - $this->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/lib/Event/Admin/Login/LoginFailedEvent.php b/lib/Event/Admin/Login/LoginFailedEvent.php index ded46f9d083..64cef660bed 100644 --- a/lib/Event/Admin/Login/LoginFailedEvent.php +++ b/lib/Event/Admin/Login/LoginFailedEvent.php @@ -15,77 +15,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 { - /** - * @var array - */ - protected $credentials; - - /** - * @var User - */ - protected $user; - - /** - * @param array $credentials - */ - public function __construct(array $credentials) - { - $this->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/lib/Event/Admin/Login/LoginRedirectEvent.php b/lib/Event/Admin/Login/LoginRedirectEvent.php index bf485dd53e5..dff8e90b98a 100644 --- a/lib/Event/Admin/Login/LoginRedirectEvent.php +++ b/lib/Event/Admin/Login/LoginRedirectEvent.php @@ -15,59 +15,9 @@ namespace Pimcore\Event\Admin\Login; -use Symfony\Contracts\EventDispatcher\Event; - -class LoginRedirectEvent extends Event +/** + * @deprecated and will be removed in Pimcore 11. Use Pimcore\Bundle\AdminBundle\Event\Login\LoginRedirectEvent instead + */ +class LoginRedirectEvent extends \Pimcore\Bundle\AdminBundle\Event\Login\LoginRedirectEvent { - /** - * @var string - */ - protected $routeName; - - /** - * @var array - */ - protected $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/lib/Event/Admin/Login/LogoutEvent.php b/lib/Event/Admin/Login/LogoutEvent.php index 03613abac2f..cce86834667 100644 --- a/lib/Event/Admin/Login/LogoutEvent.php +++ b/lib/Event/Admin/Login/LogoutEvent.php @@ -15,37 +15,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; - - /** - * @var User - */ - protected $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() - { - return $this->user; - } } diff --git a/lib/Event/Admin/Login/LostPasswordEvent.php b/lib/Event/Admin/Login/LostPasswordEvent.php index 1081e77cca1..c2c33b9c3ae 100644 --- a/lib/Event/Admin/Login/LostPasswordEvent.php +++ b/lib/Event/Admin/Login/LostPasswordEvent.php @@ -15,76 +15,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; - - /** - * @var User - */ - protected $user; - - /** - * @var string - */ - protected $loginUrl; - - /** - * @var bool - */ - protected $sendMail = true; - - /** - * @param User $user - * @param string $loginUrl - */ - public function __construct(User $user, $loginUrl) - { - $this->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/lib/Event/AdminEvents.php b/lib/Event/AdminEvents.php index 0fbe51855ec..e6ae8190ace 100644 --- a/lib/Event/AdminEvents.php +++ b/lib/Event/AdminEvents.php @@ -1,554 +1,23 @@ -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; - } + use \Pimcore\Bundle\AdminBundle\Event\Traits\ElementDeleteInfoEventTrait; } From fac9c1b4e6047c14ab9ab5e946206ab111ececd7 Mon Sep 17 00:00:00 2001 From: mattamon Date: Fri, 24 Mar 2023 11:16:07 +0000 Subject: [PATCH 17/17] Apply php-cs-fixer changes --- lib/Event/AdminEvents.php | 46 +++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/lib/Event/AdminEvents.php b/lib/Event/AdminEvents.php index e6ae8190ace..7b09a42d25a 100644 --- a/lib/Event/AdminEvents.php +++ b/lib/Event/AdminEvents.php @@ -1,23 +1,23 @@ -