From 4959fb33f979af8cfae0a4d62d653610202628b7 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 29 Apr 2021 21:19:40 +0000 Subject: [PATCH 01/56] Upgrade to GitHub-native Dependabot --- .github/dependabot.yml | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..273e702 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,9 @@ +version: 2 +updates: +- package-ecosystem: composer + directory: "/" + schedule: + interval: daily + time: "04:00" + timezone: Europe/Berlin + open-pull-requests-limit: 10 From 7621a514325498ebbaf34ab44f440a8c7cea6cdd Mon Sep 17 00:00:00 2001 From: Ingolf Steinhardt Date: Wed, 29 Jun 2022 23:40:39 +0200 Subject: [PATCH 02/56] Initial commit for MM 2.3 --- composer.json | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/composer.json b/composer.json index 0711a43..5cb8159 100644 --- a/composer.json +++ b/composer.json @@ -9,13 +9,13 @@ "nontranslatable" ], "type": "contao-bundle", - "homepage": "http://now.metamodel.me/", + "homepage": "https://now.metamodel.me/", "license": "LGPL-3.0-or-later", "authors": [ { "name": "Christian Schiffler", "email": "c.schiffler@cyberspectrum.de", - "homepage": "http://www.cyberspectrum.de/", + "homepage": "https://www.cyberspectrum.de/", "role": "Developer" }, { @@ -27,19 +27,18 @@ "support": { "email": "mail@metamodel.me", "issues": "https://github.com/MetaModels/attribute_file/issues", - "wiki": "http://de.contaowiki.org/MetaModels", + "wiki": "https://de.contaowiki.org/MetaModels", "irc": "irc://irc.freenode.org/contao.mm", "source": "https://github.com/MetaModels/attribute_file" }, "require": { - "php": "^7.2", - "contao-community-alliance/dc-general": "^2.1.3", - "contao/core-bundle": "^4.9.0, <4.13.0", - "metamodels/core": "^2.1.1", - "symfony/dependency-injection": "4.4.*", - "symfony/event-dispatcher": "4.4.*", - "symfony/http-kernel": "~4.4.13", "ext-pdo": "*", + "php": "^7.4 || ^8.0", + "contao-community-alliance/dc-general": "^2.3@dev", + "contao/core-bundle": "^4.13.0, <5.0", + "metamodels/core": "^2.3@dev", + "symfony/dependency-injection": "^5.4", + "symfony/http-kernel": "^5.4", "psr/simple-cache": "^1.0", "cache/doctrine-adapter": "^1.0", "cache/array-adapter": "^1.0" @@ -66,7 +65,7 @@ "extra": { "contao-manager-plugin": "MetaModels\\AttributeFileBundle\\ContaoManager\\Plugin", "branch-alias": { - "dev-feature/2.2.0": "2.2.x-dev" + "dev-feature/2.3.0": "2.3.x-dev" } }, "config": { From d2b8a96ab1b253da8d2554adf6ab29cd41cc203f Mon Sep 17 00:00:00 2001 From: Ingolf Steinhardt Date: Mon, 4 Jul 2022 17:13:13 +0200 Subject: [PATCH 03/56] Fix doctrine --- src/Attribute/File.php | 6 +++--- .../DcGeneral/Table/DcaSetting/FileWidgetModeOptions.php | 6 +++--- src/Helper/UpgradeHandler.php | 0 3 files changed, 6 insertions(+), 6 deletions(-) create mode 100644 src/Helper/UpgradeHandler.php diff --git a/src/Attribute/File.php b/src/Attribute/File.php index 1a0c51a..e46899b 100644 --- a/src/Attribute/File.php +++ b/src/Attribute/File.php @@ -248,7 +248,7 @@ public function searchFor($strPattern) ->where($builder->expr()->in($this->getColName(), $subSelect->getSQL())) ->setParameter('value', \str_replace(['*', '?'], ['%', '_'], $strPattern)); - return $builder->execute()->fetchAll(\PDO::FETCH_COLUMN); + return $builder->executeQuery()->fetchFirstColumn(); } /** @@ -288,10 +288,10 @@ public function getDataFor($arrIds) $builder->addSelect($this->getColName() . '__sort AS file_sort'); } - $query = $builder->execute(); + $query = $builder->executeQuery(); $data = []; - while ($result = $query->fetch(\PDO::FETCH_OBJ)) { + while ($result = $query->fetchFirstColumn()) { $row = $this->toolboxFile->convertValuesToMetaModels($this->stringUtil->deserialize($result->file, true)); if ($hasSort) { diff --git a/src/EventListener/DcGeneral/Table/DcaSetting/FileWidgetModeOptions.php b/src/EventListener/DcGeneral/Table/DcaSetting/FileWidgetModeOptions.php index b0d7595..d255068 100644 --- a/src/EventListener/DcGeneral/Table/DcaSetting/FileWidgetModeOptions.php +++ b/src/EventListener/DcGeneral/Table/DcaSetting/FileWidgetModeOptions.php @@ -113,13 +113,13 @@ private function isAttributeFile(GetPropertyOptionsEvent $event): bool ->where($builder->expr()->eq('t.id', ':id')) ->setParameter('id', $event->getModel()->getProperty('attr_id')); - $statement = $builder->execute(); + $statement = $builder->executeQuery(); if (0 === $statement->columnCount()) { return false; } - $result = $statement->fetch(\PDO::FETCH_OBJ); - return 'file' === $result->type; + $result = $statement->fetchAssociative(); + return 'file' === $result['type']; } /** diff --git a/src/Helper/UpgradeHandler.php b/src/Helper/UpgradeHandler.php new file mode 100644 index 0000000..e69de29 From d1a92562738a9f2ea6a2e37cd033f6357f24f76d Mon Sep 17 00:00:00 2001 From: Ingolf Steinhardt Date: Mon, 4 Jul 2022 18:18:32 +0200 Subject: [PATCH 04/56] Fix requirements --- composer.json | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 5cb8159..5bbc526 100644 --- a/composer.json +++ b/composer.json @@ -38,10 +38,7 @@ "contao/core-bundle": "^4.13.0, <5.0", "metamodels/core": "^2.3@dev", "symfony/dependency-injection": "^5.4", - "symfony/http-kernel": "^5.4", - "psr/simple-cache": "^1.0", - "cache/doctrine-adapter": "^1.0", - "cache/array-adapter": "^1.0" + "symfony/http-kernel": "^5.4" }, "require-dev": { "contao/manager-plugin": "^2.1", From 2837364447ed0c4e21757f59d5df4ea202171132 Mon Sep 17 00:00:00 2001 From: Ingolf Steinhardt Date: Wed, 6 Jul 2022 21:30:23 +0200 Subject: [PATCH 05/56] Fix treebuilder --- src/DependencyInjection/Configuration.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 8c51c0e..2e8b63c 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -3,7 +3,7 @@ /** * This file is part of MetaModels/attribute_file. * - * (c) 2012-2019 The MetaModels team. + * (c) 2012-2022 The MetaModels team. * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -12,7 +12,8 @@ * * @package MetaModels/attribute_file * @author Sven Baumann - * @copyright 2012-2019 The MetaModels team. + * @author Ingolf Steinhardt + * @copyright 2012-2022 The MetaModels team. * @license https://github.com/MetaModels/attribute_file/blob/master/LICENSE LGPL-3.0-or-later * @filesource */ @@ -60,10 +61,10 @@ public function __construct(bool $debug, ?string $rootDir) */ public function getConfigTreeBuilder(): TreeBuilder { - $treeBuilder = new TreeBuilder(); - $rootNode = $treeBuilder->root('metamodels_attribute_file'); + $treeBuilder = new TreeBuilder('metamodels_attribute_file'); - $rootNode + $treeBuilder + ->getRootNode() ->children() ->booleanNode('enable_cache') ->defaultValue(!$this->debug) From 897279764ee3623e3c7bf091b70ce8bdcb9b5286 Mon Sep 17 00:00:00 2001 From: Ingolf Steinhardt Date: Sun, 10 Jul 2022 15:28:03 +0200 Subject: [PATCH 06/56] Fix doctrine --- composer.json | 19 ++++++++++++++++--- src/Attribute/File.php | 10 +++++----- src/Resources/config/services.yml | 4 ++-- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/composer.json b/composer.json index 5bbc526..7643d08 100644 --- a/composer.json +++ b/composer.json @@ -32,20 +32,33 @@ "source": "https://github.com/MetaModels/attribute_file" }, "require": { - "ext-pdo": "*", "php": "^7.4 || ^8.0", "contao-community-alliance/dc-general": "^2.3@dev", "contao/core-bundle": "^4.13.0, <5.0", "metamodels/core": "^2.3@dev", + "symfony/cache": "^5.4", "symfony/dependency-injection": "^5.4", "symfony/http-kernel": "^5.4" }, + "repositories": [ + { + "type": "composer", + "url": "https://token:3NGK_ffTb0VUjDNvaJnN82sXF0jI0_M9KAzTBHy3PjReTaGY_r9K1nG8DYgPcT5l@packages.cyberspectrum.de/r" + } + ], "require-dev": { "contao/manager-plugin": "^2.1", - "metamodels/contao-frontend-editing": "^2.1", + "contao-community-alliance/dependency-container": "^2.1@dev", + "contao-community-alliance/events-contao-bindings": "^4.10@dev", + "contao-community-alliance/event-dispatcher": "^2.1@dev", + "contao-community-alliance/translator": "^2.3@dev", + "discordier/justtextwidgets": "dev-release/1.3.0 as 1.3.0", + "metamodels/contao-frontend-editing": "^2.3@dev", "menatwork/contao-multicolumnwizard-bundle": "^3.4", - "phpcq/all-tasks": "^1.2" + "phpcq/all-tasks": "^1.3" }, + "minimum-stability": "dev", + "prefer-stable": true, "autoload": { "psr-4": { "MetaModels\\AttributeFileBundle\\": "src" diff --git a/src/Attribute/File.php b/src/Attribute/File.php index e46899b..8d0ea34 100644 --- a/src/Attribute/File.php +++ b/src/Attribute/File.php @@ -268,7 +268,7 @@ public function unsetDataFor($arrIds) $builder->set('t.' . $this->getColName() . '__sort', ':null'); } - $builder->execute(); + $builder->executeQuery(); } /** @@ -291,12 +291,12 @@ public function getDataFor($arrIds) $query = $builder->executeQuery(); $data = []; - while ($result = $query->fetchFirstColumn()) { - $row = $this->toolboxFile->convertValuesToMetaModels($this->stringUtil->deserialize($result->file, true)); + while ($result = $query->fetchAssociative()) { + $row = $this->toolboxFile->convertValuesToMetaModels($this->stringUtil->deserialize($result['file'], true)); if ($hasSort) { // The sort key be can remove in later version. The new sort key is bin_sorted. - $row['sort'] = $sorted = $this->stringUtil->deserialize($result->file_sort, true); + $row['sort'] = $sorted = $this->stringUtil->deserialize($result['file_sort'], true); foreach ($this->toolboxFile->convertValuesToMetaModels($sorted) as $sortedKey => $sortedValue) { $row[$sortedKey . '_sorted'] = $sortedValue; @@ -313,7 +313,7 @@ public function getDataFor($arrIds) } } - $data[$result->id] = $row; + $data[$result['id']] = $row; } return $data; diff --git a/src/Resources/config/services.yml b/src/Resources/config/services.yml index 312f470..d947a3b 100644 --- a/src/Resources/config/services.yml +++ b/src/Resources/config/services.yml @@ -5,13 +5,13 @@ services: public: true metamodels.attribute_file.cache_system: - class: Doctrine\Common\Cache\FilesystemCache + class: Symfony\Component\Cache\Adapter\FilesystemAdapter public: false arguments: - "%metamodels.attribute_file.cache_dir%" metamodels.attribute_file.cache: - class: Cache\Adapter\Doctrine\DoctrineCachePool + class: Symfony\Component\Cache\Adapter\FilesystemAdapter public: false arguments: - "@metamodels.attribute_file.cache_system" From 90dab5829cbeee3cace140dc2480e834e88eadc5 Mon Sep 17 00:00:00 2001 From: zonky Date: Mon, 22 Aug 2022 19:23:40 +0200 Subject: [PATCH 07/56] Fix PHP 8 warnings --- src/Resources/contao/templates/mm_attr_file.html5 | 2 +- src/Resources/contao/templates/mm_attr_file_alternative.html5 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Resources/contao/templates/mm_attr_file.html5 b/src/Resources/contao/templates/mm_attr_file.html5 index 1a0d92b..e4a31b3 100644 --- a/src/Resources/contao/templates/mm_attr_file.html5 +++ b/src/Resources/contao/templates/mm_attr_file.html5 @@ -7,7 +7,7 @@ ?>
  • settings->get('file_showImage')): ?> -
    style=""> +
    style=""> settings->get('file_showLink')): ?> diff --git a/src/Resources/contao/templates/mm_attr_file_alternative.html5 b/src/Resources/contao/templates/mm_attr_file_alternative.html5 index a476808..136da9c 100644 --- a/src/Resources/contao/templates/mm_attr_file_alternative.html5 +++ b/src/Resources/contao/templates/mm_attr_file_alternative.html5 @@ -2,7 +2,7 @@ src as $arrFile): ?>
    settings->get('file_showImage')): ?> -
    style=""> +
    style=""> settings->get('file_showLink')): ?> From 29ad615b851480d1eada221129e9fe0d706acf36 Mon Sep 17 00:00:00 2001 From: e-spin Date: Mon, 12 Sep 2022 21:10:16 +0200 Subject: [PATCH 08/56] Fix PHP 8 warning --- src/Attribute/File.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Attribute/File.php b/src/Attribute/File.php index 8d0ea34..5ef342a 100644 --- a/src/Attribute/File.php +++ b/src/Attribute/File.php @@ -340,7 +340,7 @@ public function setDataFor($arrValues) if ($this->get('file_multiple')) { $files = \serialize($files); } else { - $files = $files[0]; + $files = $files[0] ?? null; } $this->connection @@ -350,7 +350,7 @@ public function setDataFor($arrValues) ->where('t.id=:id') ->setParameter($this->getColName(), $files) ->setParameter('id', $id) - ->execute(); + ->executeQuery(); } } @@ -411,7 +411,7 @@ public function serializeData($mixValues) return \serialize($data); } - return $data[0]; + return $data[0] ?? ''; } /** From d04b29e218467d4808e4148cad03bd56ed01fe97 Mon Sep 17 00:00:00 2001 From: e-spin Date: Tue, 13 Sep 2022 09:47:58 +0200 Subject: [PATCH 09/56] Fix PHP 8 warning --- src/EventListener/BuildFrontendUploadListener.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/EventListener/BuildFrontendUploadListener.php b/src/EventListener/BuildFrontendUploadListener.php index 935983c..05cbb2a 100644 --- a/src/EventListener/BuildFrontendUploadListener.php +++ b/src/EventListener/BuildFrontendUploadListener.php @@ -320,7 +320,7 @@ private function replaceInsertTag(BuildAttributeEvent $event, string $replace): $this->getInputProvider()->setValue($this->columnId->getName(), $this->autoincrement); } - $replaced = $this->replaceParam->replace( + $replaced = (string) $this->replaceParam->replace( $this->replaceTableName->replace( $event->getContainer()->getName(), StringUtil::decodeEntities($replace) From a5131ee3a5409f8ed04b09ba6c1ca4a188f492bf Mon Sep 17 00:00:00 2001 From: Ingolf Steinhardt Date: Mon, 24 Oct 2022 16:56:52 +0200 Subject: [PATCH 10/56] Fix requirements --- composer.json | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/composer.json b/composer.json index 7643d08..fb871c5 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,7 @@ "source": "https://github.com/MetaModels/attribute_file" }, "require": { - "php": "^7.4 || ^8.0", + "php": "^8.1", "contao-community-alliance/dc-general": "^2.3@dev", "contao/core-bundle": "^4.13.0, <5.0", "metamodels/core": "^2.3@dev", @@ -40,25 +40,12 @@ "symfony/dependency-injection": "^5.4", "symfony/http-kernel": "^5.4" }, - "repositories": [ - { - "type": "composer", - "url": "https://token:3NGK_ffTb0VUjDNvaJnN82sXF0jI0_M9KAzTBHy3PjReTaGY_r9K1nG8DYgPcT5l@packages.cyberspectrum.de/r" - } - ], "require-dev": { "contao/manager-plugin": "^2.1", - "contao-community-alliance/dependency-container": "^2.1@dev", - "contao-community-alliance/events-contao-bindings": "^4.10@dev", - "contao-community-alliance/event-dispatcher": "^2.1@dev", - "contao-community-alliance/translator": "^2.3@dev", - "discordier/justtextwidgets": "dev-release/1.3.0 as 1.3.0", "metamodels/contao-frontend-editing": "^2.3@dev", "menatwork/contao-multicolumnwizard-bundle": "^3.4", "phpcq/all-tasks": "^1.3" }, - "minimum-stability": "dev", - "prefer-stable": true, "autoload": { "psr-4": { "MetaModels\\AttributeFileBundle\\": "src" From e82e84ec3318d2237857d9ea8b0720031aceb2f3 Mon Sep 17 00:00:00 2001 From: Ingolf Steinhardt Date: Mon, 24 Oct 2022 17:26:13 +0200 Subject: [PATCH 11/56] Fix PHP 8 warning --- src/Attribute/File.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Attribute/File.php b/src/Attribute/File.php index 5ef342a..971b8c3 100644 --- a/src/Attribute/File.php +++ b/src/Attribute/File.php @@ -520,7 +520,7 @@ protected function prepareTemplate(Template $template, $rowData, $settings) $value = $rowData[$this->getColName()]; // No data and show image, check placeholder. - if (!$value['bin'] ?? null) { + if (!($value['bin'] ?? null)) { if (null === $settings->get('file_showImage') || null === ($placeholder = $settings->get('file_placeholder'))) { $template->files = []; @@ -529,7 +529,7 @@ protected function prepareTemplate(Template $template, $rowData, $settings) return; } - $value['bin'][] = $placeholder; + $value['bin'][] = $placeholder; $value['value'][] = StringUtil::binToUuid($placeholder); } From 48bc4428dff15dfd2301020e3b45d5c1427411c8 Mon Sep 17 00:00:00 2001 From: Ingolf Steinhardt Date: Tue, 25 Oct 2022 19:22:56 +0200 Subject: [PATCH 12/56] Fix PHP 8 warning --- src/Attribute/File.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Attribute/File.php b/src/Attribute/File.php index 971b8c3..4c7ae00 100644 --- a/src/Attribute/File.php +++ b/src/Attribute/File.php @@ -517,7 +517,7 @@ protected function prepareTemplate(Template $template, $rowData, $settings) { parent::prepareTemplate($template, $rowData, $settings); - $value = $rowData[$this->getColName()]; + $value = $rowData[$this->getColName()] ?? null; // No data and show image, check placeholder. if (!($value['bin'] ?? null)) { From 04106459a799842dc590a64a58ae8650175cd471 Mon Sep 17 00:00:00 2001 From: Ingolf Steinhardt Date: Mon, 31 Oct 2022 15:29:13 +0100 Subject: [PATCH 13/56] Fix delete old UpgradeHandler --- src/Helper/UpgradeHandler.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 src/Helper/UpgradeHandler.php diff --git a/src/Helper/UpgradeHandler.php b/src/Helper/UpgradeHandler.php deleted file mode 100644 index e69de29..0000000 From 53fa727a1486c5ee14eefcc9bb19bebe62f3c9ec Mon Sep 17 00:00:00 2001 From: Ingolf Steinhardt Date: Fri, 18 Nov 2022 19:14:53 +0100 Subject: [PATCH 14/56] fix composer --- composer.json | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 979bec8..46e747b 100644 --- a/composer.json +++ b/composer.json @@ -32,16 +32,12 @@ "source": "https://github.com/MetaModels/attribute_file" }, "require": { - "php": "^7.4 || ^8.0", - "ext-pdo": "*", - "cache/array-adapter": "^1.0", - "cache/doctrine-adapter": "^1.0", + "php": "^8.1", "contao-community-alliance/dc-general": "^2.3@dev", "contao/core-bundle": "^4.13.0, <5.0", "metamodels/core": "^2.3@dev", "symfony/cache": "^5.4", "symfony/dependency-injection": "^5.4", - "symfony/event-dispatcher": "^5.4", "symfony/http-kernel": "^5.4" }, "require-dev": { From 19fd9c72447cc5be2d0fa5ac604abc91297f3be5 Mon Sep 17 00:00:00 2001 From: Christian Schiffler Date: Wed, 14 Sep 2022 09:58:42 +0200 Subject: [PATCH 15/56] Implement schema generator --- src/Attribute/File.php | 3 +- src/Resources/config/event_listener.yml | 4 + src/Schema/DoctrineSchemaGenerator.php | 57 ++++++++++++ .../MetaModelsAttributeFileExtensionTest.php | 49 +++++++++++ tests/Schema/DoctrineSchemaGeneratorTest.php | 88 +++++++++++++++++++ 5 files changed, 200 insertions(+), 1 deletion(-) create mode 100644 src/Schema/DoctrineSchemaGenerator.php create mode 100644 tests/Schema/DoctrineSchemaGeneratorTest.php diff --git a/src/Attribute/File.php b/src/Attribute/File.php index 175a1dc..f3f2c82 100644 --- a/src/Attribute/File.php +++ b/src/Attribute/File.php @@ -39,6 +39,7 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Platforms\Keywords\KeywordList; use MetaModels\Attribute\BaseComplex; +use MetaModels\Attribute\ISchemaManagedAttribute; use MetaModels\Helper\TableManipulator; use MetaModels\Helper\ToolboxFile; use MetaModels\IMetaModel; @@ -47,7 +48,7 @@ /** * This is the MetaModel attribute class for handling file fields. */ -class File extends BaseComplex +class File extends BaseComplex implements ISchemaManagedAttribute { /** * The database connection. diff --git a/src/Resources/config/event_listener.yml b/src/Resources/config/event_listener.yml index d797295..5bdb62e 100644 --- a/src/Resources/config/event_listener.yml +++ b/src/Resources/config/event_listener.yml @@ -66,3 +66,7 @@ services: tags: - name: kernel.event_listener event: dc-general.view.contao2backend.get-property-options + + MetaModels\AttributeFileBundle\Schema\DoctrineSchemaGenerator: + tags: + - { name: 'metamodels.schema-generator.doctrine' } diff --git a/src/Schema/DoctrineSchemaGenerator.php b/src/Schema/DoctrineSchemaGenerator.php new file mode 100644 index 0000000..e6e3d05 --- /dev/null +++ b/src/Schema/DoctrineSchemaGenerator.php @@ -0,0 +1,57 @@ + + * @copyright 2012-2019 The MetaModels team. + * @license https://github.com/MetaModels/attribute_file/blob/master/LICENSE LGPL-3.0-or-later + * @filesource + */ + +declare(strict_types = 1); + +namespace MetaModels\AttributeFileBundle\Schema; + +use Doctrine\DBAL\Schema\Table; +use Doctrine\DBAL\Types\Type; +use MetaModels\Information\AttributeInformation; +use MetaModels\Schema\Doctrine\AbstractAttributeTypeSchemaGenerator; + +/** + * This adds all alias columns to doctrine tables schemas. + */ +class DoctrineSchemaGenerator extends AbstractAttributeTypeSchemaGenerator +{ + /** + * {@inheritDoc} + */ + protected function getTypeName(): string + { + return 'file'; + } + + /** + * {@inheritDoc} + */ + protected function generateAttribute(Table $tableSchema, AttributeInformation $attribute): void + { + $this->setColumnData($tableSchema, $attribute->getName(), Type::BLOB, [ + 'notnull' => false, + ]); + + if ($attribute->getConfigurationValue('file_multiple')) { + $this->setColumnData($tableSchema, $attribute->getName() . '__sort', Type::BLOB, [ + 'notnull' => false, + ]); + } + } +} diff --git a/tests/DependencyInjection/MetaModelsAttributeFileExtensionTest.php b/tests/DependencyInjection/MetaModelsAttributeFileExtensionTest.php index 76758f5..6135f37 100644 --- a/tests/DependencyInjection/MetaModelsAttributeFileExtensionTest.php +++ b/tests/DependencyInjection/MetaModelsAttributeFileExtensionTest.php @@ -23,6 +23,10 @@ use MetaModels\AttributeFileBundle\Attribute\AttributeTypeFactory; use MetaModels\AttributeFileBundle\DependencyInjection\MetaModelsAttributeFileExtension; use MetaModels\ContaoFrontendEditingBundle\MetaModelsContaoFrontendEditingBundle; +use MetaModels\AttributeFileBundle\EventListener\BuildAttributeListener; +use MetaModels\AttributeFileBundle\EventListener\BuildDataDefinitionListener; +use MetaModels\AttributeFileBundle\EventListener\ImageSizeOptionsListener; +use MetaModels\AttributeFileBundle\Schema\DoctrineSchemaGenerator; use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; @@ -70,6 +74,51 @@ function ($value) { $this->assertEquals(AttributeTypeFactory::class, $value->getClass()); $this->assertCount(1, $value->getTag('metamodels.attribute_factory')); + return true; + } + ) + ], + [ + 'metamodels.attribute_file.event_listener.image_size_options', + $this->callback(function ($value) { + /** @var Definition $value */ + $this->assertInstanceOf(Definition::class, $value); + $this->assertEquals(ImageSizeOptionsListener::class, $value->getClass()); + $this->assertCount(1, $value->getTag('kernel.event_listener')); + + return true; + }) + ], + [ + 'metamodels.attribute_file.event_listener.build_attribute', + $this->callback(function ($value) { + /** @var Definition $value */ + $this->assertInstanceOf(Definition::class, $value); + $this->assertEquals(BuildAttributeListener::class, $value->getClass()); + $this->assertCount(1, $value->getTag('kernel.event_listener')); + + return true; + }) + ], + [ + 'metamodels.attribute_file.event_listener.build-data-definition', + $this->callback(function ($value) { + /** @var Definition $value */ + $this->assertInstanceOf(Definition::class, $value); + $this->assertEquals(BuildDataDefinitionListener::class, $value->getClass()); + $this->assertCount(1, $value->getTag('kernel.event_listener')); + + return true; + }) + ], + [ + DoctrineSchemaGenerator::class, + $this->callback( + function ($value) { + /** @var Definition $value */ + $this->assertInstanceOf(Definition::class, $value); + $this->assertCount(1, $value->getTag('metamodels.schema-generator.doctrine')); + return true; } ) diff --git a/tests/Schema/DoctrineSchemaGeneratorTest.php b/tests/Schema/DoctrineSchemaGeneratorTest.php new file mode 100644 index 0000000..02746cd --- /dev/null +++ b/tests/Schema/DoctrineSchemaGeneratorTest.php @@ -0,0 +1,88 @@ + + * @copyright 2012-2019 The MetaModels team. + * @license https://github.com/MetaModels/attribute_file/blob/master/LICENSE LGPL-3.0-or-later + * @filesource + */ + +declare(strict_types = 1); + +namespace MetaModels\AttributeFileBundle\Test\Schema; + +use Doctrine\DBAL\Schema\Table; +use Doctrine\DBAL\Types\Type; +use MetaModels\AttributeFileBundle\Schema\DoctrineSchemaGenerator; +use MetaModels\Information\AttributeInformation; +use PHPUnit\Framework\TestCase; + +/** + * This tests the schema generator. + */ +class DoctrineSchemaGeneratorTest extends TestCase +{ + /** + * Test the generate method. + * + * @return void + */ + public function testGenerate(): void + { + $instance = new DoctrineSchemaGenerator(); + $reflection = new \ReflectionMethod(DoctrineSchemaGenerator::class, 'generateAttribute'); + $reflection->setAccessible(true); + + $tableSchema = new Table('mm_test'); + $attribute = new AttributeInformation('test', 'file', ['file_multiple' => false]); + + $reflection->invoke($instance, $tableSchema, $attribute); + + $this->assertTrue($tableSchema->hasColumn('test')); + $column = $tableSchema->getColumn('test'); + $this->assertSame('test', $column->getName()); + $this->assertSame(Type::getType(Type::BLOB), $column->getType()); + $this->assertSame(false, $column->getNotnull()); + + $this->assertFalse($tableSchema->hasColumn('test__sort')); + } + + /** + * Test the generate method. + * + * @return void + */ + public function testGenerateForMultiple(): void + { + $instance = new DoctrineSchemaGenerator(); + $reflection = new \ReflectionMethod(DoctrineSchemaGenerator::class, 'generateAttribute'); + $reflection->setAccessible(true); + + $tableSchema = new Table('mm_test'); + $attribute = new AttributeInformation('test', 'file', ['file_multiple' => true]); + + $reflection->invoke($instance, $tableSchema, $attribute); + + $this->assertTrue($tableSchema->hasColumn('test')); + $column = $tableSchema->getColumn('test'); + $this->assertSame('test', $column->getName()); + $this->assertSame(Type::getType(Type::BLOB), $column->getType()); + $this->assertSame(false, $column->getNotnull()); + + $this->assertTrue($tableSchema->hasColumn('test__sort')); + $column = $tableSchema->getColumn('test__sort'); + $this->assertSame('test__sort', $column->getName()); + $this->assertSame(Type::getType(Type::BLOB), $column->getType()); + $this->assertSame(false, $column->getNotnull()); + } +} From bb5360b0004cd90a6798fd823f34296c184438d1 Mon Sep 17 00:00:00 2001 From: Christian Schiffler Date: Wed, 14 Sep 2022 10:10:59 +0200 Subject: [PATCH 16/56] Update schema generating --- src/Schema/DoctrineSchemaGenerator.php | 6 +++--- tests/Schema/DoctrineSchemaGeneratorTest.php | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Schema/DoctrineSchemaGenerator.php b/src/Schema/DoctrineSchemaGenerator.php index e6e3d05..e1e7b13 100644 --- a/src/Schema/DoctrineSchemaGenerator.php +++ b/src/Schema/DoctrineSchemaGenerator.php @@ -22,7 +22,7 @@ namespace MetaModels\AttributeFileBundle\Schema; use Doctrine\DBAL\Schema\Table; -use Doctrine\DBAL\Types\Type; +use Doctrine\DBAL\Types\Types; use MetaModels\Information\AttributeInformation; use MetaModels\Schema\Doctrine\AbstractAttributeTypeSchemaGenerator; @@ -44,12 +44,12 @@ protected function getTypeName(): string */ protected function generateAttribute(Table $tableSchema, AttributeInformation $attribute): void { - $this->setColumnData($tableSchema, $attribute->getName(), Type::BLOB, [ + $this->setColumnData($tableSchema, $attribute->getName(), Types::BLOB, [ 'notnull' => false, ]); if ($attribute->getConfigurationValue('file_multiple')) { - $this->setColumnData($tableSchema, $attribute->getName() . '__sort', Type::BLOB, [ + $this->setColumnData($tableSchema, $attribute->getName() . '__sort', Types::BLOB, [ 'notnull' => false, ]); } diff --git a/tests/Schema/DoctrineSchemaGeneratorTest.php b/tests/Schema/DoctrineSchemaGeneratorTest.php index 02746cd..d4d08b4 100644 --- a/tests/Schema/DoctrineSchemaGeneratorTest.php +++ b/tests/Schema/DoctrineSchemaGeneratorTest.php @@ -23,6 +23,7 @@ use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Types\Type; +use Doctrine\DBAL\Types\Types; use MetaModels\AttributeFileBundle\Schema\DoctrineSchemaGenerator; use MetaModels\Information\AttributeInformation; use PHPUnit\Framework\TestCase; @@ -51,7 +52,7 @@ public function testGenerate(): void $this->assertTrue($tableSchema->hasColumn('test')); $column = $tableSchema->getColumn('test'); $this->assertSame('test', $column->getName()); - $this->assertSame(Type::getType(Type::BLOB), $column->getType()); + $this->assertSame(Type::getType(Types::BLOB), $column->getType()); $this->assertSame(false, $column->getNotnull()); $this->assertFalse($tableSchema->hasColumn('test__sort')); @@ -76,13 +77,13 @@ public function testGenerateForMultiple(): void $this->assertTrue($tableSchema->hasColumn('test')); $column = $tableSchema->getColumn('test'); $this->assertSame('test', $column->getName()); - $this->assertSame(Type::getType(Type::BLOB), $column->getType()); + $this->assertSame(Type::getType(Types::BLOB), $column->getType()); $this->assertSame(false, $column->getNotnull()); $this->assertTrue($tableSchema->hasColumn('test__sort')); $column = $tableSchema->getColumn('test__sort'); $this->assertSame('test__sort', $column->getName()); - $this->assertSame(Type::getType(Type::BLOB), $column->getType()); + $this->assertSame(Type::getType(Types::BLOB), $column->getType()); $this->assertSame(false, $column->getNotnull()); } } From 8df89ca690cf2c582da7094da00b2141765728b5 Mon Sep 17 00:00:00 2001 From: Christian Schiffler Date: Mon, 24 Oct 2022 17:30:59 +0200 Subject: [PATCH 17/56] Remove ISchemaManagedAttribute again Rather use the kernel parameter instead --- src/Attribute/File.php | 3 +-- src/DependencyInjection/MetaModelsAttributeFileExtension.php | 4 ++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Attribute/File.php b/src/Attribute/File.php index f3f2c82..175a1dc 100644 --- a/src/Attribute/File.php +++ b/src/Attribute/File.php @@ -39,7 +39,6 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Platforms\Keywords\KeywordList; use MetaModels\Attribute\BaseComplex; -use MetaModels\Attribute\ISchemaManagedAttribute; use MetaModels\Helper\TableManipulator; use MetaModels\Helper\ToolboxFile; use MetaModels\IMetaModel; @@ -48,7 +47,7 @@ /** * This is the MetaModel attribute class for handling file fields. */ -class File extends BaseComplex implements ISchemaManagedAttribute +class File extends BaseComplex { /** * The database connection. diff --git a/src/DependencyInjection/MetaModelsAttributeFileExtension.php b/src/DependencyInjection/MetaModelsAttributeFileExtension.php index c57eeeb..6bfd5e2 100644 --- a/src/DependencyInjection/MetaModelsAttributeFileExtension.php +++ b/src/DependencyInjection/MetaModelsAttributeFileExtension.php @@ -54,6 +54,10 @@ public function load(array $configs, ContainerBuilder $container) } $this->addFrontendEditingArgument($container, $frontendEditing); + + $managedSchemaTypeNames = $container->getParameter('metamodels.managed-schema-type-names') ?? []; + $managedSchemaTypeNames[] = 'file'; + $container->setParameter('metamodels.managed-schema-type-names', $managedSchemaTypeNames); } /** From fa95d740f8dfffd05bdf0c5bccfe6a1c24d10b92 Mon Sep 17 00:00:00 2001 From: Ingolf Steinhardt Date: Wed, 28 Dec 2022 17:50:14 +0100 Subject: [PATCH 18/56] Fix length --- src/Schema/DoctrineSchemaGenerator.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Schema/DoctrineSchemaGenerator.php b/src/Schema/DoctrineSchemaGenerator.php index e1e7b13..2200660 100644 --- a/src/Schema/DoctrineSchemaGenerator.php +++ b/src/Schema/DoctrineSchemaGenerator.php @@ -3,7 +3,7 @@ /** * This file is part of MetaModels/attribute_file. * - * (c) 2012-2019 The MetaModels team. + * (c) 2012-2022 The MetaModels team. * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -12,7 +12,8 @@ * * @package MetaModels/attribute_file * @author Christian Schiffler - * @copyright 2012-2019 The MetaModels team. + * @author Ingolf Steinhardt + * @copyright 2012-2022 The MetaModels team. * @license https://github.com/MetaModels/attribute_file/blob/master/LICENSE LGPL-3.0-or-later * @filesource */ @@ -46,11 +47,13 @@ protected function generateAttribute(Table $tableSchema, AttributeInformation $a { $this->setColumnData($tableSchema, $attribute->getName(), Types::BLOB, [ 'notnull' => false, + 'length' => 65535, ]); if ($attribute->getConfigurationValue('file_multiple')) { $this->setColumnData($tableSchema, $attribute->getName() . '__sort', Types::BLOB, [ 'notnull' => false, + 'length' => 65535, ]); } } From f06aa52a5403bf3399242888bec7250f330bd15b Mon Sep 17 00:00:00 2001 From: Ingolf Steinhardt Date: Thu, 29 Dec 2022 10:08:06 +0100 Subject: [PATCH 19/56] Fix CS --- .../MetaModelsAttributeFileExtension.php | 7 ++++--- src/Schema/DoctrineSchemaGenerator.php | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/DependencyInjection/MetaModelsAttributeFileExtension.php b/src/DependencyInjection/MetaModelsAttributeFileExtension.php index 6bfd5e2..c88b8ac 100644 --- a/src/DependencyInjection/MetaModelsAttributeFileExtension.php +++ b/src/DependencyInjection/MetaModelsAttributeFileExtension.php @@ -3,7 +3,7 @@ /** * This file is part of MetaModels/attribute_file. * - * (c) 2012-2020 The MetaModels team. + * (c) 2012-2022 The MetaModels team. * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -13,7 +13,8 @@ * @package MetaModels/attribute_file * @author Christian Schiffler * @author Sven Baumann - * @copyright 2012-2020 The MetaModels team. + * @author Ingolf Steinhardt + * @copyright 2012-2022 The MetaModels team. * @license https://github.com/MetaModels/attribute_file/blob/master/LICENSE LGPL-3.0-or-later * @filesource */ @@ -55,7 +56,7 @@ public function load(array $configs, ContainerBuilder $container) $this->addFrontendEditingArgument($container, $frontendEditing); - $managedSchemaTypeNames = $container->getParameter('metamodels.managed-schema-type-names') ?? []; + $managedSchemaTypeNames = $container->getParameter('metamodels.managed-schema-type-names') ?? []; $managedSchemaTypeNames[] = 'file'; $container->setParameter('metamodels.managed-schema-type-names', $managedSchemaTypeNames); } diff --git a/src/Schema/DoctrineSchemaGenerator.php b/src/Schema/DoctrineSchemaGenerator.php index 2200660..1779cef 100644 --- a/src/Schema/DoctrineSchemaGenerator.php +++ b/src/Schema/DoctrineSchemaGenerator.php @@ -47,7 +47,7 @@ protected function generateAttribute(Table $tableSchema, AttributeInformation $a { $this->setColumnData($tableSchema, $attribute->getName(), Types::BLOB, [ 'notnull' => false, - 'length' => 65535, + 'length' => 65535, ]); if ($attribute->getConfigurationValue('file_multiple')) { From d97880f5c50793285076bfb2b1785d025a56454b Mon Sep 17 00:00:00 2001 From: e-spin Date: Mon, 13 Feb 2023 22:14:07 +0100 Subject: [PATCH 20/56] Fix migration --- src/Attribute/File.php | 18 +++- src/Attribute/FileOrder.php | 6 +- .../HandleUpdateAttributeListener.php | 93 ------------------- src/Migration/AddSortFieldMigration.php | 39 +++++--- src/Resources/config/event_listener.yml | 13 --- 5 files changed, 46 insertions(+), 123 deletions(-) delete mode 100644 src/EventListener/HandleUpdateAttributeListener.php diff --git a/src/Attribute/File.php b/src/Attribute/File.php index 175a1dc..e76433d 100644 --- a/src/Attribute/File.php +++ b/src/Attribute/File.php @@ -3,7 +3,7 @@ /** * This file is part of MetaModels/attribute_file. * - * (c) 2012-2022 The MetaModels team. + * (c) 2012-2023 The MetaModels team. * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -23,7 +23,7 @@ * @author David Molineus * @author Sven Baumann * @author Ingolf Steinhardt - * @copyright 2012-2022 The MetaModels team. + * @copyright 2012-2023 The MetaModels team. * @license https://github.com/MetaModels/attribute_file/blob/master/LICENSE LGPL-3.0-or-later * @filesource */ @@ -198,6 +198,13 @@ public function __construct( */ public function destroyAUX() { + if ($this->isManagedAttribute($this->get('type'))) { + $this->triggerDeprecationShouldNotCallManaged(static::class, __METHOD__); + return; + } + + $this->triggerDeprecationIsUnmanagedAttribute(static::class, __METHOD__); + parent::destroyAUX(); $metaModel = $this->getMetaModel()->getTableName(); @@ -217,6 +224,13 @@ public function destroyAUX() */ public function initializeAUX() { + if ($this->isManagedAttribute($this->get('type'))) { + $this->triggerDeprecationShouldNotCallManaged(static::class, __METHOD__); + return; + } + + $this->triggerDeprecationIsUnmanagedAttribute(static::class, __METHOD__); + parent::initializeAUX(); if ($colName = $this->getColName()) { $tableName = $this->getMetaModel()->getTableName(); diff --git a/src/Attribute/FileOrder.php b/src/Attribute/FileOrder.php index 86c6ad6..0babfbf 100644 --- a/src/Attribute/FileOrder.php +++ b/src/Attribute/FileOrder.php @@ -3,7 +3,7 @@ /** * This file is part of MetaModels/attribute_file. * - * (c) 2012-2022 The MetaModels team. + * (c) 2012-2023 The MetaModels team. * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -15,7 +15,7 @@ * @author Sven Baumann * @author Stefan Heimes * @author Ingolf Steinhardt - * @copyright 2012-2022 The MetaModels team. + * @copyright 2012-2023 The MetaModels team. * @license https://github.com/MetaModels/attribute_file/blob/master/LICENSE LGPL-3.0-or-later * @filesource */ @@ -202,7 +202,7 @@ public function setDataFor($arrValues) ->where('t.id=:id') ->setParameter($this->getColName(), $value ?: $this->serializeData([])) ->setParameter('id', $id) - ->execute(); + ->executeQuery(); } } diff --git a/src/EventListener/HandleUpdateAttributeListener.php b/src/EventListener/HandleUpdateAttributeListener.php deleted file mode 100644 index a01702e..0000000 --- a/src/EventListener/HandleUpdateAttributeListener.php +++ /dev/null @@ -1,93 +0,0 @@ - - * @author Sven Baumann - * @copyright 2012-2019 The MetaModels team. - * @license https://github.com/MetaModels/attribute_file/blob/master/LICENSE LGPL-3.0-or-later - * @filesource - */ - -namespace MetaModels\AttributeFileBundle\EventListener; - -use ContaoCommunityAlliance\DcGeneral\Event\PostPersistModelEvent; -use Doctrine\DBAL\Connection; -use MetaModels\Factory; -use MetaModels\Helper\TableManipulator; - -/** - * Class HandleUpdateAttributeListener - */ -class HandleUpdateAttributeListener extends BaseListener -{ - /** - * The doctrine dbal connection. - * - * @var Connection - */ - private $connection; - - /** - * The table manipulator. - * - * @var TableManipulator - */ - private $tableManipulator; - - /** - * HandleUpdateAttributeListener constructor. - * - * @param Factory $factory The attribute factory. - * @param Connection $connection The doctrine dbal connection. - * @param TableManipulator $tableManipulator The table manipulator. - */ - public function __construct(Factory $factory, Connection $connection, TableManipulator $tableManipulator) - { - parent::__construct($factory); - - $this->connection = $connection; - $this->tableManipulator = $tableManipulator; - } - - /** - * Handle the update of the file attribute, if switch on for file multiple. - * - * @param PostPersistModelEvent $event The event. - * - * @return void - * - * @throws \Exception If column not exist in the table. - */ - public function handleUpdateAttribute(PostPersistModelEvent $event) - { - $model = $event->getModel(); - - if (('file' !== $model->getProperty('type')) - || (!$model->getProperty('file_multiple')) - || ('tl_metamodel_attribute' !== $event->getEnvironment()->getDataDefinition()->getName()) - ) { - return; - } - - $metaModelsName = $this->getFactory()->translateIdToMetaModelName($model->getProperty('pid')); - $metaModel = $this->getFactory()->getMetaModel($metaModelsName); - $attributeName = $model->getProperty('colname') . '__sort'; - $tableColumns = $this->connection->getSchemaManager()->listTableColumns($metaModel->getTableName()); - - if (\array_key_exists($attributeName, $tableColumns)) { - return; - } - - $this->tableManipulator->createColumn($metaModel->getTableName(), $attributeName, 'blob NULL'); - } -} diff --git a/src/Migration/AddSortFieldMigration.php b/src/Migration/AddSortFieldMigration.php index 5a4b624..41aee50 100644 --- a/src/Migration/AddSortFieldMigration.php +++ b/src/Migration/AddSortFieldMigration.php @@ -3,7 +3,7 @@ /** * This file is part of MetaModels/attribute_file. * - * (c) 2012-2022 The MetaModels team. + * (c) 2012-2023 The MetaModels team. * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -13,7 +13,7 @@ * @package MetaModels/attribute_file * @author Ingolf Steinhardt * @author Kim Wormer - * @copyright 2012-2022 The MetaModels team. + * @copyright 2012-2023 The MetaModels team. * @license https://github.com/MetaModels/attribute_file/blob/master/LICENSE LGPL-3.0-or-later * @filesource */ @@ -25,12 +25,13 @@ use Contao\CoreBundle\Migration\AbstractMigration; use Contao\CoreBundle\Migration\MigrationResult; use Doctrine\DBAL\Connection; +use Doctrine\DBAL\Exception; use Doctrine\DBAL\Result; use MetaModels\Helper\TableManipulator; /** * This migration add column *__sort for every - * file attribute column. + * file attribute column if option multiple set. */ class AddSortFieldMigration extends AbstractMigration { @@ -67,7 +68,7 @@ public function __construct(Connection $connection, TableManipulator $tableManip */ public function getName(): string { - return 'Add column *__sort for every file attribute column.'; + return 'Add column *__sort for every file attribute column if option multiple set.'; } /** @@ -76,10 +77,12 @@ public function getName(): string * - there are some columns defined * * @return bool + * + * @throws Exception */ public function shouldRun(): bool { - $schemaManager = $this->connection->getSchemaManager(); + $schemaManager = $this->connection->createSchemaManager(); if (!$schemaManager->tablesExist(['tl_metamodel', 'tl_metamodel_attribute'])) { return false; @@ -100,6 +103,8 @@ public function shouldRun(): bool * Create the missing columns *__sort for attribute file. * * @return MigrationResult + * + * @throws Exception */ public function run(): MigrationResult { @@ -110,18 +115,24 @@ public function run(): MigrationResult return new MigrationResult(true, 'Nothing to do.'); } + $messages = []; while ($row = $attributes->fetchAssociative()) { if ($this->fieldExists($row['tableName'], $row['colname'] . '__sort')) { continue; } + $this->tableManipulator->createColumn( $row['tableName'], - $row['colname'], + $row['colname'] . '__sort', 'blob NULL' ); + + $messages[] = \sprintf('%s: %s__sort', $row['tableName'], $row['colname']); } - return new MigrationResult(true, 'Add columns *__sort at tl_metamodel_attribute for attribute file'); + return new MigrationResult( + true, + \sprintf('Add columns for attribute file: %s', \implode(', ', $messages))); } /** @@ -131,7 +142,7 @@ public function run(): MigrationResult * * @throws \Doctrine\DBAL\Exception The DBAL exception. */ - private function getFileAttributes() + private function getFileAttributes(): Result { return $this ->connection @@ -143,7 +154,7 @@ private function getFileAttributes() ->setParameter('type', 'file') ->andWhere('attribute.file_multiple=:multiple') ->setParameter('multiple', '1') - ->execute(); + ->executeQuery(); } /** @@ -152,8 +163,10 @@ private function getFileAttributes() * @param Result $attributes The attributes. * * @return int Returns columns count. + * + * @throws Exception */ - private function countMissingSortColumns($attributes): int + private function countMissingSortColumns(Result $attributes): int { $countColumns = 0; $rows = $attributes->fetchAllAssociative(); @@ -176,11 +189,13 @@ private function countMissingSortColumns($attributes): int * @param string $columnName Column name. * * @return bool + * + * @throws Exception */ private function fieldExists(string $tableName, string $columnName): bool { - $columns = $this->connection->getSchemaManager()->listTableColumns($tableName); + $columns = $this->connection->createSchemaManager()->listTableColumns($tableName); - return isset($columns[strtolower($columnName)]); + return isset($columns[\strtolower($columnName)]); } } diff --git a/src/Resources/config/event_listener.yml b/src/Resources/config/event_listener.yml index 5bdb62e..d7f7057 100644 --- a/src/Resources/config/event_listener.yml +++ b/src/Resources/config/event_listener.yml @@ -42,19 +42,6 @@ services: method: buildDataDefinition priority: 0 - metamodels.attribute_file.event_listener.post-persist: - class: MetaModels\AttributeFileBundle\EventListener\HandleUpdateAttributeListener - arguments: - - "@metamodels.factory" - - "@database_connection" - - "@metamodels.table_manipulator" - public: true - tags: - - name: kernel.event_listener - event: dc-general.model.post-persist - method: handleUpdateAttribute - priority: -1 - MetaModels\AttributeFileBundle\EventListener\DcGeneral\Table\DcaSetting\FileWidgetModeOptions: public: false arguments: From d32fd708495410133355694753454f200b5a0a38 Mon Sep 17 00:00:00 2001 From: e-spin Date: Wed, 15 Feb 2023 10:28:06 +0100 Subject: [PATCH 21/56] Fix migration --- src/Migration/AddSortFieldMigration.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Migration/AddSortFieldMigration.php b/src/Migration/AddSortFieldMigration.php index 41aee50..ed1a5f1 100644 --- a/src/Migration/AddSortFieldMigration.php +++ b/src/Migration/AddSortFieldMigration.php @@ -172,7 +172,10 @@ private function countMissingSortColumns(Result $attributes): int $rows = $attributes->fetchAllAssociative(); foreach ($rows as $row) { - if ($this->fieldExists($row['tableName'], $row['colname'] . '__sort')) { + if ( + !$this->fieldExists($row['tableName'], $row['colname']) + || $this->fieldExists($row['tableName'], $row['colname'] . '__sort') + ) { continue; } From e7497a8559cea070e985199df4bf9bdfb4b87ac5 Mon Sep 17 00:00:00 2001 From: e-spin Date: Mon, 3 Apr 2023 20:45:44 +0200 Subject: [PATCH 22/56] Fix BuildAttributeListener for showhandler --- src/EventListener/BuildAttributeListener.php | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/EventListener/BuildAttributeListener.php b/src/EventListener/BuildAttributeListener.php index 9a23fab..22f349a 100644 --- a/src/EventListener/BuildAttributeListener.php +++ b/src/EventListener/BuildAttributeListener.php @@ -3,7 +3,7 @@ /** * This file is part of MetaModels/attribute_file. * - * (c) 2012-2019 The MetaModels team. + * (c) 2012-2023 The MetaModels team. * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -13,7 +13,8 @@ * @package MetaModels/attribute_file * @author Stefan Heimes * @author Sven Baumann - * @copyright 2012-2019 The MetaModels team. + * @author Ingolf Steinhardt + * @copyright 2012-2023 The MetaModels team. * @license https://github.com/MetaModels/attribute_file/blob/master/LICENSE LGPL-3.0-or-later * @filesource */ @@ -50,16 +51,13 @@ public function buildAttribute(BuildAttributeEvent $event) $name = $attribute->getColName(); $nameSort = \sprintf('%s__sort', $name); - if ($properties->hasProperty($nameSort)) { - $this->addAttributeToDefinition($container, $name); - $properties->getProperty($name . '__sort')->setWidgetType('fileTreeOrder'); - - return; + if (!$properties->hasProperty($nameSort)) { + $properties->addProperty(new DefaultProperty($nameSort)); } - $properties->addProperty($property = new DefaultProperty($name . '__sort')); - $property->setWidgetType('fileTreeOrder'); - + $properties->getProperty($nameSort) + ->setWidgetType('fileTreeOrder') + ->setLabel($nameSort); $this->addAttributeToDefinition($container, $name); } From f6d1a2a8622e11e76e4ad326a357a4cb9db6eae7 Mon Sep 17 00:00:00 2001 From: e-spin Date: Tue, 16 May 2023 19:55:49 +0200 Subject: [PATCH 23/56] Change dissolve inserttags from filter rule "Own SQL" to Contao core --- .../BuildFrontendUploadListener.php | 165 ++++-------------- .../frontend_editing/event_listener.yml | 4 +- .../languages/en/tl_metamodel_dcasetting.php | 13 +- 3 files changed, 38 insertions(+), 144 deletions(-) diff --git a/src/EventListener/BuildFrontendUploadListener.php b/src/EventListener/BuildFrontendUploadListener.php index 39834a9..8878cb3 100644 --- a/src/EventListener/BuildFrontendUploadListener.php +++ b/src/EventListener/BuildFrontendUploadListener.php @@ -3,7 +3,7 @@ /** * This file is part of MetaModels/attribute_file. * - * (c) 2012-2022 The MetaModels team. + * (c) 2012-2023 The MetaModels team. * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -13,7 +13,7 @@ * @package MetaModels/attribute_file * @author Sven Baumann * @author Ingolf Steinhardt - * @copyright 2012-2022 The MetaModels team. + * @copyright 2012-2023 The MetaModels team. * @license https://github.com/MetaModels/attribute_file/blob/master/LICENSE LGPL-3.0-or-later * @filesource */ @@ -22,17 +22,11 @@ namespace MetaModels\AttributeFileBundle\EventListener; -use Contao\FrontendUser; -use Contao\InsertTags; -use Contao\StringUtil; -use ContaoCommunityAlliance\DcGeneral\Contao\InputProvider; use ContaoCommunityAlliance\DcGeneral\Contao\RequestScopeDeterminatorAwareTrait; use ContaoCommunityAlliance\DcGeneral\InputProviderInterface; -use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Schema\Column; +use Contao\CoreBundle\InsertTag\InsertTagParser; +use Contao\FrontendUser; use MetaModels\AttributeFileBundle\Attribute\File; -use MetaModels\CoreBundle\Contao\InsertTag\ReplaceParam; -use MetaModels\CoreBundle\Contao\InsertTag\ReplaceTableName; use MetaModels\DcGeneral\Events\MetaModel\BuildAttributeEvent; use MetaModels\ViewCombination\ViewCombination; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; @@ -49,85 +43,51 @@ final class BuildFrontendUploadListener * * @var ViewCombination */ - private $viewCombination; + private ViewCombination $viewCombination; /** * The token storage. * * @var TokenStorageInterface */ - private $tokenStorage; + private TokenStorageInterface $tokenStorage; /** * The property information from the input screen. * * @var array */ - private $information; - - /** - * The insert tag replacer, for replace the table name. - * - * @var ReplaceTableName - */ - private $replaceTableName; - - /** - * The insert tag replacer, for replace parameters. - * - * @var ReplaceParam - */ - private $replaceParam; - - /** - * The database connection. - * - * @var Connection - */ - private $connection; + private array $information; /** * The input provider. * * @var InputProviderInterface */ - private $inputProvider; + private InputProviderInterface $inputProvider; /** - * The autoincrement. + * The insert tag parser. * - * @var int + * @var InsertTagParser */ - private $autoincrement; - - /** - * The id column. - * - * @var Column - */ - private $columnId; + private InsertTagParser $insertTagParser; /** * The constructor. * * @param ViewCombination $viewCombination The view combination. * @param TokenStorageInterface $tokenStorage The token storage. - * @param ReplaceTableName $replaceTableName The insert tag replacer, for replace the table name. - * @param ReplaceParam $replaceParam The insert tag replacer, for replace parameters. - * @param Connection $connection The database connection. + * @param InsertTagParser $insertTagParser The insert tag parser. */ public function __construct( ViewCombination $viewCombination, TokenStorageInterface $tokenStorage, - ReplaceTableName $replaceTableName, - ReplaceParam $replaceParam, - Connection $connection + InsertTagParser $insertTagParser ) { $this->viewCombination = $viewCombination; $this->tokenStorage = $tokenStorage; - $this->replaceTableName = $replaceTableName; - $this->replaceParam = $replaceParam; - $this->connection = $connection; + $this->insertTagParser = $insertTagParser; } /** @@ -165,11 +125,11 @@ private function addWidgetModeInformationToProperty(BuildAttributeEvent $event): 'deselect' => (bool) $this->information['fe_widget_file_deselect'], 'delete' => (bool) $this->information['fe_widget_file_delete'], 'uploadFolder' => $this->getUserHomeDir() ?: $this->getTargetFolder(), - 'extendFolder' => $this->getExtendFolder($event), + 'extendFolder' => $this->getExtendFolder(), 'normalizeExtendFolder' => (bool) $this->information['fe_widget_file_normalize_extend_folder'], 'normalizeFilename' => (bool) $this->information['fe_widget_file_normalize_filename'], - 'prefixFilename' => $this->getPrefixFilename($event), - 'postfixFilename' => $this->getPostfixFilename($event), + 'prefixFilename' => $this->getPrefixFilename(), + 'postfixFilename' => $this->getPostfixFilename(), 'storeFile' => true, 'imageSize' => $this->information['fe_widget_file_imageSize'], 'sortBy' => $this->information['fe_widget_file_sortBy'], @@ -238,109 +198,61 @@ private function getTargetFolder(): ?string /** * Get the extend folder. * - * @param BuildAttributeEvent $event The event. - * * @return string|null */ - private function getExtendFolder(BuildAttributeEvent $event): ?string + private function getExtendFolder(): ?string { if (!($extendFolder = $this->information['fe_widget_file_extend_folder']) - || (false === \strpos($extendFolder, '{{')) + || (!str_contains($extendFolder, '{{')) ) { return $extendFolder ?: null; } - return $this->replaceInsertTag($event, $extendFolder); + return $this->replaceInsertTag($extendFolder); } /** * Get the prefix for the filename. * - * @param BuildAttributeEvent $event The event. - * * @return string|null */ - private function getPrefixFilename(BuildAttributeEvent $event): ?string + private function getPrefixFilename(): ?string { if (!($extendFolder = $this->information['fe_widget_file_prefix_filename']) - || (false === \strpos($extendFolder, '{{')) + || (!str_contains($extendFolder, '{{')) ) { return $extendFolder ?: null; } - return $this->replaceInsertTag($event, $extendFolder); + return $this->replaceInsertTag($extendFolder); } /** * Get the postfix for the filename. * - * @param BuildAttributeEvent $event The event. - * * @return string|null */ - private function getPostfixFilename(BuildAttributeEvent $event): ?string + private function getPostfixFilename(): ?string { if (!($extendFolder = $this->information['fe_widget_file_postfix_filename']) - || (false === \strpos($extendFolder, '{{')) + || (!str_contains($extendFolder, '{{')) ) { return $extendFolder ?: null; } - return $this->replaceInsertTag($event, $extendFolder); + return $this->replaceInsertTag($extendFolder); } /** * Replace the insert tag. * - * @param BuildAttributeEvent $event The event. - * @param string $replace The replacement. + * @param string $replace The replacement. * * @return string - * - * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ - private function replaceInsertTag(BuildAttributeEvent $event, string $replace): string + private function replaceInsertTag(string $replace): string { - if ((!$this->autoincrement || !$this->columnId) - || !$this->getInputProvider()->hasParameter('act') - || ('create' === $this->getInputProvider()->getParameter('act')) - ) { - $tableDetails = $this->connection->getSchemaManager()->listTableDetails($event->getContainer()->getName()); - foreach ($tableDetails->getColumns() as $column) { - if (!$column->getAutoincrement()) { - continue; - } - - $this->columnId = $column; - break; - } - - if ($this->columnId) { - $this->autoincrement = (int) $tableDetails->getOption('autoincrement'); - } - } - - if ($this->autoincrement && $this->columnId) { - $this->getInputProvider()->setValue($this->columnId->getName(), $this->autoincrement); - } - - $replaced = (string) $this->replaceParam->replace( - $this->replaceTableName->replace( - $event->getContainer()->getName(), - StringUtil::decodeEntities($replace) - ) - ); - - if ($this->autoincrement && $this->columnId) { - $this->getInputProvider()->unsetValue($this->columnId->getName()); - } - - if ((false === \strpos($replaced, '{{'))) { - return $replaced; - } - - $replacer = new InsertTags(); - return $replacer->replace($replaced); + return $this->insertTagParser->replace($replace); } /** @@ -353,22 +265,8 @@ private function replaceInsertTag(BuildAttributeEvent $event, string $replace): private function storeFileToTempFolder(array $extra): bool { return (isset($extra['extendFolder']) && $extra['extendFolder']) - // Test if in the extend folder path find insert tag. - && (false !== \strpos($extra['extendFolder'], '{{')); - } - - /** - * Get the input provider. - * - * @return InputProviderInterface - */ - private function getInputProvider(): InputProviderInterface - { - if (null === $this->inputProvider) { - $this->inputProvider = new InputProvider(); - } - - return $this->inputProvider; + // Test if in the extent folder path find insert tag. + && (str_contains($extra['extendFolder'], '{{')); } /** @@ -399,6 +297,7 @@ private function isSingleUploadField(BuildAttributeEvent $event): bool || !($inputScreen = $this->viewCombination->getScreen($event->getContainer()->getName())) || !(isset($inputScreen['properties']) && ($properties = $inputScreen['properties'])) ) { + return false; } diff --git a/src/Resources/config/frontend_editing/event_listener.yml b/src/Resources/config/frontend_editing/event_listener.yml index 5feae68..5bdf9b5 100644 --- a/src/Resources/config/frontend_editing/event_listener.yml +++ b/src/Resources/config/frontend_editing/event_listener.yml @@ -8,9 +8,7 @@ services: arguments: - '@metamodels.view_combination' - '@security.token_storage' - - '@MetaModels\CoreBundle\Contao\InsertTag\ReplaceTableName' - - '@MetaModels\CoreBundle\Contao\InsertTag\ReplaceParam' - - '@database_connection' + - '@contao.insert_tag.parser' tags: - name: kernel.event_listener event: metamodels.dc-general.events.metamodel.build.attribute diff --git a/src/Resources/contao/languages/en/tl_metamodel_dcasetting.php b/src/Resources/contao/languages/en/tl_metamodel_dcasetting.php index 03ef83a..ca08da6 100644 --- a/src/Resources/contao/languages/en/tl_metamodel_dcasetting.php +++ b/src/Resources/contao/languages/en/tl_metamodel_dcasetting.php @@ -3,7 +3,7 @@ /** * This file is part of MetaModels/attribute_file. * - * (c) 2012-2022 The MetaModels team. + * (c) 2012-2023 The MetaModels team. * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -15,7 +15,7 @@ * @author Christian Schiffler * @author Sven Baumann * @author Ingolf Steinhardt - * @copyright 2012-2022 The MetaModels team. + * @copyright 2012-2023 The MetaModels team. * @license https://github.com/MetaModels/attribute_file/blob/master/LICENSE LGPL-3.0 * @filesource */ @@ -53,8 +53,7 @@ 'If the home dir configured too and is not authenticated a user, so this folder is the base folder.'; $GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['fe_widget_file_extend_folder'][0] = 'Extend folder'; $GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['fe_widget_file_extend_folder'][1] = - 'Here you can extend the base upload folder path. The Contao insert tags are supported to extend the path. ' . - 'The insert tags from the custom sql filter work here too.'; + 'Here you can extend the base upload folder path. The Contao insert tags are supported to extend the path.'; $GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['fe_widget_file_deselect'][0] = 'Deselect file'; $GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['fe_widget_file_deselect'][1] = 'If this option deselect file is active, then that file entry is remove from this model.'; @@ -69,12 +68,10 @@ 'Normalize the filename with an alias generator from the string util.'; $GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['fe_widget_file_prefix_filename'][0] = 'Prefix filename'; $GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['fe_widget_file_prefix_filename'][1] = - 'Here you can prefix the filename. The Contao insert tags are supported to prefix the filename. ' . - 'The insert tags from the custom sql filter work here too.'; + 'Here you can prefix the filename. The Contao insert tags are supported to prefix the filename.'; $GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['fe_widget_file_postfix_filename'][0] = 'Postfix filename'; $GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['fe_widget_file_postfix_filename'][1] = - 'Here you can postfix the filename. The Contao insert tags are supported to postfix the filename. ' . - 'The insert tags from the custom sql filter work here too.'; + 'Here you can postfix the filename. The Contao insert tags are supported to postfix the filename.'; $GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['fe_widget_file_imageSize'][0] = 'Thumbnail width and height'; $GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['fe_widget_file_imageSize'][1] = From 457b0e3a9b250fd86d8671d2dce15697654c13fc Mon Sep 17 00:00:00 2001 From: e-spin Date: Mon, 22 May 2023 11:50:14 +0200 Subject: [PATCH 24/56] Fix info at NC --- src/Attribute/File.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Attribute/File.php b/src/Attribute/File.php index e76433d..d4539b9 100644 --- a/src/Attribute/File.php +++ b/src/Attribute/File.php @@ -552,7 +552,7 @@ protected function prepareTemplate(Template $template, $rowData, $settings) '%s.%s.%s', $this->getMetaModel()->getTableName(), $settings->get('id'), - $rowData['id'] + ($rowData['id'] ?? 0) ) ) ->setShowImages($settings->get('file_showImage')); From 140c6536096e363b2c97df851c4941546a07db54 Mon Sep 17 00:00:00 2001 From: e-spin Date: Mon, 22 May 2023 15:00:05 +0200 Subject: [PATCH 25/56] Fix converting insert tags to ESI tags --- src/EventListener/BuildFrontendUploadListener.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/EventListener/BuildFrontendUploadListener.php b/src/EventListener/BuildFrontendUploadListener.php index 8878cb3..8fb9801 100644 --- a/src/EventListener/BuildFrontendUploadListener.php +++ b/src/EventListener/BuildFrontendUploadListener.php @@ -244,7 +244,7 @@ private function getPostfixFilename(): ?string } /** - * Replace the insert tag. + * Replace the insert tag - without converting to esi tags. * * @param string $replace The replacement. * @@ -252,7 +252,7 @@ private function getPostfixFilename(): ?string */ private function replaceInsertTag(string $replace): string { - return $this->insertTagParser->replace($replace); + return $this->insertTagParser->replaceInline($replace); } /** From 27c3959b485b9c8bd6eaaa4eaa3ca36c7b3be218 Mon Sep 17 00:00:00 2001 From: e-spin Date: Wed, 24 May 2023 07:58:49 +0200 Subject: [PATCH 26/56] Add "Deprecated!" at single upload for FEE --- src/Resources/contao/languages/de/tl_metamodel_dcasetting.php | 4 ++-- src/Resources/contao/languages/en/tl_metamodel_dcasetting.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Resources/contao/languages/de/tl_metamodel_dcasetting.php b/src/Resources/contao/languages/de/tl_metamodel_dcasetting.php index e6a524f..ccee1ef 100644 --- a/src/Resources/contao/languages/de/tl_metamodel_dcasetting.php +++ b/src/Resources/contao/languages/de/tl_metamodel_dcasetting.php @@ -52,8 +52,8 @@ $GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['file_widgetModes']['downloads'] = 'Dateien als sortierbare Dateiliste anzeigen z.B. für Downloads.'; $GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['file_widgetModes']['fe_multiple_upload'] = 'Mehrfacher Datei-Upload [nur für Frontend-Bearbeitung]'; $GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['file_widgetModes']['fe_multiple_upload_preview'] = 'Mehrfacher Datei-Upload mit Anzeige der Vorschaubilder [nur für Frontend-Bearbeitung]'; -$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['file_widgetModes']['fe_single_upload'] = 'Einzelner Datei-Upload [nur für Frontend-Bearbeitung]'; -$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['file_widgetModes']['fe_single_upload_preview'] = 'Einzelner Datei-Upload mit Anzeige der Vorschaubilder [nur für Frontend-Bearbeitung]'; +$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['file_widgetModes']['fe_single_upload'] = 'Einzelner Datei-Upload [nur für Frontend-Bearbeitung] - Deprecated!'; +$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['file_widgetModes']['fe_single_upload_preview'] = 'Einzelner Datei-Upload mit Anzeige der Vorschaubilder [nur für Frontend-Bearbeitung] - Deprecated!'; $GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['file_widgetModes']['gallery'] = 'Dateien als sortierbare Bilder anzeigen z.B. für eine Galerie.'; $GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['file_widgetModes']['normal'] = 'Dateien als Liste anzeigen.'; $GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['name_asc'] = 'Dateiname (aufsteigend)'; diff --git a/src/Resources/contao/languages/en/tl_metamodel_dcasetting.php b/src/Resources/contao/languages/en/tl_metamodel_dcasetting.php index ca08da6..e947598 100644 --- a/src/Resources/contao/languages/en/tl_metamodel_dcasetting.php +++ b/src/Resources/contao/languages/en/tl_metamodel_dcasetting.php @@ -32,9 +32,9 @@ 'Show files as sortable images e.g. for gallery.'; $GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['file_widgetModes']['fe_single_upload'] = - 'Single file upload [only for frontend editing]'; + 'Single file upload [only for frontend editing] - Deprecated!'; $GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['file_widgetModes']['fe_single_upload_preview'] = - 'Single file upload with show thumbnail [only for frontend editing]'; + 'Single file upload with show thumbnail [only for frontend editing] - Deprecated!'; $GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['file_widgetModes']['fe_multiple_upload'] = 'Multiple file upload [only for frontend editing]'; $GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['file_widgetModes']['fe_multiple_upload_preview'] = From aa3ee3537d1440b16f3f9ee7e5026d24225be388 Mon Sep 17 00:00:00 2001 From: zonky Date: Mon, 17 Jul 2023 09:37:41 +0200 Subject: [PATCH 27/56] Add feature to chose own widget template --- src/Resources/contao/dca/tl_metamodel_dcasetting.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Resources/contao/dca/tl_metamodel_dcasetting.php b/src/Resources/contao/dca/tl_metamodel_dcasetting.php index d17e4ef..7c8079a 100644 --- a/src/Resources/contao/dca/tl_metamodel_dcasetting.php +++ b/src/Resources/contao/dca/tl_metamodel_dcasetting.php @@ -3,7 +3,7 @@ /** * This file is part of MetaModels/attribute_file. * - * (c) 2012-2022 The MetaModels team. + * (c) 2012-2023 The MetaModels team. * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -16,7 +16,7 @@ * @author Andreas Isaak * @author Sven Baumann * @author Ingolf Steinhardt - * @copyright 2012-2022 The MetaModels team. + * @copyright 2012-2023 The MetaModels team. * @license https://github.com/MetaModels/attribute_file/blob/master/LICENSE LGPL-3.0-or-later * @filesource */ @@ -26,7 +26,8 @@ $GLOBALS['TL_DCA']['tl_metamodel_dcasetting']['metasubselectpalettes']['attr_id']['file'] = [ 'presentation' => [ - 'tl_class' + 'tl_class', + 'be_template', ], 'functions' => [ 'mandatory', @@ -53,6 +54,9 @@ System::getContainer()->getParameter('kernel.bundles'), true )) { + $GLOBALS['TL_DCA']['tl_metamodel_dcasetting']['metasubselectpalettes']['attr_id']['file']['presentation'][] = + 'fe_template'; + $GLOBALS['TL_DCA']['tl_metamodel_dcasetting']['fields']['file_widgetMode']['eval']['submitOnChange'] = true; $uploadSettings = [ From 2ba99aec23b8eecb705059978260d098ce8d8adc Mon Sep 17 00:00:00 2001 From: Ingolf Steinhardt Date: Sun, 31 Dec 2023 18:15:32 +0100 Subject: [PATCH 28/56] Fixes for PHPCQ2 --- .composer-require-checker.json | 11 + .phpcq.lock | 1 + .phpcq.yaml.dist | 112 +++++++++++ .phpmd.xml | 37 ++++ build.default.properties | 12 -- build.xml | 12 -- composer.json | 38 ++-- psalm.xml | 16 ++ src/Attribute/AttributeOrderTypeFactory.php | 6 +- src/Attribute/AttributeTypeFactory.php | 38 ++-- src/Attribute/File.php | 188 +++++++++++------- src/Attribute/FileOrder.php | 13 +- src/DependencyInjection/Configuration.php | 37 ++-- .../MetaModelsAttributeFileExtension.php | 40 ++-- src/EventListener/BuildAttributeListener.php | 16 +- .../BuildDataDefinitionListener.php | 8 +- .../BuildFrontendUploadListener.php | 80 ++++---- .../Table/Attribute/RemoveTypeOptions.php | 16 +- .../DcaSetting/FileWidgetModeOptions.php | 14 +- .../FilterSetting/RemoveAttIdOptions.php | 17 +- .../ImageSizeOptionsListener.php | 28 ++- .../AddProtectedDownloadMigration.php | 16 +- src/Migration/AddSortFieldMigration.php | 11 +- src/Schema/DoctrineSchemaGenerator.php | 2 +- .../FileAttributeTypeFactoryTest.php | 6 +- tests/Attribute/FileTest.php | 51 +++-- .../MetaModelsAttributeFileExtensionTest.php | 133 ++++--------- .../FilterSetting/RemoveAttIdOptionsTest.php | 19 +- .../Factory/AddAttributeInformationTest.php | 6 +- tests/Schema/DoctrineSchemaGeneratorTest.php | 9 +- 30 files changed, 591 insertions(+), 402 deletions(-) create mode 100644 .composer-require-checker.json create mode 100644 .phpcq.lock create mode 100644 .phpcq.yaml.dist create mode 100644 .phpmd.xml delete mode 100644 build.default.properties delete mode 100644 build.xml create mode 100644 psalm.xml diff --git a/.composer-require-checker.json b/.composer-require-checker.json new file mode 100644 index 0000000..22e99e2 --- /dev/null +++ b/.composer-require-checker.json @@ -0,0 +1,11 @@ +{ + "symbol-whitelist": [ + "array", "bool", "false", "int", "null", "self", "static", "parent", "string", "true", "void", "mixed", + "Contao\\ManagerBundle\\ContaoManagerBundle", + "Contao\\ManagerPlugin\\Bundle\\BundlePluginInterface", + "Contao\\ManagerPlugin\\Bundle\\Config\\BundleConfig", + "Contao\\ManagerPlugin\\Bundle\\Parser\\ParserInterface", + "Contao\\ManagerPlugin\\Routing\\RoutingPluginInterface", + "MetaModels\\ContaoFrontendEditingBundle\\MetaModelsContaoFrontendEditingBundle" + ] +} diff --git a/.phpcq.lock b/.phpcq.lock new file mode 100644 index 0000000..7229a0a --- /dev/null +++ b/.phpcq.lock @@ -0,0 +1 @@ +{"plugins":{"phpunit":{"api-version":"1.0.0","version":"1.0.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpunit/phpunit-1.0.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0"},"tool":{"phpunit":"^6.0 || ^7.0 || ^8.0 || ^9.0"}},"checksum":{"type":"sha-512","value":"c73f15658e3ba62665f09492ec91c3a6a715760bfaa88473a987538439fff442540148e086e46a6aa18ce55a3ea2fbf76caaa581384cb84a38859fcc609ae7e4"},"tools":{"phpunit":{"version":"9.6.16","url":"https://phar.phpunit.de/phpunit-9.6.16.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*","ext-json":"*","ext-libxml":"*","ext-mbstring":"*","ext-xml":"*","ext-xmlwriter":"*"}},"checksum":{"type":"sha-256","value":"891d46f06284db3695498aff5dfd6a944f835e07db2981295db2c2bcf6cfd338"},"signature":"https://phar.phpunit.de/phpunit-9.6.16.phar.asc"}},"composerLock":null},"psalm":{"api-version":"1.0.0","version":"1.2.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/psalm/psalm-1.2.0.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0","ext-dom":"*"},"tool":{"psalm":"^3.0 || ^4.0 || ^5.0"}},"checksum":{"type":"sha-512","value":"4a550c9226d7bca582d7c10bd87cce01190c96398936b1613421640c83df62ed1c6e0d44c1b39635414ea8cf4a892a6458d27590793238add24e7cb5547e6ffd"},"tools":{"psalm":{"version":"5.21.1","url":"https://github.com/vimeo/psalm/releases/download/5.21.1/psalm.phar","requirements":{"php":{"php":"^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0","ext-SimpleXML":"*","ext-ctype":"*","ext-dom":"*","ext-json":"*","ext-libxml":"*","ext-mbstring":"*","ext-tokenizer":"*"}},"checksum":null,"signature":"https://github.com/vimeo/psalm/releases/download/5.21.1/psalm.phar.asc"}},"composerLock":null},"composer-require-checker":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/composer-require-checker/composer-require-checker-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0"},"tool":{"composer-require-checker":"^3.8 || ^4.0"}},"checksum":{"type":"sha-512","value":"d5415bddfe024c5749d894034583882aee4e5c3e1087815d9fdd81cb5e71630f631a0e35de0ff84b97fbbf738c16ece5f83bd8c00695913eb846aa6f04577dc2"},"tools":{"composer-require-checker":{"version":"4.7.1","url":"https://github.com/maglnet/ComposerRequireChecker/releases/download/4.7.1/composer-require-checker.phar","requirements":{"php":{"php":"~8.1.0 || ~8.2.0 || ~8.3.0","ext-phar":"*"}},"checksum":null,"signature":"https://github.com/maglnet/ComposerRequireChecker/releases/download/4.7.1/composer-require-checker.phar.asc"}},"composerLock":null},"phpmd":{"api-version":"1.0.0","version":"1.0.2.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpmd/phpmd-1.0.2.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpmd":"^2.6.1"}},"checksum":{"type":"sha-512","value":"f22280a6dec8dbdd2ec1d83b294f23237fe32c34f4a298e52038e0a7a0074d541635b2b488b1a6098a42d8418a6cd8eb804406ea82b91e362be2b5d11a0915b0"},"tools":{"phpmd":{"version":"2.15.0","url":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar","requirements":{"php":{"php":">=5.3.9","ext-xml":"*"}},"checksum":null,"signature":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar.asc"}},"composerLock":null},"phpcpd":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpcpd/phpcpd-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcpd":"^6.0"}},"checksum":{"type":"sha-512","value":"1189ce0bf3fade4cb4241f1d96f915ef8fc7651f4450dc79fdf464ee3d6be3009316f0d423ce2d4af9d76ad50807b7fdf4d77bfa6d9ee2c91d6eda32ea214433"},"tools":{"phpcpd":{"version":"6.0.3","url":"https://phar.phpunit.de/phpcpd-6.0.3.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*"}},"checksum":{"type":"sha-256","value":"2cbaea7cfda1bb4299d863eb075e977c3f49055dd16d88529fae5150d48a84cb"},"signature":"https://phar.phpunit.de/phpcpd-6.0.3.phar.asc"}},"composerLock":null},"phploc":{"api-version":"1.0.0","version":"1.0.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phploc/phploc-1.0.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*","ext-json":"*"},"tool":{"phploc":"^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0"}},"checksum":{"type":"sha-512","value":"f67b02d494796adf553cb3dd13ec06c1cb8e53c799954061749424251379541637538199afb3afa3c7a01cabd1cb6f1c53eb621f015dff9644c6c7cbf10c56d1"},"tools":{"phploc":{"version":"7.0.2","url":"https://phar.phpunit.de/phploc-7.0.2.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*","ext-json":"*"}},"checksum":{"type":"sha-256","value":"3d59778ec86faf25fd00e3a329b2f9ad4a3c751ca91601ea7dab70f887b0bf46"},"signature":"https://phar.phpunit.de/phploc-7.0.2.phar.asc"}},"composerLock":null},"phpcs":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpcs/phpcs-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcs":"^3.0 || ^2.0","phpcbf":"^3.0 || ^2.0"}},"checksum":{"type":"sha-512","value":"2737022369da1318cc4e0ea194e8a81019f7b079080d869aab878b7486052fdbe68fee3f28131f35573226def1aabd4bd005e038ee7b767c137b1107c1492a83"},"tools":{"phpcs":{"version":"3.8.1","url":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.8.1/phpcs.phar","requirements":{"php":{"php":">=5.4.0","ext-simplexml":"*","ext-tokenizer":"*","ext-xmlwriter":"*"}},"checksum":null,"signature":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.8.1/phpcs.phar.asc"},"phpcbf":{"version":"3.8.1","url":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.8.1/phpcbf.phar","requirements":{"php":{"php":">=5.4.0","ext-simplexml":"*","ext-tokenizer":"*","ext-xmlwriter":"*"}},"checksum":null,"signature":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.8.1/phpcbf.phar.asc"}},"composerLock":null},"composer-normalize":{"api-version":"1.0.0","version":"1.1.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/composer-normalize/composer-normalize-1.1.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-json":"*"},"tool":{"composer-normalize":"^2.1"}},"checksum":{"type":"sha-512","value":"d59d3557cb20630734878a9115df5dd32d5aff815e5b15be36f6fb5d6e9d83dd36efd84215ab6529edcc924f600946f739a0d9e67723deff95c88346ab502498"},"tools":{"composer-normalize":{"version":"2.42.0","url":"https://github.com/ergebnis/composer-normalize/releases/download/2.42.0/composer-normalize.phar","requirements":{"php":{"php":"~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0","ext-json":"*"}},"checksum":null,"signature":"https://github.com/ergebnis/composer-normalize/releases/download/2.42.0/composer-normalize.phar.asc"}},"composerLock":null}},"tools":[]} \ No newline at end of file diff --git a/.phpcq.yaml.dist b/.phpcq.yaml.dist new file mode 100644 index 0000000..04eee1d --- /dev/null +++ b/.phpcq.yaml.dist @@ -0,0 +1,112 @@ +phpcq: + repositories: + - https://phpcq.github.io/repository/repository.json + directories: + - src + - tests + artifact: .phpcq/build + composer: + autodiscover: false + + plugins: + phpunit: + version: ^1.0 + signed: false + psalm: + version: ^1.0 + signed: false + composer-require-checker: + version: ^1.0 + signed: false + phpmd: + version: ^1.0 + signed: false + phpcpd: + version: ^1.1 + signed: false + phploc: + version: ^1.0 + signed: false + phpcs: + version: ^1.0 + signed: false + composer-normalize: + version: ^1.0 + signed: false + trusted-keys: + # composer-require-checker + - 033E5F8D801A2F8D + # sb@sebastian-bergmann.de + - 4AA394086372C20A + # psalm + - 8A03EA3B385DBAA1 + - 12CE0F1D262429A5 + # magl@magll.net + - D2CCAC42F6295E7D + # PHP_CodeSniffer + - 31C7E470E2138192 + # Composer normalize + - C00543248C87FB13 + # phpmd + - A4E55EA12C7C085C + - 9093F8B32E4815AA + +tasks: + fix: + - composer-normalize-fix + - phpcbf + + verify: + - composer-require-checker + - composer-normalize + + analyze: + - phploc + - phpcpd + - phpmd + - phpcs + - psalm + - phpunit + + default: + - verify + - analyze + + phpcpd: + plugin: phpcpd + config: + exclude: + - tests + - src/CoreBundle/EventListener/DcGeneral/DefinitionBuilder + - src/CoreBundle/Resources/contao/dca + + phpmd: + plugin: phpmd + config: + ruleset: + - ./.phpmd.xml + + composer-require-checker: + plugin: composer-require-checker + config: + config_file: '.composer-require-checker.json' + + phpcs: + plugin: phpcs + config: &phpcs-config + standard: PSR12 + excluded: + - '*/Resources/contao/dca/*' + - '*/Resources/contao/languages/*' + - '*/Resources/public/*' + + phpcbf: + plugin: phpcs + config: + <<: *phpcs-config + fix: true + + composer-normalize-fix: + plugin: composer-normalize + config: + dry_run: false diff --git a/.phpmd.xml b/.phpmd.xml new file mode 100644 index 0000000..78eb716 --- /dev/null +++ b/.phpmd.xml @@ -0,0 +1,37 @@ + + + + PHPMD rule set + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build.default.properties b/build.default.properties deleted file mode 100644 index 422e9db..0000000 --- a/build.default.properties +++ /dev/null @@ -1,12 +0,0 @@ -##################################################### -## This project is using the ## -## PHP code quality project (phpcq) ## -## ## -## https://github.com/phpcq/phpcq ## -##################################################### - -phpcs.standard=${basedir}/vendor/phpcq/coding-standard/phpcs/PhpCodeQuality/ruleset.xml -phpmd.ruleset=${basedir}/vendor/phpcq/coding-standard/phpmd/ruleset.xml - -phpcs.excluded=src/Resources/contao/languages*\ - ,src/Resources/contao/dca* diff --git a/build.xml b/build.xml deleted file mode 100644 index 2b34341..0000000 --- a/build.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - diff --git a/composer.json b/composer.json index 46e747b..f501308 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,8 @@ { "name": "metamodels/attribute_file", "description": "MetaModels attribute for files", + "license": "LGPL-3.0-or-later", + "type": "contao-bundle", "keywords": [ "contao", "metamodels", @@ -8,9 +10,6 @@ "file", "nontranslatable" ], - "type": "contao-bundle", - "homepage": "https://now.metamodel.me/", - "license": "LGPL-3.0-or-later", "authors": [ { "name": "Christian Schiffler", @@ -24,6 +23,7 @@ "role": "Developer" } ], + "homepage": "https://now.metamodel.me/", "support": { "email": "mail@metamodel.me", "issues": "https://github.com/MetaModels/attribute_file/issues", @@ -34,18 +34,27 @@ "require": { "php": "^8.1", "contao-community-alliance/dc-general": "^2.3@dev", - "contao/core-bundle": "^4.13.0, <5.0", + "contao/core-bundle": "^4.13.0 <5.0", + "doctrine/dbal": "^3.6.0", "metamodels/core": "^2.3@dev", "symfony/cache": "^5.4", + "symfony/config": "^5.4", "symfony/dependency-injection": "^5.4", - "symfony/http-kernel": "^5.4" + "symfony/http-kernel": "^5.4", + "symfony/security-core": "^5.4" }, "require-dev": { "contao/manager-plugin": "^2.1", - "metamodels/contao-frontend-editing": "^2.3@dev", "menatwork/contao-multicolumnwizard-bundle": "^3.4", - "phpcq/all-tasks": "^1.3" + "metamodels/contao-frontend-editing": "^2.3@dev", + "phpcq/runner-bootstrap": "^1.0@dev" }, + "repositories": [ + { + "type": "composer", + "url": "https://packages.cyberspectrum.de/r" + } + ], "autoload": { "psr-4": { "MetaModels\\AttributeFileBundle\\": "src" @@ -59,17 +68,18 @@ "MetaModels\\AttributeFileBundle\\Test\\": "tests" } }, - "extra": { - "contao-manager-plugin": "MetaModels\\AttributeFileBundle\\ContaoManager\\Plugin", - "branch-alias": { - "dev-feature/2.3.0": "2.3.x-dev" - } - }, "config": { "allow-plugins": { "contao-components/installer": false, - "contao/manager-plugin": false + "contao/manager-plugin": false, + "php-http/discovery": true }, "sort-packages": true + }, + "extra": { + "branch-alias": { + "dev-feature/2.3.0": "2.3.x-dev" + }, + "contao-manager-plugin": "MetaModels\\AttributeFileBundle\\ContaoManager\\Plugin" } } diff --git a/psalm.xml b/psalm.xml new file mode 100644 index 0000000..aa1a5c1 --- /dev/null +++ b/psalm.xml @@ -0,0 +1,16 @@ + + + + + + + + + + diff --git a/src/Attribute/AttributeOrderTypeFactory.php b/src/Attribute/AttributeOrderTypeFactory.php index 06ccb9d..3cb7599 100644 --- a/src/Attribute/AttributeOrderTypeFactory.php +++ b/src/Attribute/AttributeOrderTypeFactory.php @@ -86,14 +86,14 @@ public function getTypeIcon() */ public function createInstance($information, $metaModel) { - $columnName = ($information['colname'] ?? null); + $columnName = (string) ($information['colname'] ?? ''); $tableName = $metaModel->getTableName(); if (!isset($this->tableColumns[$tableName])) { - $this->tableColumns[$tableName] = $this->connection->getSchemaManager()->listTableColumns($tableName); + $this->tableColumns[$tableName] = $this->connection->createSchemaManager()->listTableColumns($tableName); } - if (!$columnName || !\array_key_exists($columnName, $this->tableColumns[$tableName])) { + if (('' === $columnName) || !\array_key_exists($columnName, $this->tableColumns[$tableName])) { return null; } diff --git a/src/Attribute/AttributeTypeFactory.php b/src/Attribute/AttributeTypeFactory.php index 795ec16..4f35ee0 100644 --- a/src/Attribute/AttributeTypeFactory.php +++ b/src/Attribute/AttributeTypeFactory.php @@ -3,7 +3,7 @@ /** * This file is part of MetaModels/attribute_file. * - * (c) 2012-2019 The MetaModels team. + * (c) 2012-2024 The MetaModels team. * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -14,7 +14,8 @@ * @author Christian Schiffler * @author Sven Baumann * @author Stefan Heimes - * @copyright 2012-2019 The MetaModels team. + * @author Ingolf Steinhardt + * @copyright 2012-2024 The MetaModels team. * @license https://github.com/MetaModels/attribute_file/blob/master/LICENSE LGPL-3.0-or-later * @filesource */ @@ -23,7 +24,6 @@ use Contao\Config; use Contao\CoreBundle\Framework\Adapter; -use Contao\CoreBundle\Image\ImageFactoryInterface; use Contao\FilesModel; use Contao\StringUtil; use Doctrine\DBAL\Connection; @@ -56,46 +56,46 @@ class AttributeTypeFactory implements IAttributeTypeFactory * * @var ToolboxFile */ - private $toolboxFile; + private ToolboxFile $toolboxFile; /** * The string util. * - * @var Adapter|StringUtil + * @var Adapter */ - private $stringUtil; + private Adapter $stringUtil; /** * The validator. * - * @var Adapter|Validator + * @var Adapter */ - private $validator; + private Adapter $validator; /** * The repository for files. * - * @var Adapter|FilesModel + * @var Adapter */ - private $fileRepository; + private Adapter $fileRepository; /** * The contao configurations. * - * @var Adapter|Config + * @var Adapter */ - private $config; + private Adapter $config; /** * {@inheritDoc} * - * @param Connection $connection The database connection. - * @param TableManipulator $tableManipulator The table manipulator. - * @param ToolboxFile $toolboxFile The toolbox for file. - * @param Adapter|StringUtil $stringUtil The string util. - * @param Adapter|Validator $validator The validator. - * @param Adapter|FilesModel $fileRepository The repository for files. - * @param Adapter|Config $config The contao configurations. + * @param Connection $connection The database connection. + * @param TableManipulator $tableManipulator The table manipulator. + * @param ToolboxFile $toolboxFile The toolbox for file. + * @param Adapter $stringUtil The string util. + * @param Adapter $validator The validator. + * @param Adapter $fileRepository The repository for files. + * @param Adapter $config The contao configurations. */ public function __construct( Connection $connection, diff --git a/src/Attribute/File.php b/src/Attribute/File.php index d4539b9..c2d8ab5 100644 --- a/src/Attribute/File.php +++ b/src/Attribute/File.php @@ -36,9 +36,10 @@ use Contao\StringUtil; use Contao\System; use Contao\Validator; +use Doctrine\DBAL\ArrayParameterType; use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Platforms\Keywords\KeywordList; use MetaModels\Attribute\BaseComplex; +use MetaModels\Attribute\ManagedAttributeTrait; use MetaModels\Helper\TableManipulator; use MetaModels\Helper\ToolboxFile; use MetaModels\IMetaModel; @@ -46,70 +47,75 @@ /** * This is the MetaModel attribute class for handling file fields. + * + * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class File extends BaseComplex { + use ManagedAttributeTrait; + /** * The database connection. * - * @var Connection|null + * @var Connection */ - private $connection; + private Connection $connection; /** * Table manipulator instance. * - * @var TableManipulator|null + * @var TableManipulator */ - private $tableManipulator; + private TableManipulator $tableManipulator; /** * The toolbox for file. * - * @var ToolboxFile|null + * @var ToolboxFile */ - private $toolboxFile; + private ToolboxFile $toolboxFile; /** * The string util. * - * @var Adapter|StringUtil|null + * @var Adapter */ - private $stringUtil; + private Adapter $stringUtil; /** * The validator. * - * @var Adapter|Validator|null + * @var Adapter */ - private $validator; + private Adapter $validator; /** * The repository for files. * - * @var Adapter|FilesModel|null + * @var Adapter */ - private $fileRepository; + private Adapter $fileRepository; /** * The contao configurations. * - * @var Adapter|Config|null + * @var Adapter */ - private $config; + private Adapter $config; /** * Create a new instance. * - * @param IMetaModel $metaModel The MetaModel instance this attribute belongs to. - * @param array $information The attribute information. - * @param Connection|null $connection The database connection. - * @param TableManipulator|null $tableManipulator Table manipulator instance. - * @param ToolboxFile|null $toolboxFile The toolbox for file. - * @param Adapter|StringUtil|null $stringUtil The string util. - * @param Adapter|Validator|null $validator The validator. - * @param Adapter|FilesModel|null $fileRepository The repository for files. - * @param Adapter|Config|null $config The contao configurations. + * @param IMetaModel $metaModel The MetaModel instance this attribute belongs to. + * @param array $information The attribute information. + * @param Connection|null $connection The database connection. + * @param TableManipulator|null $tableManipulator Table manipulator instance. + * @param ToolboxFile|null $toolboxFile The toolbox for file. + * @param Adapter|null $stringUtil The string util. + * @param Adapter|null $validator The validator. + * @param Adapter|null $fileRepository The repository for files. + * @param Adapter|null $config The contao configurations. */ public function __construct( IMetaModel $metaModel, @@ -124,16 +130,19 @@ public function __construct( ) { parent::__construct($metaModel, $information); - if (null === $toolboxFile) { - // @codingStandardsIgnoreStart - @\trigger_error( - '"toolboxFile"" is missing. It has to be passed in the constructor.' . - 'Fallback will get removed in MetaModels 3.0', - E_USER_DEPRECATED - ); - // @codingStandardsIgnoreEnd + if (null === $connection) { + $connection = $this->fetchServiceForFallback('connection', 'database_connection'); + assert($connection instanceof Connection); + } - $toolboxFile = System::getContainer()->get('metamodels.attribute_file.toolbox.file'); + if (null === $tableManipulator) { + $tableManipulator = $this->fetchServiceForFallback('tableManipulator', 'metamodels.table_manipulator'); + assert($tableManipulator instanceof TableManipulator); + } + + if (null === $toolboxFile) { + $toolboxFile = $this->fetchServiceForFallback('toolboxFile', 'metamodels.attribute_file.toolbox.file'); + assert($toolboxFile instanceof ToolboxFile); } if (null === $stringUtil) { @@ -145,7 +154,8 @@ public function __construct( ); // @codingStandardsIgnoreEnd - $stringUtil = System::getContainer()->get('contao.framework')->getAdapter(StringUtil::class); + $stringUtil = System::getContainer()->get('contao.framework')?->getAdapter(StringUtil::class); + assert($stringUtil instanceof Adapter); } if (null === $validator) { @@ -157,7 +167,8 @@ public function __construct( ); // @codingStandardsIgnoreEnd - $validator = System::getContainer()->get('contao.framework')->getAdapter(Validator::class); + $validator = System::getContainer()->get('contao.framework')?->getAdapter(Validator::class); + assert($validator instanceof Adapter); } if (null === $fileRepository) { @@ -169,7 +180,8 @@ public function __construct( ); // @codingStandardsIgnoreEnd - $fileRepository = System::getContainer()->get('contao.framework')->getAdapter(FilesModel::class); + $fileRepository = System::getContainer()->get('contao.framework')?->getAdapter(FilesModel::class); + assert($fileRepository instanceof Adapter); } if (null === $config) { @@ -181,7 +193,8 @@ public function __construct( ); // @codingStandardsIgnoreEnd - $config = System::getContainer()->get('contao.framework')->getAdapter(Config::class); + $config = System::getContainer()->get('contao.framework')?->getAdapter(Config::class); + assert($config instanceof Adapter); } $this->connection = $connection; @@ -205,11 +218,12 @@ public function destroyAUX() $this->triggerDeprecationIsUnmanagedAttribute(static::class, __METHOD__); + /** @psalm-suppress DeprecatedMethod */ parent::destroyAUX(); $metaModel = $this->getMetaModel()->getTableName(); // Try to delete the column. If it does not exist as we can assume it has been deleted already then. - $tableColumns = $this->connection->getSchemaManager()->listTableColumns($metaModel); + $tableColumns = $this->connection->createSchemaManager()->listTableColumns($metaModel); if (($colName = $this->getColName()) && \array_key_exists($colName, $tableColumns)) { $this->tableManipulator->dropColumn($metaModel, $colName); } @@ -231,6 +245,7 @@ public function initializeAUX() $this->triggerDeprecationIsUnmanagedAttribute(static::class, __METHOD__); + /** @psalm-suppress DeprecatedMethod */ parent::initializeAUX(); if ($colName = $this->getColName()) { $tableName = $this->getMetaModel()->getTableName(); @@ -269,7 +284,7 @@ public function unsetDataFor($arrIds) ->set('t.' . $this->getColName(), ':null') ->where($builder->expr()->in('t.id', ':values')) ->setParameter('null', null) - ->setParameter('values', $arrIds, Connection::PARAM_STR_ARRAY); + ->setParameter('values', $arrIds, ArrayParameterType::STRING); if ($this->getMetaModel()->hasAttribute($this->getColName() . '__sort')) { $builder->set('t.' . $this->getColName() . '__sort', ':null'); @@ -286,10 +301,10 @@ public function getDataFor($arrIds) $builder = $this->connection->createQueryBuilder(); $builder - ->select('t.id', 't.' . $this->getColName() . ' AS file') + ->select('t.id, t.' . $this->getColName() . ' AS file') ->from($this->getMetaModel()->getTableName(), 't') ->where($builder->expr()->in('t.id', ':values')) - ->setParameter('values', $arrIds, Connection::PARAM_STR_ARRAY); + ->setParameter('values', $arrIds, ArrayParameterType::STRING); if ($hasSort = $this->getMetaModel()->hasAttribute($this->getColName() . '__sort')) { $builder->addSelect($this->getColName() . '__sort AS file_sort'); @@ -299,7 +314,8 @@ public function getDataFor($arrIds) $data = []; while ($result = $query->fetchAssociative()) { - $row = $this->toolboxFile->convertValuesToMetaModels($this->stringUtil->deserialize($result['file'], true)); + $row = + $this->toolboxFile->convertValuesToMetaModels($this->stringUtil->deserialize($result['file'], true)); if ($hasSort) { // The sort key be can remove in later version. The new sort key is bin_sorted. @@ -434,8 +450,8 @@ private function handleCustomFileTree(&$arrFieldDef) // Set root path of file chooser depending on contao version. $file = null; - if ($this->validator->isUuid($this->get('file_uploadFolder'))) { - $file = $this->fileRepository->findByUuid($this->get('file_uploadFolder')); + if ($this->validator->isUuid($this->get('file_uploadFolder') ?? '')) { + $file = $this->fileRepository->findByUuid($this->get('file_uploadFolder') ?? ''); } // Check if we have a file. @@ -454,11 +470,11 @@ private function handleCustomFileTree(&$arrFieldDef) switch ($this->get('file_filesOnly')) { case '1': // Files only. - $fieldDefinition['eval']['filesOnly'] = true; + $arrFieldDef['eval']['filesOnly'] = true; break; case '2': // Folders only. - $fieldDefinition['eval']['files'] = false; + $arrFieldDef['eval']['files'] = false; break; default: // Files and files possible. @@ -479,9 +495,7 @@ public function getFieldDefinition($arrOverrides = []) $widgetMode = $this->getOverrideValue('file_widgetMode', $arrOverrides); - if (('normal' !== $widgetMode) - && ((bool) $this->get('file_multiple')) - ) { + if (('normal' !== $widgetMode) && ((bool) $this->get('file_multiple'))) { $fieldDefinition['eval']['orderField'] = $this->getColName() . '__sort'; } @@ -522,18 +536,32 @@ public function widgetToValue($varValue, $itemId) * * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ - protected function prepareTemplate(Template $template, $rowData, $settings) + protected function prepareTemplate(Template $objTemplate, $arrRowData, $objSettings) { - parent::prepareTemplate($template, $rowData, $settings); + parent::prepareTemplate($objTemplate, $arrRowData, $objSettings); + + /** @var array{ + * bin: list, + * value: list, + * path: list, + * meta: list, + * bin_sorted?: list, + * value_sorted?: list, + * path_sorted?: list, + * meta_sorted?: list + * }|null $value */ + $value = $arrRowData[$this->getColName()] ?? null; + if (null === $value) { + $value = ['bin' => [], 'value' => [], 'path' => [], 'meta' => []]; + } - $value = $rowData[$this->getColName()] ?? null; + $showImage = (bool) $objSettings->get('file_showImage'); // No data and show image, check placeholder. - if (!($value['bin'] ?? null)) { - if (null === $settings->get('file_showImage') - || null === ($placeholder = $settings->get('file_placeholder'))) { - $template->files = []; - $template->src = []; + if ([] === $value['bin']) { + if (null === ($placeholder = $objSettings->get('file_placeholder'))) { + $objTemplate->files = []; + $objTemplate->src = []; return; } @@ -544,6 +572,7 @@ protected function prepareTemplate(Template $template, $rowData, $settings) $toolbox = clone $this->toolboxFile; + /** @psalm-suppress DeprecatedMethod */ $toolbox ->setBaseLanguage($this->getMetaModel()->getActiveLanguage()) ->setFallbackLanguage($this->getMetaModel()->getFallbackLanguage()) @@ -551,38 +580,45 @@ protected function prepareTemplate(Template $template, $rowData, $settings) \sprintf( '%s.%s.%s', $this->getMetaModel()->getTableName(), - $settings->get('id'), - ($rowData['id'] ?? 0) + (string) ($objSettings->get('id') ?? ''), + (string) ($arrRowData['id'] ?? '0') ) ) - ->setShowImages($settings->get('file_showImage')); + ->setShowImages($showImage); if ($this->get('file_validFileTypes')) { $toolbox->setAcceptedExtensions($this->get('file_validFileTypes')); } - if ($settings->get('file_imageSize')) { - $toolbox->setResizeImages($settings->get('file_imageSize')); + if (\is_array($imageSize = $objSettings->get('file_imageSize'))) { + $toolbox->setResizeImages($imageSize); } - if (isset($value['value'])) { - foreach ($value['value'] as $strFile) { - $toolbox->addPathById($strFile); - } - } elseif (\is_array($value)) { - foreach ($value as $strFile) { - $toolbox->addPathById($strFile); - } - } else { - $toolbox->addPathById($value); + foreach ($value['value'] ?? [] as $strFile) { + $toolbox->addPathById($strFile); } - $toolbox->withDownloadKeys($settings->get('file_showLink') && $settings->get('file_protectedDownload')); + $toolbox->withDownloadKeys( + ((bool) $objSettings->get('file_showLink')) && ((bool) $objSettings->get('file_protectedDownload')) + ); $toolbox->resolveFiles(); - $data = $toolbox->sortFiles($settings->get('file_sortBy'), ($value['bin_sorted'] ?? [])); + $data = $toolbox->sortFiles($objSettings->get('file_sortBy') ?? 'name_asc', ($value['bin_sorted'] ?? [])); + + $objTemplate->files = $data['files']; + $objTemplate->src = $data['source']; + } + + private function fetchServiceForFallback(string $parameter, string $serviceName): null|object + { + // @codingStandardsIgnoreStart + @\trigger_error( + '"'. $parameter . '" is missing. It has to be passed in the constructor.' . + 'Fallback will get removed in MetaModels 3.0', + E_USER_DEPRECATED + ); + // @codingStandardsIgnoreEnd - $template->files = $data['files']; - $template->src = $data['source']; + return System::getContainer()->get($serviceName); } } diff --git a/src/Attribute/FileOrder.php b/src/Attribute/FileOrder.php index 0babfbf..9f0faf7 100644 --- a/src/Attribute/FileOrder.php +++ b/src/Attribute/FileOrder.php @@ -24,7 +24,6 @@ use Contao\StringUtil; use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Platforms\Keywords\KeywordList; use MetaModels\Attribute\ISimple; use MetaModels\Attribute\IInternal; use MetaModels\IMetaModel; @@ -41,30 +40,30 @@ class FileOrder implements ISimple, IInternal * * @var IMetaModel */ - private $metaModel; + private IMetaModel $metaModel; /** * The column name. * * @var string */ - private $colName; + private string $colName; /** * The connection. * * @var Connection */ - private $connection; + private Connection $connection; /** * Create a new instance. * - * @param null $metaModel The MetaModel. + * @param IMetaModel $metaModel The MetaModel. * @param array $information The attribute information. * @param Connection $connection The connection. */ - public function __construct($metaModel, array $information, Connection $connection) + public function __construct(IMetaModel $metaModel, array $information, Connection $connection) { $this->metaModel = $metaModel; $this->colName = $information['colname']; @@ -76,7 +75,7 @@ public function __construct($metaModel, array $information, Connection $connecti */ public function getName() { - return null; + return ''; } /** diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 2e8b63c..2081b4e 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -3,7 +3,7 @@ /** * This file is part of MetaModels/attribute_file. * - * (c) 2012-2022 The MetaModels team. + * (c) 2012-2023 The MetaModels team. * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -13,7 +13,7 @@ * @package MetaModels/attribute_file * @author Sven Baumann * @author Ingolf Steinhardt - * @copyright 2012-2022 The MetaModels team. + * @copyright 2012-2023 The MetaModels team. * @license https://github.com/MetaModels/attribute_file/blob/master/LICENSE LGPL-3.0-or-later * @filesource */ @@ -22,6 +22,7 @@ namespace MetaModels\AttributeFileBundle\DependencyInjection; +use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\ConfigurationInterface; @@ -35,25 +36,16 @@ final class Configuration implements ConfigurationInterface * * @var bool */ - private $debug; - - /** - * The root directory. - * - * @var string - */ - private $rootDir; + private bool $debug; /** * Constructor. * - * @param bool $debug The debug flag. - * @param string|null $rootDir The root directory. + * @param bool $debug The debug flag. */ - public function __construct(bool $debug, ?string $rootDir) + public function __construct(bool $debug) { $this->debug = $debug; - $this->rootDir = $rootDir; } /** @@ -63,16 +55,13 @@ public function getConfigTreeBuilder(): TreeBuilder { $treeBuilder = new TreeBuilder('metamodels_attribute_file'); - $treeBuilder - ->getRootNode() - ->children() - ->booleanNode('enable_cache') - ->defaultValue(!$this->debug) - ->end() - ->scalarNode('cache_dir') - ->defaultValue('%metamodels.cache_dir%' . DIRECTORY_SEPARATOR . 'attribute_file') - ->end() - ->end(); + $rootNode = $treeBuilder->getRootNode(); + assert($rootNode instanceof ArrayNodeDefinition); + $children = $rootNode->children(); + $children->booleanNode('enable_cache')->defaultValue(!$this->debug)->end(); + $children + ->scalarNode('cache_dir') + ->defaultValue('%metamodels.cache_dir%' . DIRECTORY_SEPARATOR . 'attribute_file'); return $treeBuilder; } diff --git a/src/DependencyInjection/MetaModelsAttributeFileExtension.php b/src/DependencyInjection/MetaModelsAttributeFileExtension.php index c88b8ac..6adc0d6 100644 --- a/src/DependencyInjection/MetaModelsAttributeFileExtension.php +++ b/src/DependencyInjection/MetaModelsAttributeFileExtension.php @@ -3,7 +3,7 @@ /** * This file is part of MetaModels/attribute_file. * - * (c) 2012-2022 The MetaModels team. + * (c) 2012-2023 The MetaModels team. * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -14,21 +14,27 @@ * @author Christian Schiffler * @author Sven Baumann * @author Ingolf Steinhardt - * @copyright 2012-2022 The MetaModels team. + * @copyright 2012-2023 The MetaModels team. * @license https://github.com/MetaModels/attribute_file/blob/master/LICENSE LGPL-3.0-or-later * @filesource */ namespace MetaModels\AttributeFileBundle\DependencyInjection; -use Doctrine\Common\Cache\ArrayCache; use MetaModels\AttributeFileBundle\EventListener\DcGeneral\Table\DcaSetting\FileWidgetModeOptions; use MetaModels\ContaoFrontendEditingBundle\MetaModelsContaoFrontendEditingBundle; +use Symfony\Component\Cache\Adapter\ArrayAdapter; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Extension\Extension; use Symfony\Component\DependencyInjection\Loader; +use function assert; +use function in_array; +use function is_array; +use function is_bool; +use function is_string; + /** * This is the class that loads and manages the bundle configuration */ @@ -36,27 +42,37 @@ class MetaModelsAttributeFileExtension extends Extension { /** * {@inheritDoc} + * + * @SuppressWarnings(PHPMD.LongVariable) */ - public function load(array $configs, ContainerBuilder $container) + public function load(array $configs, ContainerBuilder $container): void { $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); $loader->load('factory.yml'); $loader->load('event_listener.yml'); $loader->load('services.yml'); - $config = $this->processConfiguration($this->getConfiguration($configs, $container), $configs); + $configuration = $this->getConfiguration($configs, $container); + assert($configuration instanceof Configuration); + $config = $this->processConfiguration($configuration, $configs); $this->buildCacheService($container, $config); $frontendEditing = false; + + $bundles = $container->getParameter('kernel.bundles'); + assert(is_array($bundles)); // Load configuration for the frontend editing. - if (\in_array(MetaModelsContaoFrontendEditingBundle::class, $container->getParameter('kernel.bundles'), true)) { + if (in_array(MetaModelsContaoFrontendEditingBundle::class, $bundles, true)) { $frontendEditing = true; $loader->load('frontend_editing/event_listener.yml'); } $this->addFrontendEditingArgument($container, $frontendEditing); - $managedSchemaTypeNames = $container->getParameter('metamodels.managed-schema-type-names') ?? []; + $typeNames = $container->hasParameter('metamodels.managed-schema-type-names') + ? $container->getParameter('metamodels.managed-schema-type-names') + : null; + $managedSchemaTypeNames = is_array($typeNames) ? $typeNames : []; $managedSchemaTypeNames[] = 'file'; $container->setParameter('metamodels.managed-schema-type-names', $managedSchemaTypeNames); } @@ -66,10 +82,10 @@ public function load(array $configs, ContainerBuilder $container) */ public function getConfiguration(array $config, ContainerBuilder $container) { - return new Configuration( - $container->getParameter('kernel.debug'), - $container->getParameter('metamodels.cache_dir') - ); + $debug = $container->getParameter('kernel.debug'); + assert(is_bool($debug)); + + return new Configuration($debug); } /** @@ -85,7 +101,7 @@ private function buildCacheService(ContainerBuilder $container, array $config) // if cache disabled, swap it out with the dummy cache. if (!$config['enable_cache']) { $cache = $container->getDefinition('metamodels.attribute_file.cache_system'); - $cache->setClass(ArrayCache::class); + $cache->setClass(ArrayAdapter::class); $cache->setArguments([]); $container->setParameter('metamodels.attribute_file.cache_dir', null); return; diff --git a/src/EventListener/BuildAttributeListener.php b/src/EventListener/BuildAttributeListener.php index 22f349a..bcbcf75 100644 --- a/src/EventListener/BuildAttributeListener.php +++ b/src/EventListener/BuildAttributeListener.php @@ -3,7 +3,7 @@ /** * This file is part of MetaModels/attribute_file. * - * (c) 2012-2023 The MetaModels team. + * (c) 2012-2024 The MetaModels team. * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -14,7 +14,7 @@ * @author Stefan Heimes * @author Sven Baumann * @author Ingolf Steinhardt - * @copyright 2012-2023 The MetaModels team. + * @copyright 2012-2024 The MetaModels team. * @license https://github.com/MetaModels/attribute_file/blob/master/LICENSE LGPL-3.0-or-later * @filesource */ @@ -25,7 +25,7 @@ use MetaModels\AttributeFileBundle\Attribute\File; use MetaModels\AttributeFileBundle\DcGeneral\AttributeFileDefinition; use MetaModels\DcGeneral\Events\MetaModel\BuildAttributeEvent; -use \ContaoCommunityAlliance\DcGeneral\DataDefinition\ContainerInterface; +use ContaoCommunityAlliance\DcGeneral\DataDefinition\ContainerInterface; /** * Class Attribute @@ -57,7 +57,8 @@ public function buildAttribute(BuildAttributeEvent $event) $properties->getProperty($nameSort) ->setWidgetType('fileTreeOrder') - ->setLabel($nameSort); + ->setLabel($nameSort) + ->setExtra(['tl_class' => 'hidden']); $this->addAttributeToDefinition($container, $name); } @@ -65,17 +66,18 @@ public function buildAttribute(BuildAttributeEvent $event) * Add attribute to MetaModels file attributes definition. * * @param ContainerInterface $container The metamodel data definition. - * * @param string $name The attribute name. * * @return void */ - private function addAttributeToDefinition(ContainerInterface $container, $name) + private function addAttributeToDefinition(ContainerInterface $container, string $name): void { if (!$container->hasDefinition('metamodels.file-attributes')) { $container->setDefinition('metamodels.file-attributes', new AttributeFileDefinition()); } + $definition = $container->getDefinition('metamodels.file-attributes'); + assert($definition instanceof AttributeFileDefinition); - $container->getDefinition('metamodels.file-attributes')->add($name); + $definition->add($name); } } diff --git a/src/EventListener/BuildDataDefinitionListener.php b/src/EventListener/BuildDataDefinitionListener.php index 77b438e..b828905 100644 --- a/src/EventListener/BuildDataDefinitionListener.php +++ b/src/EventListener/BuildDataDefinitionListener.php @@ -21,6 +21,7 @@ use ContaoCommunityAlliance\DcGeneral\Factory\Event\BuildDataDefinitionEvent; use ContaoCommunityAlliance\DcGeneral\DataDefinition\Palette\Property; +use MetaModels\AttributeFileBundle\DcGeneral\AttributeFileDefinition; /** * Class BuildDataDefinitionListener @@ -41,13 +42,16 @@ public function buildDataDefinition(BuildDataDefinitionEvent $event) return; } // All properties... - foreach ($container->getDefinition('metamodels.file-attributes')->get() as $propertyName) { + $definition = $container->getDefinition('metamodels.file-attributes'); + assert($definition instanceof AttributeFileDefinition); + foreach ($definition->get() as $propertyName) { // ... in all palettes ... foreach ($container->getPalettesDefinition()->getPalettes() as $palette) { // ... in any legend ... foreach ($palette->getLegends() as $legend) { // ... of the searched name ... - if (($legend->hasProperty($propertyName)) + if ( + ($legend->hasProperty($propertyName)) && ($container->getPropertiesDefinition()->hasProperty($propertyName . '__sort')) ) { // ... must have the order field as companion, visible only when the real property is. diff --git a/src/EventListener/BuildFrontendUploadListener.php b/src/EventListener/BuildFrontendUploadListener.php index 8fb9801..caeedfd 100644 --- a/src/EventListener/BuildFrontendUploadListener.php +++ b/src/EventListener/BuildFrontendUploadListener.php @@ -22,6 +22,7 @@ namespace MetaModels\AttributeFileBundle\EventListener; +use ContaoCommunityAlliance\DcGeneral\Contao\RequestScopeDeterminator; use ContaoCommunityAlliance\DcGeneral\Contao\RequestScopeDeterminatorAwareTrait; use ContaoCommunityAlliance\DcGeneral\InputProviderInterface; use Contao\CoreBundle\InsertTag\InsertTagParser; @@ -33,6 +34,8 @@ /** * This event build the attribute for upload field, in the frontend editing scope. + * + * @SuppressWarnings(PHPMD.UnusedPrivateField) */ final class BuildFrontendUploadListener { @@ -57,14 +60,7 @@ final class BuildFrontendUploadListener * * @var array */ - private array $information; - - /** - * The input provider. - * - * @var InputProviderInterface - */ - private InputProviderInterface $inputProvider; + private array $information = []; /** * The insert tag parser. @@ -124,7 +120,7 @@ private function addWidgetModeInformationToProperty(BuildAttributeEvent $event): 'doNotOverwrite' => $this->information['fe_widget_file_doNotOverwrite'], 'deselect' => (bool) $this->information['fe_widget_file_deselect'], 'delete' => (bool) $this->information['fe_widget_file_delete'], - 'uploadFolder' => $this->getUserHomeDir() ?: $this->getTargetFolder(), + 'uploadFolder' => $this->getUserHomeDir() ?? $this->getTargetFolder() ?? '', 'extendFolder' => $this->getExtendFolder(), 'normalizeExtendFolder' => (bool) $this->information['fe_widget_file_normalize_extend_folder'], 'normalizeFilename' => (bool) $this->information['fe_widget_file_normalize_filename'], @@ -172,13 +168,13 @@ private function addWidgetModeInformationToProperty(BuildAttributeEvent $event): */ private function getUserHomeDir(): ?string { - /** @var FrontendUser $feUser */ - if ($this->information['fe_widget_file_useHomeDir'] - && ($user = $this->tokenStorage->getToken()) - && ($feUser = $user->getUser()) - && $feUser->assignDir - && $feUser->homeDir - ) { + if (!$this->information['fe_widget_file_useHomeDir'] || (null === ($user = $this->tokenStorage->getToken()))) { + return null; + } + $feUser = $user->getUser(); + assert($feUser instanceof FrontendUser); + + if (((bool) $feUser->assignDir) && $feUser->homeDir) { return $feUser->homeDir; } @@ -202,13 +198,7 @@ private function getTargetFolder(): ?string */ private function getExtendFolder(): ?string { - if (!($extendFolder = $this->information['fe_widget_file_extend_folder']) - || (!str_contains($extendFolder, '{{')) - ) { - return $extendFolder ?: null; - } - - return $this->replaceInsertTag($extendFolder); + return $this->replaceInsertTagIfNeeded($this->information['fe_widget_file_extend_folder'] ?? null); } /** @@ -218,13 +208,7 @@ private function getExtendFolder(): ?string */ private function getPrefixFilename(): ?string { - if (!($extendFolder = $this->information['fe_widget_file_prefix_filename']) - || (!str_contains($extendFolder, '{{')) - ) { - return $extendFolder ?: null; - } - - return $this->replaceInsertTag($extendFolder); + return $this->replaceInsertTagIfNeeded($this->information['fe_widget_file_prefix_filename'] ?? null); } /** @@ -234,13 +218,17 @@ private function getPrefixFilename(): ?string */ private function getPostfixFilename(): ?string { - if (!($extendFolder = $this->information['fe_widget_file_postfix_filename']) - || (!str_contains($extendFolder, '{{')) - ) { - return $extendFolder ?: null; + return $this->replaceInsertTagIfNeeded($this->information['fe_widget_file_postfix_filename'] ?? null); + } + + private function replaceInsertTagIfNeeded(mixed $value): ?string + { + if (null === $value) { + return null; } + assert(\is_string($value)); - return $this->replaceInsertTag($extendFolder); + return \str_contains($value, '{{') ? $this->replaceInsertTag($value) : $value; } /** @@ -266,7 +254,7 @@ private function storeFileToTempFolder(array $extra): bool { return (isset($extra['extendFolder']) && $extra['extendFolder']) // Test if in the extent folder path find insert tag. - && (str_contains($extra['extendFolder'], '{{')); + && (\str_contains($extra['extendFolder'], '{{')); } /** @@ -278,8 +266,11 @@ private function storeFileToTempFolder(array $extra): bool */ private function wantToHandle(BuildAttributeEvent $event): bool { - return $this->scopeDeterminator->currentScopeIsFrontend() - && !$this->scopeDeterminator->currentScopeIsUnknown() + $scopeDeterminator = $this->scopeDeterminator; + assert($scopeDeterminator instanceof RequestScopeDeterminator); + + return $scopeDeterminator->currentScopeIsFrontend() + && !$scopeDeterminator->currentScopeIsUnknown() && $this->isSingleUploadField($event); } @@ -292,12 +283,12 @@ private function wantToHandle(BuildAttributeEvent $event): bool */ private function isSingleUploadField(BuildAttributeEvent $event): bool { - $properties = []; - if (!(($attribute = $event->getAttribute()) instanceof File) - || !($inputScreen = $this->viewCombination->getScreen($event->getContainer()->getName())) - || !(isset($inputScreen['properties']) && ($properties = $inputScreen['properties'])) - ) { + if (!(($attribute = $event->getAttribute()) instanceof File)) { + return false; + } + $inputScreen = $this->viewCombination->getScreen($event->getContainer()->getName()); + if ((null === $inputScreen) || (!\is_array($properties = $inputScreen['properties'] ?? null))) { return false; } @@ -308,7 +299,8 @@ private function isSingleUploadField(BuildAttributeEvent $event): bool 'fe_multiple_upload_preview' ]; $information = $properties[\array_flip(\array_column($properties, 'attr_id'))[$attribute->get('id')]]; - if (!isset($information['file_widgetMode']) + if ( + !isset($information['file_widgetMode']) || !\in_array($information['file_widgetMode'], $supportedModes, true) ) { return false; diff --git a/src/EventListener/DcGeneral/Table/Attribute/RemoveTypeOptions.php b/src/EventListener/DcGeneral/Table/Attribute/RemoveTypeOptions.php index b791c00..1cfa8e2 100644 --- a/src/EventListener/DcGeneral/Table/Attribute/RemoveTypeOptions.php +++ b/src/EventListener/DcGeneral/Table/Attribute/RemoveTypeOptions.php @@ -3,7 +3,7 @@ /** * This file is part of MetaModels/attribute_file. * - * (c) 2012-2019 The MetaModels team. + * (c) 2012-2023 The MetaModels team. * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -12,7 +12,8 @@ * * @package MetaModels/attribute_file * @author Sven Baumann - * @copyright 2012-2019 The MetaModels team. + * @author Ingolf Steinhardt + * @copyright 2012-2023 The MetaModels team. * @license https://github.com/MetaModels/attribute_file/blob/master/LICENSE LGPL-3.0-or-later * @filesource */ @@ -20,6 +21,7 @@ namespace MetaModels\AttributeFileBundle\EventListener\DcGeneral\Table\Attribute; use ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\Event\GetPropertyOptionsEvent; +use ContaoCommunityAlliance\DcGeneral\DataDefinition\ContainerInterface; /** * This class provide functions for remove type options, from the attribute table. @@ -35,15 +37,17 @@ class RemoveTypeOptions */ public function removeOption(GetPropertyOptionsEvent $event) { - $environment = $event->getEnvironment(); - if (('type' !== $event->getPropertyName()) - || ('tl_metamodel_attribute' !== $environment->getDataDefinition()->getName()) + $dataDefinition = $event->getEnvironment()->getDataDefinition(); + assert($dataDefinition instanceof ContainerInterface); + if ( + ('type' !== $event->getPropertyName()) + || ('tl_metamodel_attribute' !== $dataDefinition->getName()) ) { return; } $options = $event->getOptions(); - if (!\array_key_exists('filesort', $options)) { + if ((null === $options) || !\array_key_exists('filesort', $options)) { return; } diff --git a/src/EventListener/DcGeneral/Table/DcaSetting/FileWidgetModeOptions.php b/src/EventListener/DcGeneral/Table/DcaSetting/FileWidgetModeOptions.php index d255068..37af20f 100644 --- a/src/EventListener/DcGeneral/Table/DcaSetting/FileWidgetModeOptions.php +++ b/src/EventListener/DcGeneral/Table/DcaSetting/FileWidgetModeOptions.php @@ -3,7 +3,7 @@ /** * This file is part of MetaModels/attribute_file. * - * (c) 2012-2022 The MetaModels team. + * (c) 2012-2023 The MetaModels team. * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -13,7 +13,7 @@ * @package MetaModels/attribute_file * @author Sven Baumann * @author Ingolf Steinhardt - * @copyright 2012-2022 The MetaModels team. + * @copyright 2012-2023 The MetaModels team. * @license https://github.com/MetaModels/attribute_file/blob/master/LICENSE LGPL-3.0-or-later * @filesource */ @@ -38,7 +38,7 @@ class FileWidgetModeOptions extends AbstractListener * * @var bool */ - private $frontendEditing; + private bool $frontendEditing; /** * {@inheritDoc} @@ -62,7 +62,8 @@ public function __construct( */ public function __invoke(GetPropertyOptionsEvent $event): void { - if (('file_widgetMode' !== $event->getPropertyName()) + if ( + ('file_widgetMode' !== $event->getPropertyName()) || (false === $this->wantToHandle($event)) || (false === $this->isAttributeFile($event)) ) { @@ -94,7 +95,7 @@ private function addOptions(GetPropertyOptionsEvent $event): void ); } - $event->setOptions(\array_values(\array_unique(\array_merge($event->getOptions(), $addOptions)))); + $event->setOptions(\array_values(\array_unique(\array_merge($event->getOptions() ?? [], $addOptions)))); } /** @@ -119,7 +120,8 @@ private function isAttributeFile(GetPropertyOptionsEvent $event): bool } $result = $statement->fetchAssociative(); - return 'file' === $result['type']; + + return 'file' === ($result['type'] ?? null); } /** diff --git a/src/EventListener/DcGeneral/Table/FilterSetting/RemoveAttIdOptions.php b/src/EventListener/DcGeneral/Table/FilterSetting/RemoveAttIdOptions.php index e027b89..c4da897 100644 --- a/src/EventListener/DcGeneral/Table/FilterSetting/RemoveAttIdOptions.php +++ b/src/EventListener/DcGeneral/Table/FilterSetting/RemoveAttIdOptions.php @@ -3,7 +3,7 @@ /** * This file is part of MetaModels/attribute_file. * - * (c) 2012-2019 The MetaModels team. + * (c) 2012-2023 The MetaModels team. * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -12,7 +12,7 @@ * * @package MetaModels/attribute_file * @author Sven Baumann - * @copyright 2012-2019 The MetaModels team. + * @copyright 2012-2023 The MetaModels team. * @license https://github.com/MetaModels/attribute_file/blob/master/LICENSE LGPL-3.0-or-later * @filesource */ @@ -20,6 +20,7 @@ namespace MetaModels\AttributeFileBundle\EventListener\DcGeneral\Table\FilterSetting; use ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\Event\GetPropertyOptionsEvent; +use ContaoCommunityAlliance\DcGeneral\DataDefinition\ContainerInterface; /** * This class provide functions for remove type options, from the filter setting table. @@ -35,17 +36,19 @@ class RemoveAttIdOptions */ public function removeOption(GetPropertyOptionsEvent $event) { - $environment = $event->getEnvironment(); - if (('attr_id' !== $event->getPropertyName()) - || ('tl_metamodel_filtersetting' !== $environment->getDataDefinition()->getName()) + $dataDefinition = $event->getEnvironment()->getDataDefinition(); + assert($dataDefinition instanceof ContainerInterface); + if ( + ('attr_id' !== $event->getPropertyName()) + || ('tl_metamodel_filtersetting' !== $dataDefinition->getName()) ) { return; } - $options = $event->getOptions(); + $options = $event->getOptions() ?? []; foreach ($options as $key => $name) { $sortKey = $key . '__sort'; - if (\array_key_exists($sortKey, $options) && ('[file]' === \substr($name, -\strlen('[file]')))) { + if (\array_key_exists($sortKey, $options) && (\str_ends_with($name, '[file]'))) { unset($options[$sortKey]); } } diff --git a/src/EventListener/ImageSizeOptionsListener.php b/src/EventListener/ImageSizeOptionsListener.php index cf8ed7b..144b267 100644 --- a/src/EventListener/ImageSizeOptionsListener.php +++ b/src/EventListener/ImageSizeOptionsListener.php @@ -3,7 +3,7 @@ /** * This file is part of MetaModels/attribute_file. * - * (c) 2012-2019 The MetaModels team. + * (c) 2012-2023 The MetaModels team. * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -13,7 +13,7 @@ * @package MetaModels/attribute_file * @author Stefan Heimes * @author Christian Schiffler - * @copyright 2012-2019 The MetaModels team. + * @copyright 2012-2023 The MetaModels team. * @license https://github.com/MetaModels/attribute_file/blob/master/LICENSE LGPL-3.0-or-later * @filesource */ @@ -21,7 +21,9 @@ namespace MetaModels\AttributeFileBundle\EventListener; use ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\Event\GetPropertyOptionsEvent; +use ContaoCommunityAlliance\DcGeneral\Data\CollectionInterface; use ContaoCommunityAlliance\DcGeneral\Data\DefaultDataProvider; +use ContaoCommunityAlliance\DcGeneral\DataDefinition\ContainerInterface; /** * Get the options for the image size. @@ -37,8 +39,12 @@ class ImageSizeOptionsListener */ public function getPropertyOptions(GetPropertyOptionsEvent $event) { - if (('file_imageSize' !== $event->getPropertyName()) - || ('tl_metamodel_rendersetting' !== $event->getEnvironment()->getDataDefinition()->getName()) + $dataDefinition = $event->getEnvironment()->getDataDefinition(); + assert($dataDefinition instanceof ContainerInterface); + + if ( + ('file_imageSize' !== $event->getPropertyName()) + || ('tl_metamodel_rendersetting' !== $dataDefinition->getName()) ) { return; } @@ -48,10 +54,11 @@ public function getPropertyOptions(GetPropertyOptionsEvent $event) return; } - $options = $event->getOptions(); - $options['image_sizes'] = \array_replace($sizes, (array) $options['image_sizes']); - - $event->setOptions($options); + $options = $event->getOptions(); + if (\is_array($options) && \array_key_exists('image_sizes', $options)) { + $options['image_sizes'] = \array_replace($sizes, $options['image_sizes']); + $event->setOptions($options); + } } /** @@ -59,16 +66,17 @@ public function getPropertyOptions(GetPropertyOptionsEvent $event) * * @return array */ - private function getThemeImageSizes() + private function getThemeImageSizes(): array { $dataProvider = new DefaultDataProvider(); $dataProvider->setBaseConfig(['source' => 'tl_image_size']); $config = $dataProvider->getEmptyConfig(); $config->setFields(['id', 'name', 'width', 'height']); - $config->setSorting(['pid', 'name']); + $config->setSorting(['pid' => 'ASC', 'name' => 'ASC']); $collection = $dataProvider->fetchAll($config); + assert($collection instanceof CollectionInterface); if (!$collection->count()) { return []; } diff --git a/src/Migration/AddProtectedDownloadMigration.php b/src/Migration/AddProtectedDownloadMigration.php index 6f821f2..3e5d2d9 100644 --- a/src/Migration/AddProtectedDownloadMigration.php +++ b/src/Migration/AddProtectedDownloadMigration.php @@ -3,7 +3,7 @@ /** * This file is part of MetaModels/attribute_file. * - * (c) 2012-2022 The MetaModels team. + * (c) 2012-2023 The MetaModels team. * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -12,7 +12,7 @@ * * @package MetaModels/attribute_file * @author Ingolf Steinhardt - * @copyright 2012-2022 The MetaModels team. + * @copyright 2012-2023 The MetaModels team. * @license https://github.com/MetaModels/attribute_file/blob/master/LICENSE LGPL-3.0-or-later * @filesource */ @@ -79,14 +79,16 @@ public function getName(): string */ public function shouldRun(): bool { - $schemaManager = $this->connection->getSchemaManager(); + $schemaManager = $this->connection->createSchemaManager(); if (!$schemaManager->tablesExist(['tl_metamodel', 'tl_metamodel_rendersetting'])) { return false; } - if ($this->fieldExists('tl_metamodel_rendersetting', 'file_showLink') - && !$this->fieldExists('tl_metamodel_rendersetting', 'file_protectedDownload')) { + if ( + $this->fieldExists('tl_metamodel_rendersetting', 'file_showLink') + && !$this->fieldExists('tl_metamodel_rendersetting', 'file_protectedDownload') + ) { return true; } @@ -111,7 +113,7 @@ public function run(): MigrationResult $this->connection->createQueryBuilder() ->update('tl_metamodel_rendersetting', 't') ->set('t.file_protectedDownload', 't.file_showLink') - ->execute(); + ->executeQuery(); return new MigrationResult(true, 'Adjusted table tl_metamodel_rendersetting with file_protectedDownload'); } @@ -129,7 +131,7 @@ public function run(): MigrationResult */ private function fieldExists(string $tableName, string $columnName): bool { - $columns = $this->connection->getSchemaManager()->listTableColumns($tableName); + $columns = $this->connection->createSchemaManager()->listTableColumns($tableName); return isset($columns[strtolower($columnName)]); } diff --git a/src/Migration/AddSortFieldMigration.php b/src/Migration/AddSortFieldMigration.php index ed1a5f1..f328f9a 100644 --- a/src/Migration/AddSortFieldMigration.php +++ b/src/Migration/AddSortFieldMigration.php @@ -110,8 +110,10 @@ public function run(): MigrationResult { $attributes = $this->getFileAttributes(); - if (!$this->fieldExists('tl_metamodel_attribute', 'file_multiple') - && !$attributes->rowCount()) { + if ( + !$this->fieldExists('tl_metamodel_attribute', 'file_multiple') + && !$attributes->rowCount() + ) { return new MigrationResult(true, 'Nothing to do.'); } @@ -132,7 +134,8 @@ public function run(): MigrationResult return new MigrationResult( true, - \sprintf('Add columns for attribute file: %s', \implode(', ', $messages))); + \sprintf('Add columns for attribute file: %s', \implode(', ', $messages)) + ); } /** @@ -147,7 +150,7 @@ private function getFileAttributes(): Result return $this ->connection ->createQueryBuilder() - ->select('metamodel.tableName', 'attribute.colname') + ->select('metamodel.tableName, attribute.colname') ->from('tl_metamodel_attribute', 'attribute') ->leftJoin('attribute', 'tl_metamodel', 'metamodel', 'metamodel.id=attribute.pid') ->where('attribute.type=:type') diff --git a/src/Schema/DoctrineSchemaGenerator.php b/src/Schema/DoctrineSchemaGenerator.php index 1779cef..fb045a6 100644 --- a/src/Schema/DoctrineSchemaGenerator.php +++ b/src/Schema/DoctrineSchemaGenerator.php @@ -18,7 +18,7 @@ * @filesource */ -declare(strict_types = 1); +declare(strict_types=1); namespace MetaModels\AttributeFileBundle\Schema; diff --git a/tests/Attribute/FileAttributeTypeFactoryTest.php b/tests/Attribute/FileAttributeTypeFactoryTest.php index b9683c5..a5d1bd1 100644 --- a/tests/Attribute/FileAttributeTypeFactoryTest.php +++ b/tests/Attribute/FileAttributeTypeFactoryTest.php @@ -47,9 +47,7 @@ class FileAttributeTypeFactoryTest extends TestCase * Mock a MetaModel. * * @param string $tableName The table name. - * * @param string $language The language. - * * @param string $fallbackLanguage The fallback language. * * @return IMetaModel @@ -89,8 +87,8 @@ private function mockConnection(AbstractSchemaManager $schemaManager = null) $connection ->expects(self::any()) - ->method('getSchemaManager') - ->willReturn($schemaManager); + ->method('createSchemaManager') + ->willReturn($schemaManager ?? $this->mockSchemaManager()); return $connection; } diff --git a/tests/Attribute/FileTest.php b/tests/Attribute/FileTest.php index 7c07acb..fa7f0ae 100644 --- a/tests/Attribute/FileTest.php +++ b/tests/Attribute/FileTest.php @@ -3,7 +3,7 @@ /** * This file is part of MetaModels/attribute_file. * - * (c) 2012-2022 The MetaModels team. + * (c) 2012-2024 The MetaModels team. * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -15,7 +15,7 @@ * @author David Greminger * @author Sven Baumann * @author Ingolf Steinhardt - * @copyright 2012-2022 The MetaModels team. + * @copyright 2012-2024 The MetaModels team. * @license https://github.com/MetaModels/attribute_file/blob/master/LICENSE LGPL-3.0-or-later * @filesource */ @@ -25,9 +25,10 @@ use Contao\CoreBundle\Framework\Adapter; use Contao\CoreBundle\Image\ImageFactoryInterface; use Doctrine\DBAL\Connection; +use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Query\Expression\ExpressionBuilder; use Doctrine\DBAL\Query\QueryBuilder; -use Doctrine\DBAL\Statement; +use Doctrine\DBAL\Result; use MetaModels\AttributeFileBundle\Attribute\File; use MetaModels\Helper\TableManipulator; use MetaModels\Helper\ToolboxFile; @@ -46,7 +47,6 @@ class FileTest extends TestCase * Mock a MetaModel. * * @param string $tableName The table name. - * * @param string $language The language. * * @return IMetaModel @@ -77,10 +77,19 @@ protected function mockMetaModel($tableName, $language) */ private function mockConnection($methods = []) { - return $this->getMockBuilder(Connection::class) + $connection = $this->getMockBuilder(Connection::class) ->disableOriginalConstructor() - ->setMethods($methods) + ->onlyMethods(\array_merge($methods, ['getDatabasePlatform'])) ->getMock(); + + $platform = $this + ->getMockBuilder(AbstractPlatform::class) + ->disableOriginalConstructor() + ->onlyMethods([]) + ->getMockForAbstractClass(); + $connection->method('getDatabasePlatform')->willReturn($platform); + + return $connection; } /** @@ -101,6 +110,8 @@ private function mockTableManipulator(Connection $connection) * Mock the image factory. * * @return ImageFactoryInterface|MockObject + * + * @SuppressWarnings(PHPMD.UnusedPrivateMethod) */ private function mockImageFactory() { @@ -220,32 +231,35 @@ public function testSearchFor() $connection = $this->mockConnection(['createQueryBuilder']); $manipulator = $this->mockTableManipulator($connection); - $statement = $this - ->getMockBuilder(Statement::class) + $result = $this + ->getMockBuilder(Result::class) ->disableOriginalConstructor() - ->setMethods(['fetchAll']) + ->onlyMethods(['fetchFirstColumn']) ->getMock(); - $statement + $result ->expects(self::once()) - ->method('fetchAll') - ->with(\PDO::FETCH_COLUMN) + ->method('fetchFirstColumn') ->willReturn(['1', '2', '3', '4', '5']); $builder1 = $this ->getMockBuilder(QueryBuilder::class) - ->disableOriginalConstructor() - ->setMethods(['expr']) + ->setConstructorArgs([$connection]) + ->onlyMethods(['expr', 'getSQL']) ->getMock(); $builder1->expects(self::once())->method('expr')->willReturn(new ExpressionBuilder($connection)); + $builder1 + ->expects(self::once()) + ->method('getSQL') + ->willReturn('SELECT f.uuid FROM tl_files f WHERE f.path LIKE :value'); $builder2 = $this ->getMockBuilder(QueryBuilder::class) - ->disableOriginalConstructor() - ->setMethods(['execute', 'expr']) + ->setConstructorArgs([$connection]) + ->onlyMethods(['executeQuery', 'expr']) ->getMock(); $builder2->expects(self::once())->method('expr')->willReturn(new ExpressionBuilder($connection)); - $builder2->expects(self::once())->method('execute')->willReturn($statement); + $builder2->expects(self::once())->method('executeQuery')->willReturn($result); $connection ->expects(self::exactly(2)) @@ -271,7 +285,8 @@ public function testSearchFor() /** @var QueryBuilder $builder2 */ self::assertSame( - 'SELECT t.id FROM mm_test t WHERE file_attribute IN (SELECT f.uuid FROM tl_files f WHERE f.path LIKE :value)', + 'SELECT t.id FROM mm_test t ' . + 'WHERE file_attribute IN (SELECT f.uuid FROM tl_files f WHERE f.path LIKE :value)', $builder2->getSQL() ); self::assertSame(['value' => '%test_value'], $builder2->getParameters()); diff --git a/tests/DependencyInjection/MetaModelsAttributeFileExtensionTest.php b/tests/DependencyInjection/MetaModelsAttributeFileExtensionTest.php index 6135f37..b3c7fd7 100644 --- a/tests/DependencyInjection/MetaModelsAttributeFileExtensionTest.php +++ b/tests/DependencyInjection/MetaModelsAttributeFileExtensionTest.php @@ -3,7 +3,7 @@ /** * This file is part of MetaModels/attribute_file. * - * (c) 2012-2021 The MetaModels team. + * (c) 2012-2024 The MetaModels team. * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -13,15 +13,16 @@ * @package MetaModels/attribute_file * @author Christian Schiffler * @author Sven Baumann - * @copyright 2012-2021 The MetaModels team. + * @author Ingolf Steinhardt + * @copyright 2012-2024 The MetaModels team. * @license https://github.com/MetaModels/attribute_file/blob/master/LICENSE LGPL-3.0-or-later * @filesource */ namespace MetaModels\AttributeFileBundle\Test\DependencyInjection; -use MetaModels\AttributeFileBundle\Attribute\AttributeTypeFactory; use MetaModels\AttributeFileBundle\DependencyInjection\MetaModelsAttributeFileExtension; +use MetaModels\AttributeFileBundle\EventListener\DcGeneral\Table\DcaSetting\FileWidgetModeOptions; use MetaModels\ContaoFrontendEditingBundle\MetaModelsContaoFrontendEditingBundle; use MetaModels\AttributeFileBundle\EventListener\BuildAttributeListener; use MetaModels\AttributeFileBundle\EventListener\BuildDataDefinitionListener; @@ -39,12 +40,7 @@ */ class MetaModelsAttributeFileExtensionTest extends TestCase { - /** - * Test that extension can be instantiated. - * - * @return void - */ - public function testInstantiation() + public function testInstantiation(): void { $extension = new MetaModelsAttributeFileExtension(); @@ -52,103 +48,44 @@ public function testInstantiation() self::assertInstanceOf(ExtensionInterface::class, $extension); } - /** - * Test that the services are loaded. - * - * @return void - */ - public function testFactoryIsRegistered() + public function testFactoryIsRegistered(): void { - $container = $this->getMockBuilder(ContainerBuilder::class)->getMock(); + $container = new ContainerBuilder(); + $container->setParameter('kernel.debug', false); + $container->setParameter('metamodels.cache_dir', 'cache/dir'); + $container->setParameter('kernel.bundles', [MetaModelsContaoFrontendEditingBundle::class]); - $container - ->expects(self::atLeastOnce()) - ->method('setDefinition') - ->withConsecutive( - [ - 'metamodels.attribute_file.factory', - self::callback( - function ($value) { - /** @var Definition $value */ - $this->assertInstanceOf(Definition::class, $value); - $this->assertEquals(AttributeTypeFactory::class, $value->getClass()); - $this->assertCount(1, $value->getTag('metamodels.attribute_factory')); - - return true; - } - ) - ], - [ - 'metamodels.attribute_file.event_listener.image_size_options', - $this->callback(function ($value) { - /** @var Definition $value */ - $this->assertInstanceOf(Definition::class, $value); - $this->assertEquals(ImageSizeOptionsListener::class, $value->getClass()); - $this->assertCount(1, $value->getTag('kernel.event_listener')); - - return true; - }) - ], - [ - 'metamodels.attribute_file.event_listener.build_attribute', - $this->callback(function ($value) { - /** @var Definition $value */ - $this->assertInstanceOf(Definition::class, $value); - $this->assertEquals(BuildAttributeListener::class, $value->getClass()); - $this->assertCount(1, $value->getTag('kernel.event_listener')); - - return true; - }) - ], - [ - 'metamodels.attribute_file.event_listener.build-data-definition', - $this->callback(function ($value) { - /** @var Definition $value */ - $this->assertInstanceOf(Definition::class, $value); - $this->assertEquals(BuildDataDefinitionListener::class, $value->getClass()); - $this->assertCount(1, $value->getTag('kernel.event_listener')); + $extension = new MetaModelsAttributeFileExtension(); + $extension->load([], $container); - return true; - }) - ], - [ - DoctrineSchemaGenerator::class, - $this->callback( - function ($value) { - /** @var Definition $value */ - $this->assertInstanceOf(Definition::class, $value); - $this->assertCount(1, $value->getTag('metamodels.schema-generator.doctrine')); + self::assertTrue($container->hasAlias('metamodels.attribute_file.toolbox.file')); - return true; - } - ) - ] - ); - $container - ->method('getParameter') - ->willReturn(false, 'cache/dir', [MetaModelsContaoFrontendEditingBundle::class]); + self::assertTrue($container->hasDefinition('metamodels.attribute_file.event_listener.build_attribute')); + $definition = $container->getDefinition('metamodels.attribute_file.event_listener.build_attribute'); + self::assertCount(1, $definition->getTag('kernel.event_listener')); - $definition = $this->createMock(Definition::class); + self::assertTrue($container->hasDefinition('metamodels.attribute_file.event_listener.image_size_options')); + $definition = $container->getDefinition('metamodels.attribute_file.event_listener.image_size_options'); + self::assertCount(1, $definition->getTag('kernel.event_listener')); - $definition - ->method('setArgument') - ->willReturnCallback( - function (string $key, bool $value) { - switch ($key) { - case '$frontendEditing': - self::assertTrue($value); - break; - default: - } - } - ); + self::assertTrue($container->hasDefinition('metamodels.attribute_file.event_listener.build-data-definition')); + $definition = $container->getDefinition('metamodels.attribute_file.event_listener.build-data-definition'); + self::assertCount(1, $definition->getTag('kernel.event_listener')); - $container - ->method('getDefinition') - ->willReturn($definition); + self::assertTrue($container->hasDefinition(DoctrineSchemaGenerator::class)); + $definition = $container->getDefinition(DoctrineSchemaGenerator::class); + self::assertCount(1, $definition->getTag('metamodels.schema-generator.doctrine')); - $extension = new MetaModelsAttributeFileExtension(); - $extension->load([], $container); + self::assertTrue($container->hasParameter('metamodels.managed-schema-type-names')); + self::assertSame(['file'], $container->getParameter('metamodels.managed-schema-type-names')); + self::assertTrue($container->hasParameter('metamodels.attribute_file.cache_dir')); + self::assertSame( + '%metamodels.cache_dir%/attribute_file', + $container->getParameter('metamodels.attribute_file.cache_dir') + ); + self::assertTrue($container->hasDefinition(FileWidgetModeOptions::class)); + $definition = $container->getDefinition(FileWidgetModeOptions::class); + self::assertTrue($definition->getArgument('$frontendEditing')); } } diff --git a/tests/EventListener/DcGeneral/Table/FilterSetting/RemoveAttIdOptionsTest.php b/tests/EventListener/DcGeneral/Table/FilterSetting/RemoveAttIdOptionsTest.php index e56a4b9..0d165d4 100644 --- a/tests/EventListener/DcGeneral/Table/FilterSetting/RemoveAttIdOptionsTest.php +++ b/tests/EventListener/DcGeneral/Table/FilterSetting/RemoveAttIdOptionsTest.php @@ -3,7 +3,7 @@ /** * This file is part of MetaModels/attribute_file. * - * (c) 2012-2021 The MetaModels team. + * (c) 2012-2023 The MetaModels team. * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -12,7 +12,8 @@ * * @package MetaModels/attribute_file * @author Sven Baumann - * @copyright 2012-2021 The MetaModels team. + * @author Ingolf Steinhardt + * @copyright 2012-2023 The MetaModels team. * @license https://github.com/MetaModels/attribute_file/blob/master/LICENSE LGPL-3.0-or-later * @filesource */ @@ -85,9 +86,19 @@ public function dataProviderTestRemoveOption() return [ [['foo' => 'bar [file]', 'filesort' => 'foo'], 'foo', 'foo', ['foo' => 'bar [file]', 'filesort' => 'foo']], - [['foo' => 'bar [file]', 'filesort' => 'foo'], 'foo', 'attr_id', ['foo' => 'bar [file]', 'filesort' => 'foo']], + [ + ['foo' => 'bar [file]', 'filesort' => 'foo'], + 'foo', + 'attr_id', + ['foo' => 'bar [file]', 'filesort' => 'foo'] + ], [['foo' => 'bar [file]'], 'tl_metamodel_filtersetting', 'attr_id', ['foo' => 'bar [file]']], - [['foo' => 'bar [file]'], 'tl_metamodel_filtersetting', 'attr_id', ['foo' => 'bar [file]', 'foo__sort' => 'foo']] + [ + ['foo' => 'bar [file]'], + 'tl_metamodel_filtersetting', + 'attr_id', + ['foo' => 'bar [file]', 'foo__sort' => 'foo'] + ] ]; } diff --git a/tests/EventListener/Factory/AddAttributeInformationTest.php b/tests/EventListener/Factory/AddAttributeInformationTest.php index 164bf6b..ad0f233 100644 --- a/tests/EventListener/Factory/AddAttributeInformationTest.php +++ b/tests/EventListener/Factory/AddAttributeInformationTest.php @@ -3,7 +3,7 @@ /** * This file is part of MetaModels/core. * - * (c) 2012-2021 The MetaModels team. + * (c) 2012-2023 The MetaModels team. * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -12,7 +12,8 @@ * * @package MetaModels/core * @author Sven Baumann - * @copyright 2012-2021 The MetaModels team. + * @author Ingolf Steinhardt + * @copyright 2012-2023 The MetaModels team. * @license https://github.com/MetaModels/core/blob/master/LICENSE LGPL-3.0-or-later * @filesource */ @@ -32,6 +33,7 @@ */ class AddAttributeInformationTest extends TestCase { + /** @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function dataProviderAddInformation() { return [ diff --git a/tests/Schema/DoctrineSchemaGeneratorTest.php b/tests/Schema/DoctrineSchemaGeneratorTest.php index d4d08b4..b0786bd 100644 --- a/tests/Schema/DoctrineSchemaGeneratorTest.php +++ b/tests/Schema/DoctrineSchemaGeneratorTest.php @@ -3,7 +3,7 @@ /** * This file is part of MetaModels/attribute_file. * - * (c) 2012-2019 The MetaModels team. + * (c) 2012-2024 The MetaModels team. * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -12,12 +12,13 @@ * * @package MetaModels/attribute_file * @author Christian Schiffler - * @copyright 2012-2019 The MetaModels team. + * @author Ingolf Steinhardt + * @copyright 2012-2024 The MetaModels team. * @license https://github.com/MetaModels/attribute_file/blob/master/LICENSE LGPL-3.0-or-later * @filesource */ -declare(strict_types = 1); +declare(strict_types=1); namespace MetaModels\AttributeFileBundle\Test\Schema; @@ -30,6 +31,8 @@ /** * This tests the schema generator. + * + * @covers \MetaModels\AttributeFileBundle\Schema\DoctrineSchemaGenerator */ class DoctrineSchemaGeneratorTest extends TestCase { From 9c9cbc3a1f00defc32d5ad4acac40b43144f79b9 Mon Sep 17 00:00:00 2001 From: Ingolf Steinardt Date: Wed, 24 Apr 2024 18:29:34 +0200 Subject: [PATCH 29/56] Fixes for PHPCQ2 --- .phpcq.lock | 2 +- src/Attribute/File.php | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.phpcq.lock b/.phpcq.lock index 7229a0a..4ec1fc3 100644 --- a/.phpcq.lock +++ b/.phpcq.lock @@ -1 +1 @@ -{"plugins":{"phpunit":{"api-version":"1.0.0","version":"1.0.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpunit/phpunit-1.0.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0"},"tool":{"phpunit":"^6.0 || ^7.0 || ^8.0 || ^9.0"}},"checksum":{"type":"sha-512","value":"c73f15658e3ba62665f09492ec91c3a6a715760bfaa88473a987538439fff442540148e086e46a6aa18ce55a3ea2fbf76caaa581384cb84a38859fcc609ae7e4"},"tools":{"phpunit":{"version":"9.6.16","url":"https://phar.phpunit.de/phpunit-9.6.16.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*","ext-json":"*","ext-libxml":"*","ext-mbstring":"*","ext-xml":"*","ext-xmlwriter":"*"}},"checksum":{"type":"sha-256","value":"891d46f06284db3695498aff5dfd6a944f835e07db2981295db2c2bcf6cfd338"},"signature":"https://phar.phpunit.de/phpunit-9.6.16.phar.asc"}},"composerLock":null},"psalm":{"api-version":"1.0.0","version":"1.2.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/psalm/psalm-1.2.0.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0","ext-dom":"*"},"tool":{"psalm":"^3.0 || ^4.0 || ^5.0"}},"checksum":{"type":"sha-512","value":"4a550c9226d7bca582d7c10bd87cce01190c96398936b1613421640c83df62ed1c6e0d44c1b39635414ea8cf4a892a6458d27590793238add24e7cb5547e6ffd"},"tools":{"psalm":{"version":"5.21.1","url":"https://github.com/vimeo/psalm/releases/download/5.21.1/psalm.phar","requirements":{"php":{"php":"^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0","ext-SimpleXML":"*","ext-ctype":"*","ext-dom":"*","ext-json":"*","ext-libxml":"*","ext-mbstring":"*","ext-tokenizer":"*"}},"checksum":null,"signature":"https://github.com/vimeo/psalm/releases/download/5.21.1/psalm.phar.asc"}},"composerLock":null},"composer-require-checker":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/composer-require-checker/composer-require-checker-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0"},"tool":{"composer-require-checker":"^3.8 || ^4.0"}},"checksum":{"type":"sha-512","value":"d5415bddfe024c5749d894034583882aee4e5c3e1087815d9fdd81cb5e71630f631a0e35de0ff84b97fbbf738c16ece5f83bd8c00695913eb846aa6f04577dc2"},"tools":{"composer-require-checker":{"version":"4.7.1","url":"https://github.com/maglnet/ComposerRequireChecker/releases/download/4.7.1/composer-require-checker.phar","requirements":{"php":{"php":"~8.1.0 || ~8.2.0 || ~8.3.0","ext-phar":"*"}},"checksum":null,"signature":"https://github.com/maglnet/ComposerRequireChecker/releases/download/4.7.1/composer-require-checker.phar.asc"}},"composerLock":null},"phpmd":{"api-version":"1.0.0","version":"1.0.2.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpmd/phpmd-1.0.2.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpmd":"^2.6.1"}},"checksum":{"type":"sha-512","value":"f22280a6dec8dbdd2ec1d83b294f23237fe32c34f4a298e52038e0a7a0074d541635b2b488b1a6098a42d8418a6cd8eb804406ea82b91e362be2b5d11a0915b0"},"tools":{"phpmd":{"version":"2.15.0","url":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar","requirements":{"php":{"php":">=5.3.9","ext-xml":"*"}},"checksum":null,"signature":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar.asc"}},"composerLock":null},"phpcpd":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpcpd/phpcpd-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcpd":"^6.0"}},"checksum":{"type":"sha-512","value":"1189ce0bf3fade4cb4241f1d96f915ef8fc7651f4450dc79fdf464ee3d6be3009316f0d423ce2d4af9d76ad50807b7fdf4d77bfa6d9ee2c91d6eda32ea214433"},"tools":{"phpcpd":{"version":"6.0.3","url":"https://phar.phpunit.de/phpcpd-6.0.3.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*"}},"checksum":{"type":"sha-256","value":"2cbaea7cfda1bb4299d863eb075e977c3f49055dd16d88529fae5150d48a84cb"},"signature":"https://phar.phpunit.de/phpcpd-6.0.3.phar.asc"}},"composerLock":null},"phploc":{"api-version":"1.0.0","version":"1.0.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phploc/phploc-1.0.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*","ext-json":"*"},"tool":{"phploc":"^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0"}},"checksum":{"type":"sha-512","value":"f67b02d494796adf553cb3dd13ec06c1cb8e53c799954061749424251379541637538199afb3afa3c7a01cabd1cb6f1c53eb621f015dff9644c6c7cbf10c56d1"},"tools":{"phploc":{"version":"7.0.2","url":"https://phar.phpunit.de/phploc-7.0.2.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*","ext-json":"*"}},"checksum":{"type":"sha-256","value":"3d59778ec86faf25fd00e3a329b2f9ad4a3c751ca91601ea7dab70f887b0bf46"},"signature":"https://phar.phpunit.de/phploc-7.0.2.phar.asc"}},"composerLock":null},"phpcs":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpcs/phpcs-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcs":"^3.0 || ^2.0","phpcbf":"^3.0 || ^2.0"}},"checksum":{"type":"sha-512","value":"2737022369da1318cc4e0ea194e8a81019f7b079080d869aab878b7486052fdbe68fee3f28131f35573226def1aabd4bd005e038ee7b767c137b1107c1492a83"},"tools":{"phpcs":{"version":"3.8.1","url":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.8.1/phpcs.phar","requirements":{"php":{"php":">=5.4.0","ext-simplexml":"*","ext-tokenizer":"*","ext-xmlwriter":"*"}},"checksum":null,"signature":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.8.1/phpcs.phar.asc"},"phpcbf":{"version":"3.8.1","url":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.8.1/phpcbf.phar","requirements":{"php":{"php":">=5.4.0","ext-simplexml":"*","ext-tokenizer":"*","ext-xmlwriter":"*"}},"checksum":null,"signature":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.8.1/phpcbf.phar.asc"}},"composerLock":null},"composer-normalize":{"api-version":"1.0.0","version":"1.1.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/composer-normalize/composer-normalize-1.1.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-json":"*"},"tool":{"composer-normalize":"^2.1"}},"checksum":{"type":"sha-512","value":"d59d3557cb20630734878a9115df5dd32d5aff815e5b15be36f6fb5d6e9d83dd36efd84215ab6529edcc924f600946f739a0d9e67723deff95c88346ab502498"},"tools":{"composer-normalize":{"version":"2.42.0","url":"https://github.com/ergebnis/composer-normalize/releases/download/2.42.0/composer-normalize.phar","requirements":{"php":{"php":"~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0","ext-json":"*"}},"checksum":null,"signature":"https://github.com/ergebnis/composer-normalize/releases/download/2.42.0/composer-normalize.phar.asc"}},"composerLock":null}},"tools":[]} \ No newline at end of file +{"plugins":{"phpunit":{"api-version":"1.0.0","version":"1.0.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpunit/phpunit-1.0.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0"},"tool":{"phpunit":"^6.0 || ^7.0 || ^8.0 || ^9.0"}},"checksum":{"type":"sha-512","value":"c73f15658e3ba62665f09492ec91c3a6a715760bfaa88473a987538439fff442540148e086e46a6aa18ce55a3ea2fbf76caaa581384cb84a38859fcc609ae7e4"},"tools":{"phpunit":{"version":"9.6.18","url":"https://phar.phpunit.de/phpunit-9.6.18.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*","ext-json":"*","ext-libxml":"*","ext-mbstring":"*","ext-xml":"*","ext-xmlwriter":"*"}},"checksum":{"type":"sha-256","value":"fc3729afdbab93cbf9f662de730bcc2f936bd9255bb08c6c53d41b9b0a30ec62"},"signature":"https://phar.phpunit.de/phpunit-9.6.18.phar.asc"}},"composerLock":null},"psalm":{"api-version":"1.0.0","version":"1.2.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/psalm/psalm-1.2.0.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0","ext-dom":"*"},"tool":{"psalm":"^3.0 || ^4.0 || ^5.0"}},"checksum":{"type":"sha-512","value":"4a550c9226d7bca582d7c10bd87cce01190c96398936b1613421640c83df62ed1c6e0d44c1b39635414ea8cf4a892a6458d27590793238add24e7cb5547e6ffd"},"tools":{"psalm":{"version":"5.23.1","url":"https://github.com/vimeo/psalm/releases/download/5.23.1/psalm.phar","requirements":{"php":{"php":"^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0","ext-SimpleXML":"*","ext-ctype":"*","ext-dom":"*","ext-json":"*","ext-libxml":"*","ext-mbstring":"*","ext-tokenizer":"*"}},"checksum":null,"signature":"https://github.com/vimeo/psalm/releases/download/5.23.1/psalm.phar.asc"}},"composerLock":null},"composer-require-checker":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/composer-require-checker/composer-require-checker-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0"},"tool":{"composer-require-checker":"^3.8 || ^4.0"}},"checksum":{"type":"sha-512","value":"d5415bddfe024c5749d894034583882aee4e5c3e1087815d9fdd81cb5e71630f631a0e35de0ff84b97fbbf738c16ece5f83bd8c00695913eb846aa6f04577dc2"},"tools":{"composer-require-checker":{"version":"4.7.1","url":"https://github.com/maglnet/ComposerRequireChecker/releases/download/4.7.1/composer-require-checker.phar","requirements":{"php":{"php":"~8.1.0 || ~8.2.0 || ~8.3.0","ext-phar":"*"}},"checksum":null,"signature":"https://github.com/maglnet/ComposerRequireChecker/releases/download/4.7.1/composer-require-checker.phar.asc"}},"composerLock":null},"phpmd":{"api-version":"1.0.0","version":"1.0.2.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpmd/phpmd-1.0.2.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpmd":"^2.6.1"}},"checksum":{"type":"sha-512","value":"f22280a6dec8dbdd2ec1d83b294f23237fe32c34f4a298e52038e0a7a0074d541635b2b488b1a6098a42d8418a6cd8eb804406ea82b91e362be2b5d11a0915b0"},"tools":{"phpmd":{"version":"2.15.0","url":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar","requirements":{"php":{"php":">=5.3.9","ext-xml":"*"}},"checksum":null,"signature":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar.asc"}},"composerLock":null},"phpcpd":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpcpd/phpcpd-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcpd":"^6.0"}},"checksum":{"type":"sha-512","value":"1189ce0bf3fade4cb4241f1d96f915ef8fc7651f4450dc79fdf464ee3d6be3009316f0d423ce2d4af9d76ad50807b7fdf4d77bfa6d9ee2c91d6eda32ea214433"},"tools":{"phpcpd":{"version":"6.0.3","url":"https://phar.phpunit.de/phpcpd-6.0.3.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*"}},"checksum":{"type":"sha-256","value":"2cbaea7cfda1bb4299d863eb075e977c3f49055dd16d88529fae5150d48a84cb"},"signature":"https://phar.phpunit.de/phpcpd-6.0.3.phar.asc"}},"composerLock":null},"phploc":{"api-version":"1.0.0","version":"1.0.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phploc/phploc-1.0.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*","ext-json":"*"},"tool":{"phploc":"^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0"}},"checksum":{"type":"sha-512","value":"f67b02d494796adf553cb3dd13ec06c1cb8e53c799954061749424251379541637538199afb3afa3c7a01cabd1cb6f1c53eb621f015dff9644c6c7cbf10c56d1"},"tools":{"phploc":{"version":"7.0.2","url":"https://phar.phpunit.de/phploc-7.0.2.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*","ext-json":"*"}},"checksum":{"type":"sha-256","value":"3d59778ec86faf25fd00e3a329b2f9ad4a3c751ca91601ea7dab70f887b0bf46"},"signature":"https://phar.phpunit.de/phploc-7.0.2.phar.asc"}},"composerLock":null},"phpcs":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpcs/phpcs-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcs":"^3.0 || ^2.0","phpcbf":"^3.0 || ^2.0"}},"checksum":{"type":"sha-512","value":"2737022369da1318cc4e0ea194e8a81019f7b079080d869aab878b7486052fdbe68fee3f28131f35573226def1aabd4bd005e038ee7b767c137b1107c1492a83"},"tools":{"phpcs":{"version":"3.9.1","url":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.9.1/phpcs.phar","requirements":{"php":{"php":">=5.4.0","ext-simplexml":"*","ext-tokenizer":"*","ext-xmlwriter":"*"}},"checksum":null,"signature":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.9.1/phpcs.phar.asc"},"phpcbf":{"version":"3.9.1","url":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.9.1/phpcbf.phar","requirements":{"php":{"php":">=5.4.0","ext-simplexml":"*","ext-tokenizer":"*","ext-xmlwriter":"*"}},"checksum":null,"signature":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.9.1/phpcbf.phar.asc"}},"composerLock":null},"composer-normalize":{"api-version":"1.0.0","version":"1.1.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/composer-normalize/composer-normalize-1.1.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-json":"*"},"tool":{"composer-normalize":"^2.1"}},"checksum":{"type":"sha-512","value":"d59d3557cb20630734878a9115df5dd32d5aff815e5b15be36f6fb5d6e9d83dd36efd84215ab6529edcc924f600946f739a0d9e67723deff95c88346ab502498"},"tools":{"composer-normalize":{"version":"2.42.0","url":"https://github.com/ergebnis/composer-normalize/releases/download/2.42.0/composer-normalize.phar","requirements":{"php":{"php":"~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0","ext-json":"*"}},"checksum":null,"signature":"https://github.com/ergebnis/composer-normalize/releases/download/2.42.0/composer-normalize.phar.asc"}},"composerLock":null}},"tools":[]} \ No newline at end of file diff --git a/src/Attribute/File.php b/src/Attribute/File.php index c2d8ab5..f4cc322 100644 --- a/src/Attribute/File.php +++ b/src/Attribute/File.php @@ -270,7 +270,10 @@ public function searchFor($strPattern) ->where($builder->expr()->in($this->getColName(), $subSelect->getSQL())) ->setParameter('value', \str_replace(['*', '?'], ['%', '_'], $strPattern)); - return $builder->executeQuery()->fetchFirstColumn(); + $statement = $builder->executeQuery(); + + // Return value list as list, parent function wants a list so we make a cast. + return \array_map(static fn(mixed $value) => (string) $value, $statement->fetchFirstColumn()); } /** From 69ba7369bc9d3a9d477b57a3e0360e85bc63aaa0 Mon Sep 17 00:00:00 2001 From: Ingolf Steinardt Date: Wed, 5 Jun 2024 19:11:32 +0200 Subject: [PATCH 30/56] Fixes for PHPCQ2 --- .phpcq.lock | 2 +- .phpcq.yaml.dist | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.phpcq.lock b/.phpcq.lock index 4ec1fc3..d67ac47 100644 --- a/.phpcq.lock +++ b/.phpcq.lock @@ -1 +1 @@ -{"plugins":{"phpunit":{"api-version":"1.0.0","version":"1.0.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpunit/phpunit-1.0.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0"},"tool":{"phpunit":"^6.0 || ^7.0 || ^8.0 || ^9.0"}},"checksum":{"type":"sha-512","value":"c73f15658e3ba62665f09492ec91c3a6a715760bfaa88473a987538439fff442540148e086e46a6aa18ce55a3ea2fbf76caaa581384cb84a38859fcc609ae7e4"},"tools":{"phpunit":{"version":"9.6.18","url":"https://phar.phpunit.de/phpunit-9.6.18.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*","ext-json":"*","ext-libxml":"*","ext-mbstring":"*","ext-xml":"*","ext-xmlwriter":"*"}},"checksum":{"type":"sha-256","value":"fc3729afdbab93cbf9f662de730bcc2f936bd9255bb08c6c53d41b9b0a30ec62"},"signature":"https://phar.phpunit.de/phpunit-9.6.18.phar.asc"}},"composerLock":null},"psalm":{"api-version":"1.0.0","version":"1.2.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/psalm/psalm-1.2.0.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0","ext-dom":"*"},"tool":{"psalm":"^3.0 || ^4.0 || ^5.0"}},"checksum":{"type":"sha-512","value":"4a550c9226d7bca582d7c10bd87cce01190c96398936b1613421640c83df62ed1c6e0d44c1b39635414ea8cf4a892a6458d27590793238add24e7cb5547e6ffd"},"tools":{"psalm":{"version":"5.23.1","url":"https://github.com/vimeo/psalm/releases/download/5.23.1/psalm.phar","requirements":{"php":{"php":"^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0","ext-SimpleXML":"*","ext-ctype":"*","ext-dom":"*","ext-json":"*","ext-libxml":"*","ext-mbstring":"*","ext-tokenizer":"*"}},"checksum":null,"signature":"https://github.com/vimeo/psalm/releases/download/5.23.1/psalm.phar.asc"}},"composerLock":null},"composer-require-checker":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/composer-require-checker/composer-require-checker-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0"},"tool":{"composer-require-checker":"^3.8 || ^4.0"}},"checksum":{"type":"sha-512","value":"d5415bddfe024c5749d894034583882aee4e5c3e1087815d9fdd81cb5e71630f631a0e35de0ff84b97fbbf738c16ece5f83bd8c00695913eb846aa6f04577dc2"},"tools":{"composer-require-checker":{"version":"4.7.1","url":"https://github.com/maglnet/ComposerRequireChecker/releases/download/4.7.1/composer-require-checker.phar","requirements":{"php":{"php":"~8.1.0 || ~8.2.0 || ~8.3.0","ext-phar":"*"}},"checksum":null,"signature":"https://github.com/maglnet/ComposerRequireChecker/releases/download/4.7.1/composer-require-checker.phar.asc"}},"composerLock":null},"phpmd":{"api-version":"1.0.0","version":"1.0.2.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpmd/phpmd-1.0.2.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpmd":"^2.6.1"}},"checksum":{"type":"sha-512","value":"f22280a6dec8dbdd2ec1d83b294f23237fe32c34f4a298e52038e0a7a0074d541635b2b488b1a6098a42d8418a6cd8eb804406ea82b91e362be2b5d11a0915b0"},"tools":{"phpmd":{"version":"2.15.0","url":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar","requirements":{"php":{"php":">=5.3.9","ext-xml":"*"}},"checksum":null,"signature":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar.asc"}},"composerLock":null},"phpcpd":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpcpd/phpcpd-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcpd":"^6.0"}},"checksum":{"type":"sha-512","value":"1189ce0bf3fade4cb4241f1d96f915ef8fc7651f4450dc79fdf464ee3d6be3009316f0d423ce2d4af9d76ad50807b7fdf4d77bfa6d9ee2c91d6eda32ea214433"},"tools":{"phpcpd":{"version":"6.0.3","url":"https://phar.phpunit.de/phpcpd-6.0.3.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*"}},"checksum":{"type":"sha-256","value":"2cbaea7cfda1bb4299d863eb075e977c3f49055dd16d88529fae5150d48a84cb"},"signature":"https://phar.phpunit.de/phpcpd-6.0.3.phar.asc"}},"composerLock":null},"phploc":{"api-version":"1.0.0","version":"1.0.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phploc/phploc-1.0.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*","ext-json":"*"},"tool":{"phploc":"^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0"}},"checksum":{"type":"sha-512","value":"f67b02d494796adf553cb3dd13ec06c1cb8e53c799954061749424251379541637538199afb3afa3c7a01cabd1cb6f1c53eb621f015dff9644c6c7cbf10c56d1"},"tools":{"phploc":{"version":"7.0.2","url":"https://phar.phpunit.de/phploc-7.0.2.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*","ext-json":"*"}},"checksum":{"type":"sha-256","value":"3d59778ec86faf25fd00e3a329b2f9ad4a3c751ca91601ea7dab70f887b0bf46"},"signature":"https://phar.phpunit.de/phploc-7.0.2.phar.asc"}},"composerLock":null},"phpcs":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpcs/phpcs-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcs":"^3.0 || ^2.0","phpcbf":"^3.0 || ^2.0"}},"checksum":{"type":"sha-512","value":"2737022369da1318cc4e0ea194e8a81019f7b079080d869aab878b7486052fdbe68fee3f28131f35573226def1aabd4bd005e038ee7b767c137b1107c1492a83"},"tools":{"phpcs":{"version":"3.9.1","url":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.9.1/phpcs.phar","requirements":{"php":{"php":">=5.4.0","ext-simplexml":"*","ext-tokenizer":"*","ext-xmlwriter":"*"}},"checksum":null,"signature":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.9.1/phpcs.phar.asc"},"phpcbf":{"version":"3.9.1","url":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.9.1/phpcbf.phar","requirements":{"php":{"php":">=5.4.0","ext-simplexml":"*","ext-tokenizer":"*","ext-xmlwriter":"*"}},"checksum":null,"signature":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.9.1/phpcbf.phar.asc"}},"composerLock":null},"composer-normalize":{"api-version":"1.0.0","version":"1.1.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/composer-normalize/composer-normalize-1.1.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-json":"*"},"tool":{"composer-normalize":"^2.1"}},"checksum":{"type":"sha-512","value":"d59d3557cb20630734878a9115df5dd32d5aff815e5b15be36f6fb5d6e9d83dd36efd84215ab6529edcc924f600946f739a0d9e67723deff95c88346ab502498"},"tools":{"composer-normalize":{"version":"2.42.0","url":"https://github.com/ergebnis/composer-normalize/releases/download/2.42.0/composer-normalize.phar","requirements":{"php":{"php":"~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0","ext-json":"*"}},"checksum":null,"signature":"https://github.com/ergebnis/composer-normalize/releases/download/2.42.0/composer-normalize.phar.asc"}},"composerLock":null}},"tools":[]} \ No newline at end of file +{"plugins":{"phpunit":{"api-version":"1.0.0","version":"1.0.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpunit/phpunit-1.0.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0"},"tool":{"phpunit":"^6.0 || ^7.0 || ^8.0 || ^9.0"}},"checksum":{"type":"sha-512","value":"c73f15658e3ba62665f09492ec91c3a6a715760bfaa88473a987538439fff442540148e086e46a6aa18ce55a3ea2fbf76caaa581384cb84a38859fcc609ae7e4"},"tools":{"phpunit":{"version":"9.6.19","url":"https://phar.phpunit.de/phpunit-9.6.19.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*","ext-json":"*","ext-libxml":"*","ext-mbstring":"*","ext-xml":"*","ext-xmlwriter":"*"}},"checksum":{"type":"sha-256","value":"f30c21743f4fbea14ad8ab8f47673f9067117262dafa147fcb182e75fbc1c249"},"signature":"https://phar.phpunit.de/phpunit-9.6.19.phar.asc"}},"composerLock":null},"psalm":{"api-version":"1.0.0","version":"1.2.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/psalm/psalm-1.2.0.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0","ext-dom":"*"},"tool":{"psalm":"^3.0 || ^4.0 || ^5.0"}},"checksum":{"type":"sha-512","value":"4a550c9226d7bca582d7c10bd87cce01190c96398936b1613421640c83df62ed1c6e0d44c1b39635414ea8cf4a892a6458d27590793238add24e7cb5547e6ffd"},"tools":{"psalm":{"version":"5.24.0","url":"https://github.com/vimeo/psalm/releases/download/5.24.0/psalm.phar","requirements":{"php":{"php":"^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0","ext-SimpleXML":"*","ext-ctype":"*","ext-dom":"*","ext-json":"*","ext-libxml":"*","ext-mbstring":"*","ext-tokenizer":"*"}},"checksum":null,"signature":"https://github.com/vimeo/psalm/releases/download/5.24.0/psalm.phar.asc"}},"composerLock":null},"composer-require-checker":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/composer-require-checker/composer-require-checker-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0"},"tool":{"composer-require-checker":"^3.8 || ^4.0"}},"checksum":{"type":"sha-512","value":"d5415bddfe024c5749d894034583882aee4e5c3e1087815d9fdd81cb5e71630f631a0e35de0ff84b97fbbf738c16ece5f83bd8c00695913eb846aa6f04577dc2"},"tools":{"composer-require-checker":{"version":"4.11.0","url":"https://github.com/maglnet/ComposerRequireChecker/releases/download/4.11.0/composer-require-checker.phar","requirements":{"php":{"php":"~8.2.0 || ~8.3.0","ext-phar":"*"}},"checksum":null,"signature":"https://github.com/maglnet/ComposerRequireChecker/releases/download/4.11.0/composer-require-checker.phar.asc"}},"composerLock":null},"phpmd":{"api-version":"1.0.0","version":"1.0.2.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpmd/phpmd-1.0.2.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpmd":"^2.6.1"}},"checksum":{"type":"sha-512","value":"f22280a6dec8dbdd2ec1d83b294f23237fe32c34f4a298e52038e0a7a0074d541635b2b488b1a6098a42d8418a6cd8eb804406ea82b91e362be2b5d11a0915b0"},"tools":{"phpmd":{"version":"2.15.0","url":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar","requirements":{"php":{"php":">=5.3.9","ext-xml":"*"}},"checksum":null,"signature":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar.asc"}},"composerLock":null},"phpcpd":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpcpd/phpcpd-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcpd":"^6.0"}},"checksum":{"type":"sha-512","value":"1189ce0bf3fade4cb4241f1d96f915ef8fc7651f4450dc79fdf464ee3d6be3009316f0d423ce2d4af9d76ad50807b7fdf4d77bfa6d9ee2c91d6eda32ea214433"},"tools":{"phpcpd":{"version":"6.0.3","url":"https://phar.phpunit.de/phpcpd-6.0.3.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*"}},"checksum":{"type":"sha-256","value":"2cbaea7cfda1bb4299d863eb075e977c3f49055dd16d88529fae5150d48a84cb"},"signature":"https://phar.phpunit.de/phpcpd-6.0.3.phar.asc"}},"composerLock":null},"phploc":{"api-version":"1.0.0","version":"1.0.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phploc/phploc-1.0.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*","ext-json":"*"},"tool":{"phploc":"^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0"}},"checksum":{"type":"sha-512","value":"f67b02d494796adf553cb3dd13ec06c1cb8e53c799954061749424251379541637538199afb3afa3c7a01cabd1cb6f1c53eb621f015dff9644c6c7cbf10c56d1"},"tools":{"phploc":{"version":"7.0.2","url":"https://phar.phpunit.de/phploc-7.0.2.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*","ext-json":"*"}},"checksum":{"type":"sha-256","value":"3d59778ec86faf25fd00e3a329b2f9ad4a3c751ca91601ea7dab70f887b0bf46"},"signature":"https://phar.phpunit.de/phploc-7.0.2.phar.asc"}},"composerLock":null},"phpcs":{"api-version":"1.0.0","version":"1.2.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpcs/phpcs-1.2.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcs":"^3.0 || ^2.0","phpcbf":"^3.0 || ^2.0"}},"checksum":{"type":"sha-512","value":"b6ed00306e76068a6af5e3b1dec837724f9e1900ef1049ce88e7ce195b0583524ca33a73613fba13244307a7ca853b6ddaa14ded69f651c3f184ac130bd1aaad"},"tools":{"phpcs":{"version":"3.10.1","url":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.10.1/phpcs.phar","requirements":{"php":{"php":">=5.4.0","ext-simplexml":"*","ext-tokenizer":"*","ext-xmlwriter":"*"}},"checksum":null,"signature":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.10.1/phpcs.phar.asc"},"phpcbf":{"version":"3.10.1","url":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.10.1/phpcbf.phar","requirements":{"php":{"php":">=5.4.0","ext-simplexml":"*","ext-tokenizer":"*","ext-xmlwriter":"*"}},"checksum":null,"signature":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.10.1/phpcbf.phar.asc"}},"composerLock":null},"composer-normalize":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/composer-normalize/composer-normalize-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-json":"*"},"tool":{"composer-normalize":"^2.1"}},"checksum":{"type":"sha-512","value":"d9abda440b85d501c58abf9c81bf76f417594b397129215ffa8b777e9bb5e5eda37d7661d661db3c8d11c24f20345bc6fbe56f013b3b9435d459d2b94f086e0f"},"tools":{"composer-normalize":{"version":"2.42.0","url":"https://github.com/ergebnis/composer-normalize/releases/download/2.42.0/composer-normalize.phar","requirements":{"php":{"php":"~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0","ext-json":"*"}},"checksum":null,"signature":"https://github.com/ergebnis/composer-normalize/releases/download/2.42.0/composer-normalize.phar.asc"}},"composerLock":null}},"tools":[]} \ No newline at end of file diff --git a/.phpcq.yaml.dist b/.phpcq.yaml.dist index 04eee1d..41607a4 100644 --- a/.phpcq.yaml.dist +++ b/.phpcq.yaml.dist @@ -45,6 +45,8 @@ phpcq: - D2CCAC42F6295E7D # PHP_CodeSniffer - 31C7E470E2138192 + - 5E6DDE998AB73B8E + - A978220305CD5C32 # Composer normalize - C00543248C87FB13 # phpmd From 74bd19cfa2231222a0fd5274c40b7654824dd878 Mon Sep 17 00:00:00 2001 From: Cliff Parnitzky Date: Wed, 12 Jun 2024 20:25:35 +0000 Subject: [PATCH 31/56] Enable predefined dimensions for image sizes of `config.yaml` to be selectable. --- src/Resources/contao/dca/tl_metamodel_rendersetting.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Resources/contao/dca/tl_metamodel_rendersetting.php b/src/Resources/contao/dca/tl_metamodel_rendersetting.php index 1919802..1933b59 100644 --- a/src/Resources/contao/dca/tl_metamodel_rendersetting.php +++ b/src/Resources/contao/dca/tl_metamodel_rendersetting.php @@ -16,6 +16,7 @@ * @author Sven Baumann * @author Ingolf Steinhardt * @author Stefan Heimes + * @author Cliff Parnitzky * @copyright 2012-2022 The MetaModels team. * @license https://github.com/MetaModels/attribute_file/blob/master/LICENSE LGPL-3.0-or-later * @filesource @@ -84,11 +85,14 @@ 'label' => &$GLOBALS['TL_LANG']['tl_metamodel_rendersetting']['file_imageSize'], 'exclude' => true, 'inputType' => 'imageSize', - 'options' => $GLOBALS['TL_CROP'], + 'options_callback' => static function () + { + return System::getContainer()->get('contao.image.sizes')->getOptionsForUser(BackendUser::getInstance()); + }, 'reference' => &$GLOBALS['TL_LANG']['MSC'], 'sql' => 'varchar(255) NOT NULL default \'\'', 'eval' => [ - 'rgxp' => 'digit', + 'rgxp' => 'natural', 'includeBlankOption' => true, 'nospace' => true, 'helpwizard' => true, From 2c28bb6298af7d6cf69f782d497b7bf8e13e2566 Mon Sep 17 00:00:00 2001 From: Cliff Parnitzky Date: Mon, 24 Jun 2024 21:34:35 +0000 Subject: [PATCH 32/56] Updated the copyright years --- src/Resources/contao/dca/tl_metamodel_rendersetting.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Resources/contao/dca/tl_metamodel_rendersetting.php b/src/Resources/contao/dca/tl_metamodel_rendersetting.php index 1933b59..c65fb2c 100644 --- a/src/Resources/contao/dca/tl_metamodel_rendersetting.php +++ b/src/Resources/contao/dca/tl_metamodel_rendersetting.php @@ -3,7 +3,7 @@ /** * This file is part of MetaModels/attribute_file. * - * (c) 2012-2022 The MetaModels team. + * (c) 2012-2024 The MetaModels team. * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -17,7 +17,7 @@ * @author Ingolf Steinhardt * @author Stefan Heimes * @author Cliff Parnitzky - * @copyright 2012-2022 The MetaModels team. + * @copyright 2012-2024 The MetaModels team. * @license https://github.com/MetaModels/attribute_file/blob/master/LICENSE LGPL-3.0-or-later * @filesource */ From 00f2a0ea7ae15f066ba24231ae724a93335cb08e Mon Sep 17 00:00:00 2001 From: Ingolf Steinardt Date: Mon, 8 Jul 2024 16:57:23 +0200 Subject: [PATCH 33/56] Fix migration --- .phpcq.lock | 2 +- src/Migration/AddSortFieldMigration.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.phpcq.lock b/.phpcq.lock index d67ac47..aa37692 100644 --- a/.phpcq.lock +++ b/.phpcq.lock @@ -1 +1 @@ -{"plugins":{"phpunit":{"api-version":"1.0.0","version":"1.0.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpunit/phpunit-1.0.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0"},"tool":{"phpunit":"^6.0 || ^7.0 || ^8.0 || ^9.0"}},"checksum":{"type":"sha-512","value":"c73f15658e3ba62665f09492ec91c3a6a715760bfaa88473a987538439fff442540148e086e46a6aa18ce55a3ea2fbf76caaa581384cb84a38859fcc609ae7e4"},"tools":{"phpunit":{"version":"9.6.19","url":"https://phar.phpunit.de/phpunit-9.6.19.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*","ext-json":"*","ext-libxml":"*","ext-mbstring":"*","ext-xml":"*","ext-xmlwriter":"*"}},"checksum":{"type":"sha-256","value":"f30c21743f4fbea14ad8ab8f47673f9067117262dafa147fcb182e75fbc1c249"},"signature":"https://phar.phpunit.de/phpunit-9.6.19.phar.asc"}},"composerLock":null},"psalm":{"api-version":"1.0.0","version":"1.2.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/psalm/psalm-1.2.0.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0","ext-dom":"*"},"tool":{"psalm":"^3.0 || ^4.0 || ^5.0"}},"checksum":{"type":"sha-512","value":"4a550c9226d7bca582d7c10bd87cce01190c96398936b1613421640c83df62ed1c6e0d44c1b39635414ea8cf4a892a6458d27590793238add24e7cb5547e6ffd"},"tools":{"psalm":{"version":"5.24.0","url":"https://github.com/vimeo/psalm/releases/download/5.24.0/psalm.phar","requirements":{"php":{"php":"^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0","ext-SimpleXML":"*","ext-ctype":"*","ext-dom":"*","ext-json":"*","ext-libxml":"*","ext-mbstring":"*","ext-tokenizer":"*"}},"checksum":null,"signature":"https://github.com/vimeo/psalm/releases/download/5.24.0/psalm.phar.asc"}},"composerLock":null},"composer-require-checker":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/composer-require-checker/composer-require-checker-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0"},"tool":{"composer-require-checker":"^3.8 || ^4.0"}},"checksum":{"type":"sha-512","value":"d5415bddfe024c5749d894034583882aee4e5c3e1087815d9fdd81cb5e71630f631a0e35de0ff84b97fbbf738c16ece5f83bd8c00695913eb846aa6f04577dc2"},"tools":{"composer-require-checker":{"version":"4.11.0","url":"https://github.com/maglnet/ComposerRequireChecker/releases/download/4.11.0/composer-require-checker.phar","requirements":{"php":{"php":"~8.2.0 || ~8.3.0","ext-phar":"*"}},"checksum":null,"signature":"https://github.com/maglnet/ComposerRequireChecker/releases/download/4.11.0/composer-require-checker.phar.asc"}},"composerLock":null},"phpmd":{"api-version":"1.0.0","version":"1.0.2.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpmd/phpmd-1.0.2.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpmd":"^2.6.1"}},"checksum":{"type":"sha-512","value":"f22280a6dec8dbdd2ec1d83b294f23237fe32c34f4a298e52038e0a7a0074d541635b2b488b1a6098a42d8418a6cd8eb804406ea82b91e362be2b5d11a0915b0"},"tools":{"phpmd":{"version":"2.15.0","url":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar","requirements":{"php":{"php":">=5.3.9","ext-xml":"*"}},"checksum":null,"signature":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar.asc"}},"composerLock":null},"phpcpd":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpcpd/phpcpd-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcpd":"^6.0"}},"checksum":{"type":"sha-512","value":"1189ce0bf3fade4cb4241f1d96f915ef8fc7651f4450dc79fdf464ee3d6be3009316f0d423ce2d4af9d76ad50807b7fdf4d77bfa6d9ee2c91d6eda32ea214433"},"tools":{"phpcpd":{"version":"6.0.3","url":"https://phar.phpunit.de/phpcpd-6.0.3.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*"}},"checksum":{"type":"sha-256","value":"2cbaea7cfda1bb4299d863eb075e977c3f49055dd16d88529fae5150d48a84cb"},"signature":"https://phar.phpunit.de/phpcpd-6.0.3.phar.asc"}},"composerLock":null},"phploc":{"api-version":"1.0.0","version":"1.0.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phploc/phploc-1.0.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*","ext-json":"*"},"tool":{"phploc":"^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0"}},"checksum":{"type":"sha-512","value":"f67b02d494796adf553cb3dd13ec06c1cb8e53c799954061749424251379541637538199afb3afa3c7a01cabd1cb6f1c53eb621f015dff9644c6c7cbf10c56d1"},"tools":{"phploc":{"version":"7.0.2","url":"https://phar.phpunit.de/phploc-7.0.2.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*","ext-json":"*"}},"checksum":{"type":"sha-256","value":"3d59778ec86faf25fd00e3a329b2f9ad4a3c751ca91601ea7dab70f887b0bf46"},"signature":"https://phar.phpunit.de/phploc-7.0.2.phar.asc"}},"composerLock":null},"phpcs":{"api-version":"1.0.0","version":"1.2.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpcs/phpcs-1.2.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcs":"^3.0 || ^2.0","phpcbf":"^3.0 || ^2.0"}},"checksum":{"type":"sha-512","value":"b6ed00306e76068a6af5e3b1dec837724f9e1900ef1049ce88e7ce195b0583524ca33a73613fba13244307a7ca853b6ddaa14ded69f651c3f184ac130bd1aaad"},"tools":{"phpcs":{"version":"3.10.1","url":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.10.1/phpcs.phar","requirements":{"php":{"php":">=5.4.0","ext-simplexml":"*","ext-tokenizer":"*","ext-xmlwriter":"*"}},"checksum":null,"signature":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.10.1/phpcs.phar.asc"},"phpcbf":{"version":"3.10.1","url":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.10.1/phpcbf.phar","requirements":{"php":{"php":">=5.4.0","ext-simplexml":"*","ext-tokenizer":"*","ext-xmlwriter":"*"}},"checksum":null,"signature":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.10.1/phpcbf.phar.asc"}},"composerLock":null},"composer-normalize":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/composer-normalize/composer-normalize-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-json":"*"},"tool":{"composer-normalize":"^2.1"}},"checksum":{"type":"sha-512","value":"d9abda440b85d501c58abf9c81bf76f417594b397129215ffa8b777e9bb5e5eda37d7661d661db3c8d11c24f20345bc6fbe56f013b3b9435d459d2b94f086e0f"},"tools":{"composer-normalize":{"version":"2.42.0","url":"https://github.com/ergebnis/composer-normalize/releases/download/2.42.0/composer-normalize.phar","requirements":{"php":{"php":"~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0","ext-json":"*"}},"checksum":null,"signature":"https://github.com/ergebnis/composer-normalize/releases/download/2.42.0/composer-normalize.phar.asc"}},"composerLock":null}},"tools":[]} \ No newline at end of file +{"plugins":{"phpunit":{"api-version":"1.0.0","version":"1.0.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpunit/phpunit-1.0.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0"},"tool":{"phpunit":"^6.0 || ^7.0 || ^8.0 || ^9.0"}},"checksum":{"type":"sha-512","value":"c73f15658e3ba62665f09492ec91c3a6a715760bfaa88473a987538439fff442540148e086e46a6aa18ce55a3ea2fbf76caaa581384cb84a38859fcc609ae7e4"},"tools":{"phpunit":{"version":"9.6.19","url":"https://phar.phpunit.de/phpunit-9.6.19.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*","ext-json":"*","ext-libxml":"*","ext-mbstring":"*","ext-xml":"*","ext-xmlwriter":"*"}},"checksum":{"type":"sha-256","value":"f30c21743f4fbea14ad8ab8f47673f9067117262dafa147fcb182e75fbc1c249"},"signature":"https://phar.phpunit.de/phpunit-9.6.19.phar.asc"}},"composerLock":null},"psalm":{"api-version":"1.0.0","version":"1.2.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/psalm/psalm-1.2.0.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0","ext-dom":"*"},"tool":{"psalm":"^3.0 || ^4.0 || ^5.0"}},"checksum":{"type":"sha-512","value":"4a550c9226d7bca582d7c10bd87cce01190c96398936b1613421640c83df62ed1c6e0d44c1b39635414ea8cf4a892a6458d27590793238add24e7cb5547e6ffd"},"tools":{"psalm":{"version":"5.25.0","url":"https://github.com/vimeo/psalm/releases/download/5.25.0/psalm.phar","requirements":{"php":{"php":"^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0","ext-SimpleXML":"*","ext-ctype":"*","ext-dom":"*","ext-json":"*","ext-libxml":"*","ext-mbstring":"*","ext-tokenizer":"*"}},"checksum":null,"signature":"https://github.com/vimeo/psalm/releases/download/5.25.0/psalm.phar.asc"}},"composerLock":null},"composer-require-checker":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/composer-require-checker/composer-require-checker-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0"},"tool":{"composer-require-checker":"^3.8 || ^4.0"}},"checksum":{"type":"sha-512","value":"d5415bddfe024c5749d894034583882aee4e5c3e1087815d9fdd81cb5e71630f631a0e35de0ff84b97fbbf738c16ece5f83bd8c00695913eb846aa6f04577dc2"},"tools":{"composer-require-checker":{"version":"4.11.0","url":"https://github.com/maglnet/ComposerRequireChecker/releases/download/4.11.0/composer-require-checker.phar","requirements":{"php":{"php":"~8.2.0 || ~8.3.0","ext-phar":"*"}},"checksum":null,"signature":"https://github.com/maglnet/ComposerRequireChecker/releases/download/4.11.0/composer-require-checker.phar.asc"}},"composerLock":null},"phpmd":{"api-version":"1.0.0","version":"1.0.2.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpmd/phpmd-1.0.2.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpmd":"^2.6.1"}},"checksum":{"type":"sha-512","value":"f22280a6dec8dbdd2ec1d83b294f23237fe32c34f4a298e52038e0a7a0074d541635b2b488b1a6098a42d8418a6cd8eb804406ea82b91e362be2b5d11a0915b0"},"tools":{"phpmd":{"version":"2.15.0","url":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar","requirements":{"php":{"php":">=5.3.9","ext-xml":"*"}},"checksum":null,"signature":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar.asc"}},"composerLock":null},"phpcpd":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpcpd/phpcpd-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcpd":"^6.0"}},"checksum":{"type":"sha-512","value":"1189ce0bf3fade4cb4241f1d96f915ef8fc7651f4450dc79fdf464ee3d6be3009316f0d423ce2d4af9d76ad50807b7fdf4d77bfa6d9ee2c91d6eda32ea214433"},"tools":{"phpcpd":{"version":"6.0.3","url":"https://phar.phpunit.de/phpcpd-6.0.3.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*"}},"checksum":{"type":"sha-256","value":"2cbaea7cfda1bb4299d863eb075e977c3f49055dd16d88529fae5150d48a84cb"},"signature":"https://phar.phpunit.de/phpcpd-6.0.3.phar.asc"}},"composerLock":null},"phploc":{"api-version":"1.0.0","version":"1.0.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phploc/phploc-1.0.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*","ext-json":"*"},"tool":{"phploc":"^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0"}},"checksum":{"type":"sha-512","value":"f67b02d494796adf553cb3dd13ec06c1cb8e53c799954061749424251379541637538199afb3afa3c7a01cabd1cb6f1c53eb621f015dff9644c6c7cbf10c56d1"},"tools":{"phploc":{"version":"7.0.2","url":"https://phar.phpunit.de/phploc-7.0.2.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*","ext-json":"*"}},"checksum":{"type":"sha-256","value":"3d59778ec86faf25fd00e3a329b2f9ad4a3c751ca91601ea7dab70f887b0bf46"},"signature":"https://phar.phpunit.de/phploc-7.0.2.phar.asc"}},"composerLock":null},"phpcs":{"api-version":"1.0.0","version":"1.2.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpcs/phpcs-1.2.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcs":"^3.0 || ^2.0","phpcbf":"^3.0 || ^2.0"}},"checksum":{"type":"sha-512","value":"b6ed00306e76068a6af5e3b1dec837724f9e1900ef1049ce88e7ce195b0583524ca33a73613fba13244307a7ca853b6ddaa14ded69f651c3f184ac130bd1aaad"},"tools":{"phpcs":{"version":"3.10.1","url":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.10.1/phpcs.phar","requirements":{"php":{"php":">=5.4.0","ext-simplexml":"*","ext-tokenizer":"*","ext-xmlwriter":"*"}},"checksum":null,"signature":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.10.1/phpcs.phar.asc"},"phpcbf":{"version":"3.10.1","url":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.10.1/phpcbf.phar","requirements":{"php":{"php":">=5.4.0","ext-simplexml":"*","ext-tokenizer":"*","ext-xmlwriter":"*"}},"checksum":null,"signature":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.10.1/phpcbf.phar.asc"}},"composerLock":null},"composer-normalize":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/composer-normalize/composer-normalize-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-json":"*"},"tool":{"composer-normalize":"^2.1"}},"checksum":{"type":"sha-512","value":"d9abda440b85d501c58abf9c81bf76f417594b397129215ffa8b777e9bb5e5eda37d7661d661db3c8d11c24f20345bc6fbe56f013b3b9435d459d2b94f086e0f"},"tools":{"composer-normalize":{"version":"2.43.0","url":"https://github.com/ergebnis/composer-normalize/releases/download/2.43.0/composer-normalize.phar","requirements":{"php":{"php":"~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0","ext-json":"*"}},"checksum":null,"signature":"https://github.com/ergebnis/composer-normalize/releases/download/2.43.0/composer-normalize.phar.asc"}},"composerLock":null}},"tools":[]} \ No newline at end of file diff --git a/src/Migration/AddSortFieldMigration.php b/src/Migration/AddSortFieldMigration.php index f328f9a..41534ce 100644 --- a/src/Migration/AddSortFieldMigration.php +++ b/src/Migration/AddSortFieldMigration.php @@ -109,6 +109,7 @@ public function shouldRun(): bool public function run(): MigrationResult { $attributes = $this->getFileAttributes(); + $rows = $attributes->fetchAllAssociative(); if ( !$this->fieldExists('tl_metamodel_attribute', 'file_multiple') @@ -118,7 +119,7 @@ public function run(): MigrationResult } $messages = []; - while ($row = $attributes->fetchAssociative()) { + foreach ($rows as $row) { if ($this->fieldExists($row['tableName'], $row['colname'] . '__sort')) { continue; } From 91c07e0b21a74cb586f7c1b789c9b3887dca152b Mon Sep 17 00:00:00 2001 From: Ingolf Steinardt Date: Fri, 19 Jul 2024 16:07:47 +0200 Subject: [PATCH 34/56] Changes for translation loader --- .tx/config | 29 +++ composer.json | 7 +- .../contao/dca/tl_metamodel_attribute.php | 59 +++--- .../contao/dca/tl_metamodel_dcasetting.php | 169 ++++++++++-------- .../contao/dca/tl_metamodel_rendersetting.php | 79 ++++---- src/Resources/contao/languages/en/default.php | 23 --- .../languages/en/tl_metamodel_attribute.php | 45 ----- .../languages/en/tl_metamodel_dcasetting.php | 90 ---------- .../en/tl_metamodel_rendersetting.php | 48 ----- .../tl_metamodel_attribute.en.xlf | 49 +++++ .../tl_metamodel_dcasetting.en.xlf | 124 +++++++++++++ .../tl_metamodel_rendersetting.en.xlf | 61 +++++++ 12 files changed, 442 insertions(+), 341 deletions(-) create mode 100644 .tx/config delete mode 100644 src/Resources/contao/languages/en/default.php delete mode 100644 src/Resources/contao/languages/en/tl_metamodel_attribute.php delete mode 100644 src/Resources/contao/languages/en/tl_metamodel_dcasetting.php delete mode 100644 src/Resources/contao/languages/en/tl_metamodel_rendersetting.php create mode 100644 src/Resources/translations/tl_metamodel_attribute.en.xlf create mode 100644 src/Resources/translations/tl_metamodel_dcasetting.en.xlf create mode 100644 src/Resources/translations/tl_metamodel_rendersetting.en.xlf diff --git a/.tx/config b/.tx/config new file mode 100644 index 0000000..6a1f87a --- /dev/null +++ b/.tx/config @@ -0,0 +1,29 @@ +[main] +host = https://app.transifex.com + +[o:metamodels:p:attribute-file:r:tl_metamodel_attribute] +file_filter = src/Resources/translations/tl_metamodel_attribute..xlf +source_file = src/Resources/translations/tl_metamodel_attribute.en.xlf +type = XLIFF +minimum_perc = 0 +resource_name = tl_metamodel_attribute +replace_edited_strings = false +keep_translations = false + +[o:metamodels:p:attribute-file:r:tl_metamodel_dcasetting] +file_filter = src/Resources/translations/tl_metamodel_dcasetting..xlf +source_file = src/Resources/translations/tl_metamodel_dcasetting.en.xlf +type = XLIFF +minimum_perc = 0 +resource_name = tl_metamodel_dcasetting +replace_edited_strings = false +keep_translations = false + +[o:metamodels:p:attribute-file:r:tl_metamodel_rendersetting] +file_filter = src/Resources/translations/tl_metamodel_rendersetting..xlf +source_file = src/Resources/translations/tl_metamodel_rendersetting.en.xlf +type = XLIFF +minimum_perc = 0 +resource_name = tl_metamodel_rendersetting +replace_edited_strings = false +keep_translations = false diff --git a/composer.json b/composer.json index f501308..7e64509 100644 --- a/composer.json +++ b/composer.json @@ -49,12 +49,7 @@ "metamodels/contao-frontend-editing": "^2.3@dev", "phpcq/runner-bootstrap": "^1.0@dev" }, - "repositories": [ - { - "type": "composer", - "url": "https://packages.cyberspectrum.de/r" - } - ], + "minimum-stability": "dev", "autoload": { "psr-4": { "MetaModels\\AttributeFileBundle\\": "src" diff --git a/src/Resources/contao/dca/tl_metamodel_attribute.php b/src/Resources/contao/dca/tl_metamodel_attribute.php index ff8b114..32a4fa3 100644 --- a/src/Resources/contao/dca/tl_metamodel_attribute.php +++ b/src/Resources/contao/dca/tl_metamodel_attribute.php @@ -3,7 +3,7 @@ /** * This file is part of MetaModels/attribute_file. * - * (c) 2012-2021 The MetaModels team. + * (c) 2012-2024 The MetaModels team. * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -17,7 +17,7 @@ * @author David Molineus * @author Sven Baumann * @author Ingolf Steinhardt - * @copyright 2012-2021 The MetaModels team. + * @copyright 2012-2024 The MetaModels team. * @license https://github.com/MetaModels/attribute_file/blob/master/LICENSE LGPL-3.0-or-later * @filesource */ @@ -33,39 +33,48 @@ ]; $GLOBALS['TL_DCA']['tl_metamodel_attribute']['fields']['file_customFiletree'] = [ - 'label' => &$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_customFiletree'], - 'inputType' => 'checkbox', - 'sql' => 'char(1) NOT NULL default \'\'', - 'eval' => ['submitOnChange' => true, 'tl_class' => 'w50'] + 'label' => 'file_customFiletree.label', + 'description' => 'file_customFiletree.description', + 'inputType' => 'checkbox', + 'sql' => 'char(1) NOT NULL default \'\'', + 'eval' => ['submitOnChange' => true, 'tl_class' => 'w50'] ]; $GLOBALS['TL_DCA']['tl_metamodel_attribute']['fields']['file_multiple'] = [ - 'label' => &$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_multiple'], - 'inputType' => 'checkbox', - 'sql' => 'char(1) NOT NULL default \'\'', - 'eval' => ['tl_class' => 'w50'] + 'label' => 'file_multiple.label', + 'description' => 'file_multiple.description', + 'inputType' => 'checkbox', + 'sql' => 'char(1) NOT NULL default \'\'', + 'eval' => ['tl_class' => 'w50'] ]; $GLOBALS['TL_DCA']['tl_metamodel_attribute']['fields']['file_uploadFolder'] = [ - 'label' => &$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_uploadFolder'], - 'exclude' => true, - 'inputType' => 'fileTree', - 'sql' => 'blob NULL', - 'eval' => ['fieldType' => 'radio', 'tl_class' => 'clr'] + 'label' => 'file_uploadFolder.label', + 'description' => 'file_uploadFolder.description', + 'exclude' => true, + 'inputType' => 'fileTree', + 'sql' => 'blob NULL', + 'eval' => ['fieldType' => 'radio', 'tl_class' => 'clr'] ]; $GLOBALS['TL_DCA']['tl_metamodel_attribute']['fields']['file_validFileTypes'] = [ - 'label' => &$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_validFileTypes'], - 'inputType' => 'text', - 'sql' => 'varchar(255) NOT NULL default \'\'', - 'eval' => ['maxlength' => 255, 'tl_class' => 'w50'] + 'label' => 'file_validFileTypes.label', + 'description' => 'file_validFileTypes.description', + 'inputType' => 'text', + 'sql' => 'varchar(255) NOT NULL default \'\'', + 'eval' => ['maxlength' => 255, 'tl_class' => 'w50'] ]; $GLOBALS['TL_DCA']['tl_metamodel_attribute']['fields']['file_filesOnly'] = [ - 'label' => &$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_filesOnly'], - 'inputType' => 'select', - 'options' => ['', '1', '2'], - 'reference' => &$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_filesOnly_options'], - 'eval' => ['tl_class' => 'w50'], - 'sql' => ['type' => 'string', 'length' => 1, 'fixed' => true, 'default' => ''] + 'label' => 'file_filesOnly.label', + 'description' => 'file_filesOnly.description', + 'inputType' => 'select', + 'options' => ['', '1', '2'], + 'reference' => [ + '' => 'file_filesOnly_options.allow_both', + '1' => 'file_filesOnly_options.allow_files', + '2' => 'file_filesOnly_options.allow_folder', + ], + 'eval' => ['tl_class' => 'w50'], + 'sql' => ['type' => 'string', 'length' => 1, 'fixed' => true, 'default' => ''] ]; diff --git a/src/Resources/contao/dca/tl_metamodel_dcasetting.php b/src/Resources/contao/dca/tl_metamodel_dcasetting.php index 7c8079a..576a383 100644 --- a/src/Resources/contao/dca/tl_metamodel_dcasetting.php +++ b/src/Resources/contao/dca/tl_metamodel_dcasetting.php @@ -3,7 +3,7 @@ /** * This file is part of MetaModels/attribute_file. * - * (c) 2012-2023 The MetaModels team. + * (c) 2012-2024 The MetaModels team. * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -16,7 +16,7 @@ * @author Andreas Isaak * @author Sven Baumann * @author Ingolf Steinhardt - * @copyright 2012-2023 The MetaModels team. + * @copyright 2012-2024 The MetaModels team. * @license https://github.com/MetaModels/attribute_file/blob/master/LICENSE LGPL-3.0-or-later * @filesource */ @@ -36,16 +36,25 @@ ]; $GLOBALS['TL_DCA']['tl_metamodel_dcasetting']['fields']['file_widgetMode'] = [ - 'label' => &$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['file_widgetMode'], - 'exclude' => true, - 'inputType' => 'radio', - 'default' => 'normal', - 'options' => ['normal'], - 'reference' => &$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['file_widgetModes'], - 'eval' => [ + 'label' => 'file_widgetMode.label', + 'description' => 'file_widgetMode.description', + 'exclude' => true, + 'inputType' => 'radio', + 'default' => 'normal', + 'options' => ['normal'], + 'reference' => [ + 'normal' => 'file_widgetModes.normal', + 'downloads' => 'file_widgetModes.downloads', + 'gallery' => 'file_widgetModes.gallery', + 'fe_single_upload' => 'file_widgetModes.fe_single_upload', + 'fe_single_upload_preview' => 'file_widgetModes.fe_single_upload_preview', + 'fe_multiple_upload' => 'file_widgetModes.fe_multiple_upload', + 'fe_multiple_upload_preview' => 'file_widgetModes.fe_multiple_upload_preview', + ], + 'eval' => [ 'tl_class' => 'clr w50' ], - 'sql' => 'char(32) NOT NULL default \'normal\'' + 'sql' => 'char(32) NOT NULL default \'normal\'' ]; // Load configuration for the frontend editing. @@ -96,124 +105,142 @@ ); $GLOBALS['TL_DCA']['tl_metamodel_dcasetting']['fields']['fe_widget_file_useHomeDir'] = [ - 'label' => &$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['fe_widget_file_useHomeDir'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'eval' => [ + 'label' => 'fe_widget_file_useHomeDir.label', + 'description' => 'fe_widget_file_useHomeDir.description', + 'exclude' => true, + 'inputType' => 'checkbox', + 'eval' => [ 'tl_class' => 'w50 cbx m12', ], - 'sql' => "char(1) NOT NULL default ''", + 'sql' => "char(1) NOT NULL default ''", ]; $GLOBALS['TL_DCA']['tl_metamodel_dcasetting']['fields']['fe_widget_file_uploadFolder'] = [ - 'label' => &$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['fe_widget_file_uploadFolder'], - 'exclude' => true, - 'inputType' => 'fileTree', - 'eval' => [ + 'label' => 'fe_widget_file_uploadFolder.label', + 'description' => 'fe_widget_file_uploadFolder.description', + 'exclude' => true, + 'inputType' => 'fileTree', + 'eval' => [ 'fieldType' => 'radio', 'tl_class' => 'w50' ], - 'sql' => "binary(16) NULL" + 'sql' => "binary(16) NULL" ]; $GLOBALS['TL_DCA']['tl_metamodel_dcasetting']['fields']['fe_widget_file_doNotOverwrite'] = [ - 'label' => &$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['fe_widget_file_doNotOverwrite'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'eval' => [ + 'label' => 'fe_widget_file_doNotOverwrite.label', + 'description' => 'fe_widget_file_doNotOverwrite.description', + 'exclude' => true, + 'inputType' => 'checkbox', + 'eval' => [ 'tl_class' => 'w50 cbx m12 clr', ], - 'sql' => "char(1) NOT NULL default ''", + 'sql' => "char(1) NOT NULL default ''", ]; $GLOBALS['TL_DCA']['tl_metamodel_dcasetting']['fields']['fe_widget_file_deselect'] = [ - 'label' => &$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['fe_widget_file_deselect'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'eval' => [ + 'label' => 'fe_widget_file_deselect.label', + 'description' => 'fe_widget_file_deselect.description', + 'exclude' => true, + 'inputType' => 'checkbox', + 'eval' => [ 'tl_class' => 'w50 clr cbx m12', ], - 'sql' => "char(1) NOT NULL default ''", + 'sql' => "char(1) NOT NULL default ''", ]; $GLOBALS['TL_DCA']['tl_metamodel_dcasetting']['fields']['fe_widget_file_delete'] = [ - 'label' => &$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['fe_widget_file_delete'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'eval' => [ + 'label' => 'fe_widget_file_delete.label', + 'description' => 'fe_widget_file_delete.description', + 'exclude' => true, + 'inputType' => 'checkbox', + 'eval' => [ 'tl_class' => 'w50 cbx m12', ], - 'sql' => "char(1) NOT NULL default ''", + 'sql' => "char(1) NOT NULL default ''", ]; $GLOBALS['TL_DCA']['tl_metamodel_dcasetting']['fields']['fe_widget_file_extend_folder'] = [ - 'label' => &$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['fe_widget_file_extend_folder'], - 'inputType' => 'text', - 'eval' => [ + 'label' => 'fe_widget_file_extend_folder.label', + 'description' => 'fe_widget_file_extend_folder.description', + 'inputType' => 'text', + 'eval' => [ 'tl_class' => 'w50 clr' ], - 'sql' => "longtext" + 'sql' => "longtext" ]; $GLOBALS['TL_DCA']['tl_metamodel_dcasetting']['fields']['fe_widget_file_normalize_extend_folder'] = [ - 'label' => &$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['fe_widget_file_normalize_extend_folder'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'eval' => [ + 'label' => 'fe_widget_file_normalize_extend_folder.label', + 'description' => 'fe_widget_file_normalize_extend_folder.description', + 'exclude' => true, + 'inputType' => 'checkbox', + 'eval' => [ 'tl_class' => 'w50 cbx m12', ], - 'sql' => "char(1) NOT NULL default ''", + 'sql' => "char(1) NOT NULL default ''", ]; $GLOBALS['TL_DCA']['tl_metamodel_dcasetting']['fields']['fe_widget_file_normalize_filename'] = [ - 'label' => &$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['fe_widget_file_normalize_filename'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'eval' => [ + 'label' => 'fe_widget_file_normalize_filename.label', + 'description' => 'fe_widget_file_normalize_filename.description', + 'exclude' => true, + 'inputType' => 'checkbox', + 'eval' => [ 'tl_class' => 'w50 cbx m12', ], - 'sql' => "char(1) NOT NULL default ''", + 'sql' => "char(1) NOT NULL default ''", ]; $GLOBALS['TL_DCA']['tl_metamodel_dcasetting']['fields']['fe_widget_file_prefix_filename'] = [ - 'label' => &$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['fe_widget_file_prefix_filename'], - 'inputType' => 'text', - 'eval' => [ + 'label' => 'fe_widget_file_prefix_filename.label', + 'description' => 'fe_widget_file_prefix_filename.description', + 'inputType' => 'text', + 'eval' => [ 'tl_class' => 'w50 clr' ], - 'sql' => "longtext" + 'sql' => "longtext" ]; $GLOBALS['TL_DCA']['tl_metamodel_dcasetting']['fields']['fe_widget_file_postfix_filename'] = [ - 'label' => &$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['fe_widget_file_postfix_filename'], - 'inputType' => 'text', - 'eval' => [ + 'label' => 'fe_widget_file_postfix_filename.label', + 'description' => 'fe_widget_file_postfix_filename.description', + 'inputType' => 'text', + 'eval' => [ 'tl_class' => 'w50' ], - 'sql' => "longtext" + 'sql' => "longtext" ]; $GLOBALS['TL_DCA']['tl_metamodel_dcasetting']['fields']['fe_widget_file_sortBy'] = [ - 'label' => &$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['fe_widget_file_sortBy'], - 'exclude' => true, - 'inputType' => 'select', - 'options' => ['name_asc', 'name_desc', 'date_asc', 'date_desc', 'random'], - 'reference' => &$GLOBALS['TL_LANG']['tl_metamodel_dcasetting'], - 'sql' => 'varchar(32) NOT NULL default \'\'', - 'eval' => [ + 'label' => 'fe_widget_file_sortBy.label', + 'description' => 'fe_widget_file_sortBy.description', + 'exclude' => true, + 'inputType' => 'select', + 'options' => ['name_asc', 'name_desc', 'date_asc', 'date_desc', 'random'], + 'reference' => [ + 'name_asc' => 'fe_widget_file_sortBy.name_asc', + 'name_desc' => 'fe_widget_file_sortBy.name_desc', + 'date_asc' => 'fe_widget_file_sortBy.date_asc', + 'date_desc' => 'fe_widget_file_sortBy.date_desc', + 'random' => 'fe_widget_file_sortBy.random', + ], + 'sql' => 'varchar(32) NOT NULL default \'\'', + 'eval' => [ 'tl_class' => 'w50', 'chosen' => true ] ]; $GLOBALS['TL_DCA']['tl_metamodel_dcasetting']['fields']['fe_widget_file_imageSize'] = [ - 'label' => &$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['fe_widget_file_imageSize'], - 'exclude' => true, - 'inputType' => 'imageSize', - 'options' => $GLOBALS['TL_CROP'], - 'reference' => &$GLOBALS['TL_LANG']['MSC'], - 'sql' => 'varchar(255) NOT NULL default \'\'', - 'eval' => [ + 'label' => 'fe_widget_file_imageSize.label', + 'description' => 'fe_widget_file_imageSize.description', + 'exclude' => true, + 'inputType' => 'imageSize', + 'options' => $GLOBALS['TL_CROP'], + 'reference' => &$GLOBALS['TL_LANG']['MSC'], + 'sql' => 'varchar(255) NOT NULL default \'\'', + 'eval' => [ 'rgxp' => 'digit', 'includeBlankOption' => true, 'nospace' => true, diff --git a/src/Resources/contao/dca/tl_metamodel_rendersetting.php b/src/Resources/contao/dca/tl_metamodel_rendersetting.php index 1919802..b947811 100644 --- a/src/Resources/contao/dca/tl_metamodel_rendersetting.php +++ b/src/Resources/contao/dca/tl_metamodel_rendersetting.php @@ -3,7 +3,7 @@ /** * This file is part of MetaModels/attribute_file. * - * (c) 2012-2022 The MetaModels team. + * (c) 2012-2024 The MetaModels team. * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -16,7 +16,7 @@ * @author Sven Baumann * @author Ingolf Steinhardt * @author Stefan Heimes - * @copyright 2012-2022 The MetaModels team. + * @copyright 2012-2024 The MetaModels team. * @license https://github.com/MetaModels/attribute_file/blob/master/LICENSE LGPL-3.0-or-later * @filesource */ @@ -39,55 +39,67 @@ ]; $GLOBALS['TL_DCA']['tl_metamodel_rendersetting']['fields']['file_sortBy'] = [ - 'label' => &$GLOBALS['TL_LANG']['tl_metamodel_rendersetting']['file_sortBy'], - 'exclude' => true, - 'inputType' => 'select', - 'options' => ['name_asc', 'name_desc', 'date_asc', 'date_desc', 'manual', 'random'], - 'reference' => &$GLOBALS['TL_LANG']['tl_metamodel_rendersetting'], - 'sql' => 'varchar(32) NOT NULL default \'\'', - 'eval' => [ + 'label' => 'file_sortBy.label', + 'description' => 'file_sortBy.description', + 'exclude' => true, + 'inputType' => 'select', + 'options' => ['name_asc', 'name_desc', 'date_asc', 'date_desc', 'manual', 'random'], + 'reference' => [ + 'name_asc' => 'file_sortBy.name_asc', + 'name_desc' => 'file_sortBy.name_desc', + 'date_asc' => 'file_sortBy.date_asc', + 'date_desc' => 'file_sortBy.date_desc', + 'random' => 'file_sortBy.random', + 'manual' => 'file_sortBy.manual', +], + 'sql' => 'varchar(32) NOT NULL default \'\'', + 'eval' => [ 'tl_class' => 'w50', 'chosen' => true ] ]; $GLOBALS['TL_DCA']['tl_metamodel_rendersetting']['fields']['file_showLink'] = [ - 'label' => &$GLOBALS['TL_LANG']['tl_metamodel_rendersetting']['file_showLink'], - 'inputType' => 'checkbox', - 'sql' => 'char(1) NOT NULL default \'\'', - 'eval' => [ + 'label' => 'file_showLink.label', + 'description' => 'file_showLink.description', + 'inputType' => 'checkbox', + 'sql' => 'char(1) NOT NULL default \'\'', + 'eval' => [ 'submitOnChange' => true, 'tl_class' => 'clr w50 cbx m12' ] ]; $GLOBALS['TL_DCA']['tl_metamodel_rendersetting']['fields']['file_protectedDownload'] = [ - 'label' => &$GLOBALS['TL_LANG']['tl_metamodel_rendersetting']['file_protectedDownload'], - 'inputType' => 'checkbox', - 'sql' => 'char(1) NOT NULL default \'\'', - 'eval' => [ + 'label' => 'file_protectedDownload.label', + 'description' => 'file_protectedDownload.description', + 'inputType' => 'checkbox', + 'sql' => 'char(1) NOT NULL default \'\'', + 'eval' => [ 'tl_class' => 'w50 cbx m12' ] ]; $GLOBALS['TL_DCA']['tl_metamodel_rendersetting']['fields']['file_showImage'] = [ - 'label' => &$GLOBALS['TL_LANG']['tl_metamodel_rendersetting']['file_showImage'], - 'inputType' => 'checkbox', - 'sql' => 'char(1) NOT NULL default \'\'', - 'eval' => [ + 'label' => 'file_showImage.label', + 'description' => 'file_showImage.description', + 'inputType' => 'checkbox', + 'sql' => 'char(1) NOT NULL default \'\'', + 'eval' => [ 'submitOnChange' => true, 'tl_class' => 'clr w50 cbx m12' ] ]; $GLOBALS['TL_DCA']['tl_metamodel_rendersetting']['fields']['file_imageSize'] = [ - 'label' => &$GLOBALS['TL_LANG']['tl_metamodel_rendersetting']['file_imageSize'], - 'exclude' => true, - 'inputType' => 'imageSize', - 'options' => $GLOBALS['TL_CROP'], - 'reference' => &$GLOBALS['TL_LANG']['MSC'], - 'sql' => 'varchar(255) NOT NULL default \'\'', - 'eval' => [ + 'label' => 'file_imageSize.label', + 'description' => 'file_imageSize.description', + 'exclude' => true, + 'inputType' => 'imageSize', + 'options' => $GLOBALS['TL_CROP'], + 'reference' => &$GLOBALS['TL_LANG']['MSC'], + 'sql' => 'varchar(255) NOT NULL default \'\'', + 'eval' => [ 'rgxp' => 'digit', 'includeBlankOption' => true, 'nospace' => true, @@ -97,11 +109,12 @@ ]; $GLOBALS['TL_DCA']['tl_metamodel_rendersetting']['fields']['file_placeholder'] = [ - 'label' => &$GLOBALS['TL_LANG']['tl_metamodel_rendersetting']['file_placeholder'], - 'exclude' => true, - 'inputType' => 'fileTree', - 'sql' => 'blob NULL', - 'eval' => [ + 'label' => 'file_placeholder.label', + 'description' => 'file_placeholder.description', + 'exclude' => true, + 'inputType' => 'fileTree', + 'sql' => 'blob NULL', + 'eval' => [ 'fieldType' => 'radio', 'files' => true, 'filesOnly' => true, diff --git a/src/Resources/contao/languages/en/default.php b/src/Resources/contao/languages/en/default.php deleted file mode 100644 index bb71d01..0000000 --- a/src/Resources/contao/languages/en/default.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @copyright 2012-2019 The MetaModels team. - * @license https://github.com/MetaModels/attribute_file/blob/master/LICENSE LGPL-3.0-or-later - * @filesource - */ - -$GLOBALS['TL_LANG']['ERR']['both_input_not_match'] = - 'The %s does not match the %s . Please check both entries.'; - diff --git a/src/Resources/contao/languages/en/tl_metamodel_attribute.php b/src/Resources/contao/languages/en/tl_metamodel_attribute.php deleted file mode 100644 index 9f70425..0000000 --- a/src/Resources/contao/languages/en/tl_metamodel_attribute.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @author David Molineus - * @author Sven Baumann - * @author Ingolf Steinhardt - * @copyright 2012-2021 The MetaModels team. - * @license https://github.com/MetaModels/attribute_file/blob/master/LICENSE LGPL-3.0-or-later - * @filesource - */ - -// Fields. -$GLOBALS['TL_LANG']['tl_metamodel_attribute']['typeOptions']['file'] = 'File'; -$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_customFiletree'][0] = 'Customize the file tree'; -$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_customFiletree'][1] = - 'Allows you to set custom options for the filetree.'; -$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_uploadFolder'][0] = 'Set file root folder'; -$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_uploadFolder'][1] = - 'Selects the root point from which the user will select this file field.'; -$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_validFileTypes'][0] = 'Valid file types'; -$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_validFileTypes'][1] = - 'To overwrite the contao standard file types, please enter a comma separated list of extensions of valid file ' . - 'types for this field.'; -$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_filesOnly'][0] = 'Allowed types for selection'; -$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_filesOnly'][1] = - 'Select a restriction on files or folders - default is no restriction on files or folders.'; -$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_multiple'][0] = 'Multiple selection'; -$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_multiple'][1] = - 'If selected, user will be able to select more than one item.'; - -$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_filesOnly_options'][''] = 'Allow files and folders'; -$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_filesOnly_options']['1'] = 'Allow files only'; -$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_filesOnly_options']['2'] = 'Allow folders only'; diff --git a/src/Resources/contao/languages/en/tl_metamodel_dcasetting.php b/src/Resources/contao/languages/en/tl_metamodel_dcasetting.php deleted file mode 100644 index e947598..0000000 --- a/src/Resources/contao/languages/en/tl_metamodel_dcasetting.php +++ /dev/null @@ -1,90 +0,0 @@ - - * @author Sven Baumann - * @author Ingolf Steinhardt - * @copyright 2012-2023 The MetaModels team. - * @license https://github.com/MetaModels/attribute_file/blob/master/LICENSE LGPL-3.0 - * @filesource - */ - -$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['file_widgetMode'][0] = 'Widget mode'; -$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['file_widgetMode'][1] = - 'With the mode the display type can be selected.'; - -$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['file_widgetModes']['normal'] = - 'Show files as list.'; -$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['file_widgetModes']['downloads'] = - 'Show files as sortable file list e.g. for downloads.'; -$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['file_widgetModes']['gallery'] = - 'Show files as sortable images e.g. for gallery.'; - -$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['file_widgetModes']['fe_single_upload'] = - 'Single file upload [only for frontend editing] - Deprecated!'; -$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['file_widgetModes']['fe_single_upload_preview'] = - 'Single file upload with show thumbnail [only for frontend editing] - Deprecated!'; -$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['file_widgetModes']['fe_multiple_upload'] = - 'Multiple file upload [only for frontend editing]'; -$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['file_widgetModes']['fe_multiple_upload_preview'] = - 'Multiple file upload with show thumbnail [only for frontend editing]'; - -$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['fe_widget_file_doNotOverwrite'][0] = 'Preserve existing files'; -$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['fe_widget_file_doNotOverwrite'][1] = - 'Add a numeric suffix to the new file, if the file name already exists.'; -$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['fe_widget_file_useHomeDir'][0] = 'Use home directory'; -$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['fe_widget_file_useHomeDir'][1] = - 'If this option is active, store the file in the home directory if there is an authenticated user. ' . - 'If the target folder configured too and the user is authenticated, so this folder is the base upload folder.'; -$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['fe_widget_file_uploadFolder'][0] = 'Target folder'; -$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['fe_widget_file_uploadFolder'][1] = - 'Please select the target folder from the files directory. ' . - 'If the home dir configured too and is not authenticated a user, so this folder is the base folder.'; -$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['fe_widget_file_extend_folder'][0] = 'Extend folder'; -$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['fe_widget_file_extend_folder'][1] = - 'Here you can extend the base upload folder path. The Contao insert tags are supported to extend the path.'; -$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['fe_widget_file_deselect'][0] = 'Deselect file'; -$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['fe_widget_file_deselect'][1] = - 'If this option deselect file is active, then that file entry is remove from this model.'; -$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['fe_widget_file_delete'][0] = 'Delete file'; -$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['fe_widget_file_delete'][1] = - 'If this option delete file is active, then that file entry is remove from this model and from the file directory.'; -$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['fe_widget_file_normalize_extend_folder'][0] = 'Normalize extend folder'; -$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['fe_widget_file_normalize_extend_folder'][1] = - 'Normalize the extend folder with an alias generator from the string util.'; -$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['fe_widget_file_normalize_filename'][0] = 'Normalize filename'; -$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['fe_widget_file_normalize_filename'][1] = - 'Normalize the filename with an alias generator from the string util.'; -$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['fe_widget_file_prefix_filename'][0] = 'Prefix filename'; -$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['fe_widget_file_prefix_filename'][1] = - 'Here you can prefix the filename. The Contao insert tags are supported to prefix the filename.'; -$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['fe_widget_file_postfix_filename'][0] = 'Postfix filename'; -$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['fe_widget_file_postfix_filename'][1] = - 'Here you can postfix the filename. The Contao insert tags are supported to postfix the filename.'; -$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['fe_widget_file_imageSize'][0] = - 'Thumbnail width and height'; -$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['fe_widget_file_imageSize'][1] = - 'Please enter either the image width, the image height or both measures to resize the image. If you leave both ' . - 'fields blank, the original image size will be displayed.'; -$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['fe_widget_file_sortBy'][0] = 'Order by'; -$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['fe_widget_file_sortBy'][1] = - 'Please choose the sort order.'; - -$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['upload_settings_legend'] = 'File upload settings'; - -$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['name_asc'] = 'File name (ascending)'; -$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['name_desc'] = 'File name (descending)'; -$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['date_asc'] = 'Date (ascending)'; -$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['date_desc'] = 'Date (descending)'; -$GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['random'] = 'Random order'; diff --git a/src/Resources/contao/languages/en/tl_metamodel_rendersetting.php b/src/Resources/contao/languages/en/tl_metamodel_rendersetting.php deleted file mode 100644 index 53ce8d1..0000000 --- a/src/Resources/contao/languages/en/tl_metamodel_rendersetting.php +++ /dev/null @@ -1,48 +0,0 @@ - - * @author Sven Baumann - * @author Ingolf Steinhardt - * @copyright 2012-2022 The MetaModels team. - * @license https://github.com/MetaModels/attribute_file/blob/master/LICENSE LGPL-3.0-or-later - * @filesource - */ - -$GLOBALS['TL_LANG']['tl_metamodel_rendersetting']['file_showImage'][0] = 'Enable as image field with thumbnail'; -$GLOBALS['TL_LANG']['tl_metamodel_rendersetting']['file_showImage'][1] = - 'If selected, a thumbnail will be created for image files.'; -$GLOBALS['TL_LANG']['tl_metamodel_rendersetting']['file_sortBy'][0] = 'Order by'; -$GLOBALS['TL_LANG']['tl_metamodel_rendersetting']['file_sortBy'][1] = 'Please choose the sort order.'; -$GLOBALS['TL_LANG']['tl_metamodel_rendersetting']['file_showLink'][0] = - 'Create link as file download or image lightbox'; -$GLOBALS['TL_LANG']['tl_metamodel_rendersetting']['file_showLink'][1] = - 'Wraps the item in a link that will show the fullscreen image or download the file.'; -$GLOBALS['TL_LANG']['tl_metamodel_rendersetting']['file_imageSize'][0] = 'Image width and height'; -$GLOBALS['TL_LANG']['tl_metamodel_rendersetting']['file_imageSize'][1] = - 'Please enter either the image width, the image height or both measures to resize the image. If you leave both ' . - 'fields blank, the original image size will be displayed.'; -$GLOBALS['TL_LANG']['tl_metamodel_rendersetting']['file_placeholder'][0] = 'Image placeholder'; -$GLOBALS['TL_LANG']['tl_metamodel_rendersetting']['file_placeholder'][1] = - 'Select an image as a placeholder if no image is selected.'; -$GLOBALS['TL_LANG']['tl_metamodel_rendersetting']['file_protectedDownload'][0] = 'Protected download'; -$GLOBALS['TL_LANG']['tl_metamodel_rendersetting']['file_protectedDownload'][1] = - 'If this option is selected, the URL is only temporarily valid.'; - -$GLOBALS['TL_LANG']['tl_metamodel_rendersetting']['name_asc'] = 'File name (ascending)'; -$GLOBALS['TL_LANG']['tl_metamodel_rendersetting']['name_desc'] = 'File name (descending)'; -$GLOBALS['TL_LANG']['tl_metamodel_rendersetting']['date_asc'] = 'Date (ascending)'; -$GLOBALS['TL_LANG']['tl_metamodel_rendersetting']['date_desc'] = 'Date (descending)'; -$GLOBALS['TL_LANG']['tl_metamodel_rendersetting']['random'] = 'Random order'; -$GLOBALS['TL_LANG']['tl_metamodel_rendersetting']['manual'] = 'Manual sorting'; diff --git a/src/Resources/translations/tl_metamodel_attribute.en.xlf b/src/Resources/translations/tl_metamodel_attribute.en.xlf new file mode 100644 index 0000000..539adb2 --- /dev/null +++ b/src/Resources/translations/tl_metamodel_attribute.en.xlf @@ -0,0 +1,49 @@ + + + + + + File + + + Customize the file tree + + + Allows you to set custom options for the filetree. + + + Set file root folder + + + Selects the root point from which the user will select this file field. + + + Valid file types + + + To overwrite the contao standard file types, please enter a comma separated list of extensions of valid file types for this field. + + + Allowed types for selection + + + Select a restriction on files or folders - default is no restriction on files or folders. + + + Multiple selection + + + If selected, user will be able to select more than one item. + + + Allow files and folders + + + Allow files only + + + Allow folders only + + + + diff --git a/src/Resources/translations/tl_metamodel_dcasetting.en.xlf b/src/Resources/translations/tl_metamodel_dcasetting.en.xlf new file mode 100644 index 0000000..28a7d54 --- /dev/null +++ b/src/Resources/translations/tl_metamodel_dcasetting.en.xlf @@ -0,0 +1,124 @@ + + + + + + File upload settings + + + Widget mode + + + With the mode the display type can be selected. + + + Preserve existing files + + + Add a numeric suffix to the new file, if the file name already exists. + + + Use home directory + + + If this option is active, store the file in the home directory if there is an authenticated user. If the target folder configured too and the user is authenticated, so this folder is the base upload folder. + + + Target folder + + + Please select the target folder from the files directory. If the home dir configured too and is not authenticated a user, so this folder is the base folder. + + + Extend folder + + + Here you can extend the base upload folder path. The Contao insert tags are supported to extend the path. + + + Deselect file + + + If this option deselect file is active, then that file entry is remove from this model. + + + Delete file + + + If this option delete file is active, then that file entry is remove from this model and from the file directory. + + + Normalize extend folder + + + Normalize the extend folder with an alias generator from the string util. + + + Normalize filename + + + Normalize the filename with an alias generator from the string util. + + + Prefix filename + + + Here you can prefix the filename. The Contao insert tags are supported to prefix the filename. + + + Postfix filename + + + Here you can postfix the filename. The Contao insert tags are supported to postfix the filename. + + + Thumbnail width and height + + + Please enter either the image width, the image height or both measures to resize the image. If you leave both fields blank, the original image size will be displayed. + + + Order by + + + Please choose the sort order. + + + Show files as list. + + + Show files as sortable file list e.g. for downloads. + + + Show files as sortable images e.g. for gallery. + + + Single file upload [only for frontend editing] - Deprecated! + + + Single file upload with show thumbnail [only for frontend editing] - Deprecated! + + + Multiple file upload [only for frontend editing] + + + Multiple file upload with show thumbnail [only for frontend editing] + + + File name (ascending) + + + File name (descending) + + + Date (ascending) + + + Date (descending) + + + Random order + + + + diff --git a/src/Resources/translations/tl_metamodel_rendersetting.en.xlf b/src/Resources/translations/tl_metamodel_rendersetting.en.xlf new file mode 100644 index 0000000..93ad4b4 --- /dev/null +++ b/src/Resources/translations/tl_metamodel_rendersetting.en.xlf @@ -0,0 +1,61 @@ + + + + + + Enable as image field with thumbnail + + + If selected, a thumbnail will be created for image files. + + + Order by + + + Please choose the sort order. + + + Create link as file download or image lightbox + + + Wraps the item in a link that will show the fullscreen image or download the file. + + + Image width and height + + + Please enter either the image width, the image height or both measures to resize the image. If you leave both fields blank, the original image size will be displayed. + + + Image placeholder + + + Select an image as a placeholder if no image is selected. + + + Protected download + + + If this option is selected, the URL is only temporarily valid. + + + File name (ascending) + + + File name (descending) + + + Date (ascending) + + + Date (descending) + + + Random order + + + Manual sorting + + + + From 7a81509b70f5d0f450d043083cb436aa090e798d Mon Sep 17 00:00:00 2001 From: Mini Model Date: Sun, 21 Jul 2024 16:17:58 +0200 Subject: [PATCH 35/56] Updated translations from transifex. --- .../tl_metamodel_attribute.de.xlf | 62 +++++++ .../tl_metamodel_dcasetting.de.xlf | 162 ++++++++++++++++++ .../tl_metamodel_rendersetting.de.xlf | 78 +++++++++ 3 files changed, 302 insertions(+) create mode 100644 src/Resources/translations/tl_metamodel_attribute.de.xlf create mode 100644 src/Resources/translations/tl_metamodel_dcasetting.de.xlf create mode 100644 src/Resources/translations/tl_metamodel_rendersetting.de.xlf diff --git a/src/Resources/translations/tl_metamodel_attribute.de.xlf b/src/Resources/translations/tl_metamodel_attribute.de.xlf new file mode 100644 index 0000000..4f0a741 --- /dev/null +++ b/src/Resources/translations/tl_metamodel_attribute.de.xlf @@ -0,0 +1,62 @@ + + + + + File + Datei + + + Customize the file tree + Passen Sie den Dateibaum an + + + Allows you to set custom options for the filetree. + Erlaubt Ihnen, individuelle Optionen für den Dateibaum zu setzen. + + + Set file root folder + Wurzelordner (Root) angeben + + + Selects the root point from which the user will select this file field. + Wählen Sie den Punkt im Dateibaum, von dem aus Benutzer Daten hinzufügen können. + + + Valid file types + Gültige Dateitypen + + + To overwrite the contao standard file types, please enter a comma separated list of extensions of valid file types for this field. + Geben Sie hier eine kommagetrennte Liste gültiger Dateiendungen ein, um die Standard-Dateitypen von Contao zu überschreiben. + + + Allowed types for selection + Erlaubte Dateitypen + + + Select a restriction on files or folders - default is no restriction on files or folders. + Wählen Sie eine Einschränkung für Dateien oder Ordner aus - Standard ist keine Einschränkung für Dateien oder Ordner. + + + Multiple selection + Mehrfachauswahl + + + If selected, user will be able to select more than one item. + Wenn aktiviert, können mehrere Dateien ausgewählt werden. + + + Allow files and folders + Erlauben von Dateien und Ordnern + + + Allow files only + Nur Dateien erlauben + + + Allow folders only + Nur Ordner erlauben + + + + \ No newline at end of file diff --git a/src/Resources/translations/tl_metamodel_dcasetting.de.xlf b/src/Resources/translations/tl_metamodel_dcasetting.de.xlf new file mode 100644 index 0000000..6620bca --- /dev/null +++ b/src/Resources/translations/tl_metamodel_dcasetting.de.xlf @@ -0,0 +1,162 @@ + + + + + File upload settings + Einstellungen zum Upload von Dateien + + + Widget mode + Widget-Modus + + + With the mode the display type can be selected. + Mit dem Modus kann die Anzeigeart ausgewählt werden. + + + Preserve existing files + Vorhandene Dateien beibehalten + + + Add a numeric suffix to the new file, if the file name already exists. + Fügen Sie der neuen Datei ein numerisches Suffix hinzu, wenn der Dateiname bereits existiert. + + + Use home directory + Home-Verzeichnis verwenden + + + If this option is active, store the file in the home directory if there is an authenticated user. If the target folder configured too and the user is authenticated, so this folder is the base upload folder. + Wenn diese Option aktiv ist, wird die Datei im Home-Verzeichnis gespeichert, wenn es einen authentifizierten Benutzer gibt. Ist der Zielordner zu konfiguriert und der Benutzer ist authentifiziert, so ist dieser Ordner der Basis-Upload-Ordner. + + + Target folder + Zielordner + + + Please select the target folder from the files directory. If the home dir configured too and is not authenticated a user, so this folder is the base folder. + Bitte wählen Sie den Zielordner aus dem Dateiverzeichnis aus. Ist das Home-Verzeichnis konfiguriert und ein Benutzer nicht authentifiziert, so ist dieser Ordner der Basisordner. + + + Extend folder + Ordner erweitern + + + Here you can extend the base upload folder path. The Contao insert tags are supported to extend the path. + Hier können Sie den Basis-Upload-Ordnerpfad erweitern. Die Contao Insert-Tags werden unterstützt, um den Pfad zu erweitern. Die Insert-Tags aus der Filterregel "Eigener SQL" funktionieren auch hier. + + + Deselect file + Datei abwählen + + + If this option deselect file is active, then that file entry is remove from this model. + Wenn die Option Datei abwählen aktiviert ist, wird dieser Dateieintrag aus diesem Modell entfernt. + + + Delete file + Datei löschen + + + If this option delete file is active, then that file entry is remove from this model and from the file directory. + Ist die Option Datei löschen aktiv, so wird dieser Dateieintrag aus diesem Modell und aus dem Dateiverzeichnis entfernt. + + + Normalize extend folder + Erweiterten Ordner normalisieren + + + Normalize the extend folder with an alias generator from the string util. + Normalisieren Sie den erweiterten Ordner mit einem Alias-Generator. + + + Normalize filename + Dateinamen normalisieren + + + Normalize the filename with an alias generator from the string util. + Normalisieren Sie den Dateinamen mit einem Alias-Generator. + + + Prefix filename + Dateinamen Präfix + + + Here you can prefix the filename. The Contao insert tags are supported to prefix the filename. + Hier können Sie Zeichen den Dateinamen vorangestellt werden. Die Contao-Insert-Tags werden für das Voranstellen des Dateinamens unterstützt. + + + Postfix filename + Dateinamen Postfix + + + Here you can postfix the filename. The Contao insert tags are supported to postfix the filename. + Hier können Sie Zeichen den Dateinamen anhängen. Die Contao-Insert-Tags werden für das Voranstellen des Dateinamens unterstützt. + + + Thumbnail width and height + Breite und Höhe der Vorschaubilder + + + Please enter either the image width, the image height or both measures to resize the image. If you leave both fields blank, the original image size will be displayed. + Bitte geben Sie entweder die Bildbreite, die Bildhöhe oder beides ein, damit das Bild skaliert wird. Falls Sie beide Felder leer lassen, wird das Bild in Originalgröße ausgegeben. + + + Order by + Sortieren nach + + + Please choose the sort order. + Bitte wählen Sie die Sortierreihenfolge. + + + Show files as list. + Dateien als Liste anzeigen. + + + Show files as sortable file list e.g. for downloads. + Dateien als sortierbare Dateiliste anzeigen z.B. für Downloads. + + + Show files as sortable images e.g. for gallery. + Dateien als sortierbare Bilder anzeigen z.B. für eine Galerie. + + + Single file upload [only for frontend editing] - Deprecated! + Einzelner Datei-Upload [nur für Frontend-Bearbeitung] - Deprecated! + + + Single file upload with show thumbnail [only for frontend editing] - Deprecated! + Einzelner Datei-Upload mit Anzeige der Vorschaubilder [nur für Frontend-Bearbeitung] - Deprecated! + + + Multiple file upload [only for frontend editing] + Mehrfacher Datei-Upload [nur für Frontend-Bearbeitung] + + + Multiple file upload with show thumbnail [only for frontend editing] + Mehrfacher Datei-Upload mit Anzeige der Vorschaubilder [nur für Frontend-Bearbeitung] + + + File name (ascending) + Dateiname (aufsteigend) + + + File name (descending) + Dateiname (absteigend) + + + Date (ascending) + Datum (aufsteigend) + + + Date (descending) + Datum (absteigend) + + + Random order + Zufällige Reihenfolge + + + + \ No newline at end of file diff --git a/src/Resources/translations/tl_metamodel_rendersetting.de.xlf b/src/Resources/translations/tl_metamodel_rendersetting.de.xlf new file mode 100644 index 0000000..0c45624 --- /dev/null +++ b/src/Resources/translations/tl_metamodel_rendersetting.de.xlf @@ -0,0 +1,78 @@ + + + + + Enable as image field with thumbnail + Als Bildfeld mit Vorschaubild benutzen + + + If selected, a thumbnail will be created for image files. + Falls aktiviert, wird für das Bild ein verkleinertes Vorschaubild generiert. + + + Order by + Sortierung nach + + + Please choose the sort order. + Bitte wählen Sie die Sortierreihenfolge. + + + Create link as file download or image lightbox + Link als Download oder Lightbox erstellen + + + Wraps the item in a link that will show the fullscreen image or download the file. + Das Item wird in einen Link eingebettet, der entweder für eine Großansicht oder einen Download dienen kann. + + + Image width and height + Bildbreite und -höhe + + + Please enter either the image width, the image height or both measures to resize the image. If you leave both fields blank, the original image size will be displayed. + Bitte geben Sie entweder die Bildbreite, die Bildhöhe oder beides ein, damit das Bild skaliert wird. Falls Sie beide Felder leer lassen, wird das Bild in Originalgröße ausgegeben. + + + Image placeholder + Bild als Platzhalter + + + Select an image as a placeholder if no image is selected. + Wählen Sie ein Bild als Platzhalter, wenn kein Bild ausgewählt ist. + + + Protected download + Geschützter Download + + + If this option is selected, the URL is only temporarily valid. + Wenn diese Option ausgewählt ist, ist die URL nur vorübergehend gültig. + + + File name (ascending) + Dateiname (aufsteigend) + + + File name (descending) + Dateiname (absteigend) + + + Date (ascending) + Datum (aufsteigend) + + + Date (descending) + Datum (absteigend) + + + Random order + Zufällige Reihenfolge + + + Manual sorting + Manuelle Sortierung + + + + \ No newline at end of file From 77cf04fa380f48387d3e57578ac70cf508b3418c Mon Sep 17 00:00:00 2001 From: Cliff Parnitzky Date: Wed, 12 Jun 2024 20:25:35 +0000 Subject: [PATCH 36/56] Enable predefined dimensions for image sizes of `config.yaml` to be selectable. --- .../contao/dca/tl_metamodel_rendersetting.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Resources/contao/dca/tl_metamodel_rendersetting.php b/src/Resources/contao/dca/tl_metamodel_rendersetting.php index b947811..73a390d 100644 --- a/src/Resources/contao/dca/tl_metamodel_rendersetting.php +++ b/src/Resources/contao/dca/tl_metamodel_rendersetting.php @@ -16,6 +16,7 @@ * @author Sven Baumann * @author Ingolf Steinhardt * @author Stefan Heimes + * @author Cliff Parnitzky * @copyright 2012-2024 The MetaModels team. * @license https://github.com/MetaModels/attribute_file/blob/master/LICENSE LGPL-3.0-or-later * @filesource @@ -96,11 +97,21 @@ 'description' => 'file_imageSize.description', 'exclude' => true, 'inputType' => 'imageSize', - 'options' => $GLOBALS['TL_CROP'], + 'options_callback' => static function () + { + return System::getContainer()->get('contao.image.sizes')->getOptionsForUser(BackendUser::getInstance()); + }, 'reference' => &$GLOBALS['TL_LANG']['MSC'], 'sql' => 'varchar(255) NOT NULL default \'\'', 'eval' => [ 'rgxp' => 'digit', + 'label' => &$GLOBALS['TL_LANG']['tl_metamodel_rendersetting']['file_imageSize'], + 'exclude' => true, + 'inputType' => 'imageSize', + 'reference' => &$GLOBALS['TL_LANG']['MSC'], + 'sql' => 'varchar(255) NOT NULL default \'\'', + 'eval' => [ + 'rgxp' => 'natural', 'includeBlankOption' => true, 'nospace' => true, 'helpwizard' => true, From 69188ff92740f58518a11c472558e7d721541d91 Mon Sep 17 00:00:00 2001 From: Ingolf Steinardt Date: Wed, 24 Jul 2024 13:09:40 +0200 Subject: [PATCH 37/56] Rebase with feature/2.3.0 --- .../contao/dca/tl_metamodel_rendersetting.php | 42 ++++++++----------- 1 file changed, 17 insertions(+), 25 deletions(-) diff --git a/src/Resources/contao/dca/tl_metamodel_rendersetting.php b/src/Resources/contao/dca/tl_metamodel_rendersetting.php index 73a390d..44b43fe 100644 --- a/src/Resources/contao/dca/tl_metamodel_rendersetting.php +++ b/src/Resources/contao/dca/tl_metamodel_rendersetting.php @@ -46,13 +46,13 @@ 'inputType' => 'select', 'options' => ['name_asc', 'name_desc', 'date_asc', 'date_desc', 'manual', 'random'], 'reference' => [ - 'name_asc' => 'file_sortBy.name_asc', - 'name_desc' => 'file_sortBy.name_desc', - 'date_asc' => 'file_sortBy.date_asc', - 'date_desc' => 'file_sortBy.date_desc', - 'random' => 'file_sortBy.random', - 'manual' => 'file_sortBy.manual', -], + 'name_asc' => 'file_sortBy.name_asc', + 'name_desc' => 'file_sortBy.name_desc', + 'date_asc' => 'file_sortBy.date_asc', + 'date_desc' => 'file_sortBy.date_desc', + 'random' => 'file_sortBy.random', + 'manual' => 'file_sortBy.manual', + ], 'sql' => 'varchar(32) NOT NULL default \'\'', 'eval' => [ 'tl_class' => 'w50', @@ -93,30 +93,22 @@ ]; $GLOBALS['TL_DCA']['tl_metamodel_rendersetting']['fields']['file_imageSize'] = [ - 'label' => 'file_imageSize.label', - 'description' => 'file_imageSize.description', - 'exclude' => true, - 'inputType' => 'imageSize', - 'options_callback' => static function () - { - return System::getContainer()->get('contao.image.sizes')->getOptionsForUser(BackendUser::getInstance()); + 'label' => 'file_imageSize.label', + 'description' => 'file_imageSize.description', + 'exclude' => true, + 'inputType' => 'imageSize', + 'options_callback' => static function () { + return System::getContainer()->get('contao.image.sizes')?->getOptionsForUser(BackendUser::getInstance()); }, - 'reference' => &$GLOBALS['TL_LANG']['MSC'], - 'sql' => 'varchar(255) NOT NULL default \'\'', - 'eval' => [ - 'rgxp' => 'digit', - 'label' => &$GLOBALS['TL_LANG']['tl_metamodel_rendersetting']['file_imageSize'], - 'exclude' => true, - 'inputType' => 'imageSize', - 'reference' => &$GLOBALS['TL_LANG']['MSC'], - 'sql' => 'varchar(255) NOT NULL default \'\'', - 'eval' => [ + 'reference' => &$GLOBALS['TL_LANG']['MSC'], + 'eval' => [ 'rgxp' => 'natural', 'includeBlankOption' => true, 'nospace' => true, 'helpwizard' => true, 'tl_class' => 'clr w50' - ] + ], + 'sql' => 'varchar(255) NOT NULL default \'\'', ]; $GLOBALS['TL_DCA']['tl_metamodel_rendersetting']['fields']['file_placeholder'] = [ From 7857c2e0544a8fcd61b3daefaaac0a8b1f2554f0 Mon Sep 17 00:00:00 2001 From: Ingolf Steinardt Date: Sat, 27 Jul 2024 14:57:03 +0200 Subject: [PATCH 38/56] Add predefined sizes fee thms --- src/Resources/contao/dca/tl_metamodel_dcasetting.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Resources/contao/dca/tl_metamodel_dcasetting.php b/src/Resources/contao/dca/tl_metamodel_dcasetting.php index 576a383..929c46c 100644 --- a/src/Resources/contao/dca/tl_metamodel_dcasetting.php +++ b/src/Resources/contao/dca/tl_metamodel_dcasetting.php @@ -237,7 +237,9 @@ 'description' => 'fe_widget_file_imageSize.description', 'exclude' => true, 'inputType' => 'imageSize', - 'options' => $GLOBALS['TL_CROP'], + 'options_callback' => static function () { + return System::getContainer()->get('contao.image.sizes')?->getOptionsForUser(BackendUser::getInstance()); + }, 'reference' => &$GLOBALS['TL_LANG']['MSC'], 'sql' => 'varchar(255) NOT NULL default \'\'', 'eval' => [ From dc5333b18712f612d9d16288a9088162f9f61945 Mon Sep 17 00:00:00 2001 From: Ingolf Steinardt Date: Mon, 29 Jul 2024 20:43:28 +0200 Subject: [PATCH 39/56] Fix transaltions --- .phpcq.lock | 2 +- src/Resources/contao/dca/tl_metamodel_dcasetting.php | 1 + src/Resources/contao/dca/tl_metamodel_rendersetting.php | 3 +++ src/Resources/translations/tl_metamodel_dcasetting.en.xlf | 4 ++-- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.phpcq.lock b/.phpcq.lock index aa37692..52ac3b1 100644 --- a/.phpcq.lock +++ b/.phpcq.lock @@ -1 +1 @@ -{"plugins":{"phpunit":{"api-version":"1.0.0","version":"1.0.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpunit/phpunit-1.0.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0"},"tool":{"phpunit":"^6.0 || ^7.0 || ^8.0 || ^9.0"}},"checksum":{"type":"sha-512","value":"c73f15658e3ba62665f09492ec91c3a6a715760bfaa88473a987538439fff442540148e086e46a6aa18ce55a3ea2fbf76caaa581384cb84a38859fcc609ae7e4"},"tools":{"phpunit":{"version":"9.6.19","url":"https://phar.phpunit.de/phpunit-9.6.19.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*","ext-json":"*","ext-libxml":"*","ext-mbstring":"*","ext-xml":"*","ext-xmlwriter":"*"}},"checksum":{"type":"sha-256","value":"f30c21743f4fbea14ad8ab8f47673f9067117262dafa147fcb182e75fbc1c249"},"signature":"https://phar.phpunit.de/phpunit-9.6.19.phar.asc"}},"composerLock":null},"psalm":{"api-version":"1.0.0","version":"1.2.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/psalm/psalm-1.2.0.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0","ext-dom":"*"},"tool":{"psalm":"^3.0 || ^4.0 || ^5.0"}},"checksum":{"type":"sha-512","value":"4a550c9226d7bca582d7c10bd87cce01190c96398936b1613421640c83df62ed1c6e0d44c1b39635414ea8cf4a892a6458d27590793238add24e7cb5547e6ffd"},"tools":{"psalm":{"version":"5.25.0","url":"https://github.com/vimeo/psalm/releases/download/5.25.0/psalm.phar","requirements":{"php":{"php":"^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0","ext-SimpleXML":"*","ext-ctype":"*","ext-dom":"*","ext-json":"*","ext-libxml":"*","ext-mbstring":"*","ext-tokenizer":"*"}},"checksum":null,"signature":"https://github.com/vimeo/psalm/releases/download/5.25.0/psalm.phar.asc"}},"composerLock":null},"composer-require-checker":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/composer-require-checker/composer-require-checker-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0"},"tool":{"composer-require-checker":"^3.8 || ^4.0"}},"checksum":{"type":"sha-512","value":"d5415bddfe024c5749d894034583882aee4e5c3e1087815d9fdd81cb5e71630f631a0e35de0ff84b97fbbf738c16ece5f83bd8c00695913eb846aa6f04577dc2"},"tools":{"composer-require-checker":{"version":"4.11.0","url":"https://github.com/maglnet/ComposerRequireChecker/releases/download/4.11.0/composer-require-checker.phar","requirements":{"php":{"php":"~8.2.0 || ~8.3.0","ext-phar":"*"}},"checksum":null,"signature":"https://github.com/maglnet/ComposerRequireChecker/releases/download/4.11.0/composer-require-checker.phar.asc"}},"composerLock":null},"phpmd":{"api-version":"1.0.0","version":"1.0.2.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpmd/phpmd-1.0.2.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpmd":"^2.6.1"}},"checksum":{"type":"sha-512","value":"f22280a6dec8dbdd2ec1d83b294f23237fe32c34f4a298e52038e0a7a0074d541635b2b488b1a6098a42d8418a6cd8eb804406ea82b91e362be2b5d11a0915b0"},"tools":{"phpmd":{"version":"2.15.0","url":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar","requirements":{"php":{"php":">=5.3.9","ext-xml":"*"}},"checksum":null,"signature":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar.asc"}},"composerLock":null},"phpcpd":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpcpd/phpcpd-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcpd":"^6.0"}},"checksum":{"type":"sha-512","value":"1189ce0bf3fade4cb4241f1d96f915ef8fc7651f4450dc79fdf464ee3d6be3009316f0d423ce2d4af9d76ad50807b7fdf4d77bfa6d9ee2c91d6eda32ea214433"},"tools":{"phpcpd":{"version":"6.0.3","url":"https://phar.phpunit.de/phpcpd-6.0.3.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*"}},"checksum":{"type":"sha-256","value":"2cbaea7cfda1bb4299d863eb075e977c3f49055dd16d88529fae5150d48a84cb"},"signature":"https://phar.phpunit.de/phpcpd-6.0.3.phar.asc"}},"composerLock":null},"phploc":{"api-version":"1.0.0","version":"1.0.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phploc/phploc-1.0.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*","ext-json":"*"},"tool":{"phploc":"^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0"}},"checksum":{"type":"sha-512","value":"f67b02d494796adf553cb3dd13ec06c1cb8e53c799954061749424251379541637538199afb3afa3c7a01cabd1cb6f1c53eb621f015dff9644c6c7cbf10c56d1"},"tools":{"phploc":{"version":"7.0.2","url":"https://phar.phpunit.de/phploc-7.0.2.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*","ext-json":"*"}},"checksum":{"type":"sha-256","value":"3d59778ec86faf25fd00e3a329b2f9ad4a3c751ca91601ea7dab70f887b0bf46"},"signature":"https://phar.phpunit.de/phploc-7.0.2.phar.asc"}},"composerLock":null},"phpcs":{"api-version":"1.0.0","version":"1.2.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpcs/phpcs-1.2.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcs":"^3.0 || ^2.0","phpcbf":"^3.0 || ^2.0"}},"checksum":{"type":"sha-512","value":"b6ed00306e76068a6af5e3b1dec837724f9e1900ef1049ce88e7ce195b0583524ca33a73613fba13244307a7ca853b6ddaa14ded69f651c3f184ac130bd1aaad"},"tools":{"phpcs":{"version":"3.10.1","url":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.10.1/phpcs.phar","requirements":{"php":{"php":">=5.4.0","ext-simplexml":"*","ext-tokenizer":"*","ext-xmlwriter":"*"}},"checksum":null,"signature":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.10.1/phpcs.phar.asc"},"phpcbf":{"version":"3.10.1","url":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.10.1/phpcbf.phar","requirements":{"php":{"php":">=5.4.0","ext-simplexml":"*","ext-tokenizer":"*","ext-xmlwriter":"*"}},"checksum":null,"signature":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.10.1/phpcbf.phar.asc"}},"composerLock":null},"composer-normalize":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/composer-normalize/composer-normalize-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-json":"*"},"tool":{"composer-normalize":"^2.1"}},"checksum":{"type":"sha-512","value":"d9abda440b85d501c58abf9c81bf76f417594b397129215ffa8b777e9bb5e5eda37d7661d661db3c8d11c24f20345bc6fbe56f013b3b9435d459d2b94f086e0f"},"tools":{"composer-normalize":{"version":"2.43.0","url":"https://github.com/ergebnis/composer-normalize/releases/download/2.43.0/composer-normalize.phar","requirements":{"php":{"php":"~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0","ext-json":"*"}},"checksum":null,"signature":"https://github.com/ergebnis/composer-normalize/releases/download/2.43.0/composer-normalize.phar.asc"}},"composerLock":null}},"tools":[]} \ No newline at end of file +{"plugins":{"phpunit":{"api-version":"1.0.0","version":"1.0.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpunit/phpunit-1.0.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0"},"tool":{"phpunit":"^6.0 || ^7.0 || ^8.0 || ^9.0"}},"checksum":{"type":"sha-512","value":"c73f15658e3ba62665f09492ec91c3a6a715760bfaa88473a987538439fff442540148e086e46a6aa18ce55a3ea2fbf76caaa581384cb84a38859fcc609ae7e4"},"tools":{"phpunit":{"version":"9.6.20","url":"https://phar.phpunit.de/phpunit-9.6.20.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*","ext-json":"*","ext-libxml":"*","ext-mbstring":"*","ext-xml":"*","ext-xmlwriter":"*"}},"checksum":{"type":"sha-256","value":"4b49fdf48a3fdb5f4f4b5b18c43a542e75787edaf6a6ab39713f579d0a018210"},"signature":"https://phar.phpunit.de/phpunit-9.6.20.phar.asc"}},"composerLock":null},"psalm":{"api-version":"1.0.0","version":"1.2.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/psalm/psalm-1.2.0.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0","ext-dom":"*"},"tool":{"psalm":"^3.0 || ^4.0 || ^5.0"}},"checksum":{"type":"sha-512","value":"4a550c9226d7bca582d7c10bd87cce01190c96398936b1613421640c83df62ed1c6e0d44c1b39635414ea8cf4a892a6458d27590793238add24e7cb5547e6ffd"},"tools":{"psalm":{"version":"5.25.0","url":"https://github.com/vimeo/psalm/releases/download/5.25.0/psalm.phar","requirements":{"php":{"php":"^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0","ext-SimpleXML":"*","ext-ctype":"*","ext-dom":"*","ext-json":"*","ext-libxml":"*","ext-mbstring":"*","ext-tokenizer":"*"}},"checksum":null,"signature":"https://github.com/vimeo/psalm/releases/download/5.25.0/psalm.phar.asc"}},"composerLock":null},"composer-require-checker":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/composer-require-checker/composer-require-checker-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0"},"tool":{"composer-require-checker":"^3.8 || ^4.0"}},"checksum":{"type":"sha-512","value":"d5415bddfe024c5749d894034583882aee4e5c3e1087815d9fdd81cb5e71630f631a0e35de0ff84b97fbbf738c16ece5f83bd8c00695913eb846aa6f04577dc2"},"tools":{"composer-require-checker":{"version":"4.11.0","url":"https://github.com/maglnet/ComposerRequireChecker/releases/download/4.11.0/composer-require-checker.phar","requirements":{"php":{"php":"~8.2.0 || ~8.3.0","ext-phar":"*"}},"checksum":null,"signature":"https://github.com/maglnet/ComposerRequireChecker/releases/download/4.11.0/composer-require-checker.phar.asc"}},"composerLock":null},"phpmd":{"api-version":"1.0.0","version":"1.0.2.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpmd/phpmd-1.0.2.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpmd":"^2.6.1"}},"checksum":{"type":"sha-512","value":"f22280a6dec8dbdd2ec1d83b294f23237fe32c34f4a298e52038e0a7a0074d541635b2b488b1a6098a42d8418a6cd8eb804406ea82b91e362be2b5d11a0915b0"},"tools":{"phpmd":{"version":"2.15.0","url":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar","requirements":{"php":{"php":">=5.3.9","ext-xml":"*"}},"checksum":null,"signature":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar.asc"}},"composerLock":null},"phpcpd":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpcpd/phpcpd-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcpd":"^6.0"}},"checksum":{"type":"sha-512","value":"1189ce0bf3fade4cb4241f1d96f915ef8fc7651f4450dc79fdf464ee3d6be3009316f0d423ce2d4af9d76ad50807b7fdf4d77bfa6d9ee2c91d6eda32ea214433"},"tools":{"phpcpd":{"version":"6.0.3","url":"https://phar.phpunit.de/phpcpd-6.0.3.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*"}},"checksum":{"type":"sha-256","value":"2cbaea7cfda1bb4299d863eb075e977c3f49055dd16d88529fae5150d48a84cb"},"signature":"https://phar.phpunit.de/phpcpd-6.0.3.phar.asc"}},"composerLock":null},"phploc":{"api-version":"1.0.0","version":"1.0.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phploc/phploc-1.0.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*","ext-json":"*"},"tool":{"phploc":"^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0"}},"checksum":{"type":"sha-512","value":"f67b02d494796adf553cb3dd13ec06c1cb8e53c799954061749424251379541637538199afb3afa3c7a01cabd1cb6f1c53eb621f015dff9644c6c7cbf10c56d1"},"tools":{"phploc":{"version":"7.0.2","url":"https://phar.phpunit.de/phploc-7.0.2.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*","ext-json":"*"}},"checksum":{"type":"sha-256","value":"3d59778ec86faf25fd00e3a329b2f9ad4a3c751ca91601ea7dab70f887b0bf46"},"signature":"https://phar.phpunit.de/phploc-7.0.2.phar.asc"}},"composerLock":null},"phpcs":{"api-version":"1.0.0","version":"1.2.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpcs/phpcs-1.2.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcs":"^3.0 || ^2.0","phpcbf":"^3.0 || ^2.0"}},"checksum":{"type":"sha-512","value":"b6ed00306e76068a6af5e3b1dec837724f9e1900ef1049ce88e7ce195b0583524ca33a73613fba13244307a7ca853b6ddaa14ded69f651c3f184ac130bd1aaad"},"tools":{"phpcs":{"version":"3.10.2","url":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.10.2/phpcs.phar","requirements":{"php":{"php":">=5.4.0","ext-simplexml":"*","ext-tokenizer":"*","ext-xmlwriter":"*"}},"checksum":null,"signature":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.10.2/phpcs.phar.asc"},"phpcbf":{"version":"3.10.2","url":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.10.2/phpcbf.phar","requirements":{"php":{"php":">=5.4.0","ext-simplexml":"*","ext-tokenizer":"*","ext-xmlwriter":"*"}},"checksum":null,"signature":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.10.2/phpcbf.phar.asc"}},"composerLock":null},"composer-normalize":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/composer-normalize/composer-normalize-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-json":"*"},"tool":{"composer-normalize":"^2.1"}},"checksum":{"type":"sha-512","value":"d9abda440b85d501c58abf9c81bf76f417594b397129215ffa8b777e9bb5e5eda37d7661d661db3c8d11c24f20345bc6fbe56f013b3b9435d459d2b94f086e0f"},"tools":{"composer-normalize":{"version":"2.43.0","url":"https://github.com/ergebnis/composer-normalize/releases/download/2.43.0/composer-normalize.phar","requirements":{"php":{"php":"~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0","ext-json":"*"}},"checksum":null,"signature":"https://github.com/ergebnis/composer-normalize/releases/download/2.43.0/composer-normalize.phar.asc"}},"composerLock":null}},"tools":[]} \ No newline at end of file diff --git a/src/Resources/contao/dca/tl_metamodel_dcasetting.php b/src/Resources/contao/dca/tl_metamodel_dcasetting.php index 929c46c..1cd0c82 100644 --- a/src/Resources/contao/dca/tl_metamodel_dcasetting.php +++ b/src/Resources/contao/dca/tl_metamodel_dcasetting.php @@ -21,6 +21,7 @@ * @filesource */ +use Contao\BackendUser; use Contao\System; use MetaModels\ContaoFrontendEditingBundle\MetaModelsContaoFrontendEditingBundle; diff --git a/src/Resources/contao/dca/tl_metamodel_rendersetting.php b/src/Resources/contao/dca/tl_metamodel_rendersetting.php index 44b43fe..28960a0 100644 --- a/src/Resources/contao/dca/tl_metamodel_rendersetting.php +++ b/src/Resources/contao/dca/tl_metamodel_rendersetting.php @@ -22,6 +22,9 @@ * @filesource */ +use Contao\BackendUser; +use Contao\System; + /** * Table tl_metamodel_rendersettings */ diff --git a/src/Resources/translations/tl_metamodel_dcasetting.en.xlf b/src/Resources/translations/tl_metamodel_dcasetting.en.xlf index 28a7d54..51df50a 100644 --- a/src/Resources/translations/tl_metamodel_dcasetting.en.xlf +++ b/src/Resources/translations/tl_metamodel_dcasetting.en.xlf @@ -93,10 +93,10 @@ Show files as sortable images e.g. for gallery. - Single file upload [only for frontend editing] - Deprecated! + Single file upload [only for frontend editing] - Single file upload with show thumbnail [only for frontend editing] - Deprecated! + Single file upload with show thumbnail [only for frontend editing] Multiple file upload [only for frontend editing] From c4ffc4231fdbefdc6343e5b78f64d03b7c0b9d16 Mon Sep 17 00:00:00 2001 From: Mini Model Date: Mon, 29 Jul 2024 20:49:10 +0200 Subject: [PATCH 40/56] Updated translations from transifex. --- src/Resources/translations/tl_metamodel_dcasetting.de.xlf | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Resources/translations/tl_metamodel_dcasetting.de.xlf b/src/Resources/translations/tl_metamodel_dcasetting.de.xlf index 6620bca..526ee14 100644 --- a/src/Resources/translations/tl_metamodel_dcasetting.de.xlf +++ b/src/Resources/translations/tl_metamodel_dcasetting.de.xlf @@ -122,12 +122,12 @@ Dateien als sortierbare Bilder anzeigen z.B. für eine Galerie. - Single file upload [only for frontend editing] - Deprecated! - Einzelner Datei-Upload [nur für Frontend-Bearbeitung] - Deprecated! + Single file upload [only for frontend editing] + Einzelner Datei-Upload [nur für Frontend-Bearbeitung] - Single file upload with show thumbnail [only for frontend editing] - Deprecated! - Einzelner Datei-Upload mit Anzeige der Vorschaubilder [nur für Frontend-Bearbeitung] - Deprecated! + Single file upload with show thumbnail [only for frontend editing] + Einzelner Datei-Upload mit Anzeige der Vorschaubilder [nur für Frontend-Bearbeitung] Multiple file upload [only for frontend editing] From 1daac89bbfa9343d868ac3d8cfb0d61d4a1cd55e Mon Sep 17 00:00:00 2001 From: Ingolf Steinardt Date: Wed, 31 Jul 2024 09:12:27 +0200 Subject: [PATCH 41/56] Fix composer --- composer.json | 1 - 1 file changed, 1 deletion(-) diff --git a/composer.json b/composer.json index 7e64509..10044d3 100644 --- a/composer.json +++ b/composer.json @@ -49,7 +49,6 @@ "metamodels/contao-frontend-editing": "^2.3@dev", "phpcq/runner-bootstrap": "^1.0@dev" }, - "minimum-stability": "dev", "autoload": { "psr-4": { "MetaModels\\AttributeFileBundle\\": "src" From 04e507f458191984131461298ebf8946ff69ef88 Mon Sep 17 00:00:00 2001 From: Ingolf Steinardt Date: Mon, 5 Aug 2024 22:13:39 +0200 Subject: [PATCH 42/56] Add image size --- composer.json | 1 - .../RenderSetting/FileImageSizeOptions.php | 137 ++++++++++++++++++ src/Resources/config/event_listener.yml | 116 ++++++++------- .../contao/dca/tl_metamodel_rendersetting.php | 7 +- 4 files changed, 202 insertions(+), 59 deletions(-) create mode 100644 src/EventListener/DcGeneral/Table/RenderSetting/FileImageSizeOptions.php diff --git a/composer.json b/composer.json index 10044d3..e9ae41e 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,6 @@ "email": "mail@metamodel.me", "issues": "https://github.com/MetaModels/attribute_file/issues", "wiki": "https://de.contaowiki.org/MetaModels", - "irc": "irc://irc.freenode.org/contao.mm", "source": "https://github.com/MetaModels/attribute_file" }, "require": { diff --git a/src/EventListener/DcGeneral/Table/RenderSetting/FileImageSizeOptions.php b/src/EventListener/DcGeneral/Table/RenderSetting/FileImageSizeOptions.php new file mode 100644 index 0000000..9c969d0 --- /dev/null +++ b/src/EventListener/DcGeneral/Table/RenderSetting/FileImageSizeOptions.php @@ -0,0 +1,137 @@ + + * @copyright 2012-2024 The MetaModels team. + * @license https://github.com/MetaModels/attribute_file/blob/master/LICENSE LGPL-3.0-or-later + * @filesource + */ + +declare(strict_types=1); + +namespace MetaModels\AttributeFileBundle\EventListener\DcGeneral\Table\RenderSetting; + +use Contao\CoreBundle\Image\ImageSizes; +use ContaoCommunityAlliance\DcGeneral\Contao\RequestScopeDeterminator; +use ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\Event\GetPropertyOptionsEvent; +use Doctrine\DBAL\Connection; +use MetaModels\CoreBundle\EventListener\DcGeneral\Table\RenderSetting\AbstractListener; +use MetaModels\IFactory; +use Symfony\Contracts\Translation\TranslatorInterface; + +/** + * Add the options for the file image size. + */ +final class FileImageSizeOptions extends AbstractListener +{ + public function __construct( + RequestScopeDeterminator $scopeDeterminator, + IFactory $factory, + Connection $connection, + private readonly ImageSizes $imageSizes, + private readonly TranslatorInterface $translator, + ) { + parent::__construct($scopeDeterminator, $factory, $connection); + } + + /** + * Invoke the event. + * + * @param GetPropertyOptionsEvent $event The event. + * + * @return void + */ + public function __invoke(GetPropertyOptionsEvent $event): void + { + if ( + ('file_imageSize' !== $event->getPropertyName()) + || (false === $this->wantToHandle($event)) + || (false === $this->isAttributeFile($event)) + ) { + return; + } + + $this->addOptions($event); + } + + /** + * Add the options. + * + * @param GetPropertyOptionsEvent $event The event. + * + * @return void + */ + private function addOptions(GetPropertyOptionsEvent $event): void + { + $options = $this->imageSizes->getAllOptions(); + $optionsFull = []; + foreach ($options as $section => $sizeNames) { + $optionsFull[$this->translateSizeName($section)] = $this->translateSection($section, $sizeNames); + } + + $event->setOptions($optionsFull); + } + + /** + * If used attribute type of file. + * + * @param GetPropertyOptionsEvent $event The event. + * + * @return bool + */ + private function isAttributeFile(GetPropertyOptionsEvent $event): bool + { + $builder = $this->connection->createQueryBuilder(); + $builder + ->select('t.type') + ->from('tl_metamodel_attribute', 't') + ->where($builder->expr()->eq('t.id', ':id')) + ->setParameter('id', $event->getModel()->getProperty('attr_id')); + + $statement = $builder->executeQuery(); + if (0 === $statement->columnCount()) { + return false; + } + + $result = $statement->fetchAssociative(); + + return 'file' === ($result['type'] ?? null); + } + + private function translateSection(string $section, array $sizeNames): array + { + if (!\in_array($section, ['relative', 'exact'], true)) { + return $sizeNames; + } + + $optionSection = []; + foreach ($sizeNames as $currentLabel) { + $optionSection[$currentLabel] = $this->translateSizeName($currentLabel); + } + return $optionSection; + } + + private function translateSizeName(string $sizeName): string + { + $key = 'MSC.' . $sizeName . '.0'; + if ($key !== $label = $this->translator->trans($key, [], 'contao_default')) { + return $label; + } + $key = 'MSC.' . $sizeName; + if ($key !== $label = $this->translator->trans($key, [], 'contao_default')) { + return $label; + } + + return $sizeName; + } +} diff --git a/src/Resources/config/event_listener.yml b/src/Resources/config/event_listener.yml index d7f7057..38806e0 100644 --- a/src/Resources/config/event_listener.yml +++ b/src/Resources/config/event_listener.yml @@ -1,59 +1,71 @@ services: - metamodels.attribute_file.event_listener.image_size_options: - class: MetaModels\AttributeFileBundle\EventListener\ImageSizeOptionsListener - public: true - tags: - - name: kernel.event_listener - event: dc-general.view.contao2backend.get-property-options - method: getPropertyOptions + metamodels.attribute_file.event_listener.image_size_options: + class: MetaModels\AttributeFileBundle\EventListener\ImageSizeOptionsListener + public: true + tags: + - name: kernel.event_listener + event: dc-general.view.contao2backend.get-property-options + method: getPropertyOptions - metamodels.attribute_file.event_listener.remove_type_options: - class: MetaModels\AttributeFileBundle\EventListener\DcGeneral\Table\Attribute\RemoveTypeOptions - public: true - tags: - - name: kernel.event_listener - event: dc-general.view.contao2backend.get-property-options - method: removeOption - priority: -1 + metamodels.attribute_file.event_listener.remove_type_options: + class: MetaModels\AttributeFileBundle\EventListener\DcGeneral\Table\Attribute\RemoveTypeOptions + public: true + tags: + - name: kernel.event_listener + event: dc-general.view.contao2backend.get-property-options + method: removeOption + priority: -1 - metamodels.attribute_file.event_listener.remove_attid_options: - class: MetaModels\AttributeFileBundle\EventListener\DcGeneral\Table\FilterSetting\RemoveAttIdOptions - public: true - tags: - - name: kernel.event_listener - event: dc-general.view.contao2backend.get-property-options - method: removeOption - priority: -1 + metamodels.attribute_file.event_listener.remove_attid_options: + class: MetaModels\AttributeFileBundle\EventListener\DcGeneral\Table\FilterSetting\RemoveAttIdOptions + public: true + tags: + - name: kernel.event_listener + event: dc-general.view.contao2backend.get-property-options + method: removeOption + priority: -1 - metamodels.attribute_file.event_listener.build_attribute: - class: MetaModels\AttributeFileBundle\EventListener\BuildAttributeListener - public: true - tags: - - name: kernel.event_listener - event: metamodels.dc-general.events.metamodel.build.attribute - method: buildAttribute + metamodels.attribute_file.event_listener.build_attribute: + class: MetaModels\AttributeFileBundle\EventListener\BuildAttributeListener + public: true + tags: + - name: kernel.event_listener + event: metamodels.dc-general.events.metamodel.build.attribute + method: buildAttribute - metamodels.attribute_file.event_listener.build-data-definition: - class: MetaModels\AttributeFileBundle\EventListener\BuildDataDefinitionListener - public: true - tags: - - name: kernel.event_listener - event: dc-general.factory.build-data-definition - method: buildDataDefinition - priority: 0 + metamodels.attribute_file.event_listener.build-data-definition: + class: MetaModels\AttributeFileBundle\EventListener\BuildDataDefinitionListener + public: true + tags: + - name: kernel.event_listener + event: dc-general.factory.build-data-definition + method: buildDataDefinition + priority: 0 - MetaModels\AttributeFileBundle\EventListener\DcGeneral\Table\DcaSetting\FileWidgetModeOptions: - public: false - arguments: - $scopeDeterminator: '@cca.dc-general.scope-matcher' - $factory: '@MetaModels\IFactory' - $connection: '@database_connection' - # The $frontendEditing argument where set in the extension. - $frontendEditing: ~ - tags: - - name: kernel.event_listener - event: dc-general.view.contao2backend.get-property-options + MetaModels\AttributeFileBundle\EventListener\DcGeneral\Table\DcaSetting\FileWidgetModeOptions: + public: false + arguments: + $scopeDeterminator: '@cca.dc-general.scope-matcher' + $factory: '@MetaModels\IFactory' + $connection: '@database_connection' + # The $frontendEditing argument where set in the extension. + $frontendEditing: ~ + tags: + - name: kernel.event_listener + event: dc-general.view.contao2backend.get-property-options - MetaModels\AttributeFileBundle\Schema\DoctrineSchemaGenerator: - tags: - - { name: 'metamodels.schema-generator.doctrine' } + MetaModels\AttributeFileBundle\EventListener\DcGeneral\Table\RenderSetting\FileImageSizeOptions: + public: false + arguments: + $scopeDeterminator: '@cca.dc-general.scope-matcher' + $factory: '@MetaModels\IFactory' + $connection: '@database_connection' + $imageSizes: '@contao.image.sizes' + $translator: '@translator' + tags: + - name: kernel.event_listener + event: dc-general.view.contao2backend.get-property-options + + MetaModels\AttributeFileBundle\Schema\DoctrineSchemaGenerator: + tags: + - { name: 'metamodels.schema-generator.doctrine' } diff --git a/src/Resources/contao/dca/tl_metamodel_rendersetting.php b/src/Resources/contao/dca/tl_metamodel_rendersetting.php index 28960a0..eaa4fb6 100644 --- a/src/Resources/contao/dca/tl_metamodel_rendersetting.php +++ b/src/Resources/contao/dca/tl_metamodel_rendersetting.php @@ -100,18 +100,13 @@ 'description' => 'file_imageSize.description', 'exclude' => true, 'inputType' => 'imageSize', - 'options_callback' => static function () { - return System::getContainer()->get('contao.image.sizes')?->getOptionsForUser(BackendUser::getInstance()); - }, - 'reference' => &$GLOBALS['TL_LANG']['MSC'], 'eval' => [ 'rgxp' => 'natural', 'includeBlankOption' => true, 'nospace' => true, - 'helpwizard' => true, 'tl_class' => 'clr w50' ], - 'sql' => 'varchar(255) NOT NULL default \'\'', + 'sql' => 'varchar(128) COLLATE ascii_bin NOT NULL \'\'', ]; $GLOBALS['TL_DCA']['tl_metamodel_rendersetting']['fields']['file_placeholder'] = [ From 5c84e9b4cdf57431554fef95005aa73370bf85f3 Mon Sep 17 00:00:00 2001 From: Ingolf Steinardt Date: Wed, 7 Aug 2024 15:15:41 +0200 Subject: [PATCH 43/56] Add image size --- .phpcq.yaml.dist | 4 +- composer.json | 5 +- .../DcaSetting/FeeFileImageSizeOptions.php | 90 +++++++++++++++++ .../RenderSetting/FileImageSizeOptions.php | 53 +--------- .../ImageSizeOptionsListener.php | 96 ------------------- .../ImageSizeOptionsProvider.php | 82 ++++++++++++++++ src/Resources/config/event_listener.yml | 24 +++-- .../contao/dca/tl_metamodel_dcasetting.php | 5 - src/deprecated-autoload.php | 4 +- .../MetaModelsAttributeFileExtensionTest.php | 4 +- tests/DeprecatedAutoloaderTest.php | 6 +- 11 files changed, 202 insertions(+), 171 deletions(-) create mode 100644 src/EventListener/DcGeneral/Table/DcaSetting/FeeFileImageSizeOptions.php delete mode 100644 src/EventListener/ImageSizeOptionsListener.php create mode 100644 src/EventListener/ImageSizeOptionsProvider.php diff --git a/.phpcq.yaml.dist b/.phpcq.yaml.dist index 41607a4..a9616d5 100644 --- a/.phpcq.yaml.dist +++ b/.phpcq.yaml.dist @@ -79,8 +79,8 @@ tasks: config: exclude: - tests - - src/CoreBundle/EventListener/DcGeneral/DefinitionBuilder - - src/CoreBundle/Resources/contao/dca + - src/EventListener/DcGeneral/Table/DcaSetting/FeeFileImageSizeOptions.php + - src/EventListener/DcGeneral/Table/RenderSetting/FileImageSizeOptions.php phpmd: plugin: phpmd diff --git a/composer.json b/composer.json index e9ae41e..13e84ed 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,7 @@ }, "require": { "php": "^8.1", - "contao-community-alliance/dc-general": "^2.3@dev", + "contao-community-alliance/dc-general": "^2.3", "contao/core-bundle": "^4.13.0 <5.0", "doctrine/dbal": "^3.6.0", "metamodels/core": "^2.3@dev", @@ -40,7 +40,8 @@ "symfony/config": "^5.4", "symfony/dependency-injection": "^5.4", "symfony/http-kernel": "^5.4", - "symfony/security-core": "^5.4" + "symfony/security-core": "^5.4", + "symfony/translation-contracts": "^2.5.2" }, "require-dev": { "contao/manager-plugin": "^2.1", diff --git a/src/EventListener/DcGeneral/Table/DcaSetting/FeeFileImageSizeOptions.php b/src/EventListener/DcGeneral/Table/DcaSetting/FeeFileImageSizeOptions.php new file mode 100644 index 0000000..e63bba8 --- /dev/null +++ b/src/EventListener/DcGeneral/Table/DcaSetting/FeeFileImageSizeOptions.php @@ -0,0 +1,90 @@ + + * @copyright 2012-2024 The MetaModels team. + * @license https://github.com/MetaModels/attribute_file/blob/master/LICENSE LGPL-3.0-or-later + * @filesource + */ + +declare(strict_types=1); + +namespace MetaModels\AttributeFileBundle\EventListener\DcGeneral\Table\DcaSetting; + +use ContaoCommunityAlliance\DcGeneral\Contao\RequestScopeDeterminator; +use ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\Event\GetPropertyOptionsEvent; +use Doctrine\DBAL\Connection; +use MetaModels\AttributeFileBundle\EventListener\ImageSizeOptionsProvider; +use MetaModels\CoreBundle\EventListener\DcGeneral\Table\DcaSetting\AbstractListener; +use MetaModels\IFactory; + +/** + * Add the options for the FEE file image size. + */ +final class FeeFileImageSizeOptions extends AbstractListener +{ + public function __construct( + RequestScopeDeterminator $scopeDeterminator, + IFactory $factory, + Connection $connection, + private readonly ImageSizeOptionsProvider $optionsProvider, + ) { + parent::__construct($scopeDeterminator, $factory, $connection); + } + + /** + * Invoke the event. + * + * @param GetPropertyOptionsEvent $event The event. + * + * @return void + */ + public function __invoke(GetPropertyOptionsEvent $event): void + { + if ( + ('fe_widget_file_imageSize' !== $event->getPropertyName()) + || (false === $this->wantToHandle($event)) + || (false === $this->isAttributeFile($event)) + ) { + return; + } + + $this->optionsProvider->addOptions($event); + } + + /** + * If used attribute type of file. + * + * @param GetPropertyOptionsEvent $event The event. + * + * @return bool + */ + private function isAttributeFile(GetPropertyOptionsEvent $event): bool + { + $builder = $this->connection->createQueryBuilder(); + $builder + ->select('t.type') + ->from('tl_metamodel_attribute', 't') + ->where($builder->expr()->eq('t.id', ':id')) + ->setParameter('id', $event->getModel()->getProperty('attr_id')); + + $statement = $builder->executeQuery(); + if (0 === $statement->columnCount()) { + return false; + } + + $result = $statement->fetchAssociative(); + + return 'file' === ($result['type'] ?? null); + } +} diff --git a/src/EventListener/DcGeneral/Table/RenderSetting/FileImageSizeOptions.php b/src/EventListener/DcGeneral/Table/RenderSetting/FileImageSizeOptions.php index 9c969d0..c6e04bb 100644 --- a/src/EventListener/DcGeneral/Table/RenderSetting/FileImageSizeOptions.php +++ b/src/EventListener/DcGeneral/Table/RenderSetting/FileImageSizeOptions.php @@ -21,13 +21,12 @@ namespace MetaModels\AttributeFileBundle\EventListener\DcGeneral\Table\RenderSetting; -use Contao\CoreBundle\Image\ImageSizes; use ContaoCommunityAlliance\DcGeneral\Contao\RequestScopeDeterminator; use ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\Event\GetPropertyOptionsEvent; use Doctrine\DBAL\Connection; +use MetaModels\AttributeFileBundle\EventListener\ImageSizeOptionsProvider; use MetaModels\CoreBundle\EventListener\DcGeneral\Table\RenderSetting\AbstractListener; use MetaModels\IFactory; -use Symfony\Contracts\Translation\TranslatorInterface; /** * Add the options for the file image size. @@ -38,8 +37,7 @@ public function __construct( RequestScopeDeterminator $scopeDeterminator, IFactory $factory, Connection $connection, - private readonly ImageSizes $imageSizes, - private readonly TranslatorInterface $translator, + private readonly ImageSizeOptionsProvider $optionsProvider, ) { parent::__construct($scopeDeterminator, $factory, $connection); } @@ -61,25 +59,7 @@ public function __invoke(GetPropertyOptionsEvent $event): void return; } - $this->addOptions($event); - } - - /** - * Add the options. - * - * @param GetPropertyOptionsEvent $event The event. - * - * @return void - */ - private function addOptions(GetPropertyOptionsEvent $event): void - { - $options = $this->imageSizes->getAllOptions(); - $optionsFull = []; - foreach ($options as $section => $sizeNames) { - $optionsFull[$this->translateSizeName($section)] = $this->translateSection($section, $sizeNames); - } - - $event->setOptions($optionsFull); + $this->optionsProvider->addOptions($event); } /** @@ -107,31 +87,4 @@ private function isAttributeFile(GetPropertyOptionsEvent $event): bool return 'file' === ($result['type'] ?? null); } - - private function translateSection(string $section, array $sizeNames): array - { - if (!\in_array($section, ['relative', 'exact'], true)) { - return $sizeNames; - } - - $optionSection = []; - foreach ($sizeNames as $currentLabel) { - $optionSection[$currentLabel] = $this->translateSizeName($currentLabel); - } - return $optionSection; - } - - private function translateSizeName(string $sizeName): string - { - $key = 'MSC.' . $sizeName . '.0'; - if ($key !== $label = $this->translator->trans($key, [], 'contao_default')) { - return $label; - } - $key = 'MSC.' . $sizeName; - if ($key !== $label = $this->translator->trans($key, [], 'contao_default')) { - return $label; - } - - return $sizeName; - } } diff --git a/src/EventListener/ImageSizeOptionsListener.php b/src/EventListener/ImageSizeOptionsListener.php deleted file mode 100644 index 144b267..0000000 --- a/src/EventListener/ImageSizeOptionsListener.php +++ /dev/null @@ -1,96 +0,0 @@ - - * @author Christian Schiffler - * @copyright 2012-2023 The MetaModels team. - * @license https://github.com/MetaModels/attribute_file/blob/master/LICENSE LGPL-3.0-or-later - * @filesource - */ - -namespace MetaModels\AttributeFileBundle\EventListener; - -use ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\Event\GetPropertyOptionsEvent; -use ContaoCommunityAlliance\DcGeneral\Data\CollectionInterface; -use ContaoCommunityAlliance\DcGeneral\Data\DefaultDataProvider; -use ContaoCommunityAlliance\DcGeneral\DataDefinition\ContainerInterface; - -/** - * Get the options for the image size. - */ -class ImageSizeOptionsListener -{ - /** - * Get property options for file image size in the render settings. - * - * @param GetPropertyOptionsEvent $event The event. - * - * @return void - */ - public function getPropertyOptions(GetPropertyOptionsEvent $event) - { - $dataDefinition = $event->getEnvironment()->getDataDefinition(); - assert($dataDefinition instanceof ContainerInterface); - - if ( - ('file_imageSize' !== $event->getPropertyName()) - || ('tl_metamodel_rendersetting' !== $dataDefinition->getName()) - ) { - return; - } - - $sizes = $this->getThemeImageSizes(); - if (!$sizes) { - return; - } - - $options = $event->getOptions(); - if (\is_array($options) && \array_key_exists('image_sizes', $options)) { - $options['image_sizes'] = \array_replace($sizes, $options['image_sizes']); - $event->setOptions($options); - } - } - - /** - * Get the image sizes from the theme. - * - * @return array - */ - private function getThemeImageSizes(): array - { - $dataProvider = new DefaultDataProvider(); - $dataProvider->setBaseConfig(['source' => 'tl_image_size']); - - $config = $dataProvider->getEmptyConfig(); - $config->setFields(['id', 'name', 'width', 'height']); - $config->setSorting(['pid' => 'ASC', 'name' => 'ASC']); - - $collection = $dataProvider->fetchAll($config); - assert($collection instanceof CollectionInterface); - if (!$collection->count()) { - return []; - } - - $sizes = []; - foreach ($collection as $model) { - $sizes[$model->getProperty('id')] = \sprintf( - '%s (%sx%s)', - $model->getProperty('name'), - $model->getProperty('width'), - $model->getProperty('height') - ); - } - - return $sizes; - } -} diff --git a/src/EventListener/ImageSizeOptionsProvider.php b/src/EventListener/ImageSizeOptionsProvider.php new file mode 100644 index 0000000..b1eae6e --- /dev/null +++ b/src/EventListener/ImageSizeOptionsProvider.php @@ -0,0 +1,82 @@ + + * @author Christian Schiffler + * @copyright 2012-2023 The MetaModels team. + * @license https://github.com/MetaModels/attribute_file/blob/master/LICENSE LGPL-3.0-or-later + * @filesource + */ + +namespace MetaModels\AttributeFileBundle\EventListener; + +use Contao\CoreBundle\Image\ImageSizes; +use ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\Event\GetPropertyOptionsEvent; +use Symfony\Contracts\Translation\TranslatorInterface; + +/** + * Get the options for the image size. + */ +class ImageSizeOptionsProvider +{ + public function __construct( + private readonly ImageSizes $imageSizes, + private readonly TranslatorInterface $translator, + ) { + } + + /** + * Add the options. + * + * @param GetPropertyOptionsEvent $event The event. + * + * @return void + */ + public function addOptions(GetPropertyOptionsEvent $event): void + { + $options = $this->imageSizes->getAllOptions(); + $optionsFull = []; + foreach ($options as $section => $sizeNames) { + $optionsFull[$this->translateSizeName($section)] = $this->translateSection($section, $sizeNames); + } + + $event->setOptions($optionsFull); + } + + private function translateSection(string $section, array $sizeNames): array + { + if (!\in_array($section, ['relative', 'exact'], true)) { + return $sizeNames; + } + + $optionSection = []; + foreach ($sizeNames as $currentLabel) { + $optionSection[$currentLabel] = $this->translateSizeName($currentLabel); + } + return $optionSection; + } + + private function translateSizeName(string $sizeName): string + { + $key = 'MSC.' . $sizeName . '.0'; + if ($key !== $label = $this->translator->trans($key, [], 'contao_default')) { + return $label; + } + $key = 'MSC.' . $sizeName; + if ($key !== $label = $this->translator->trans($key, [], 'contao_default')) { + return $label; + } + + return $sizeName; + } +} diff --git a/src/Resources/config/event_listener.yml b/src/Resources/config/event_listener.yml index 38806e0..8ab2146 100644 --- a/src/Resources/config/event_listener.yml +++ b/src/Resources/config/event_listener.yml @@ -1,11 +1,9 @@ services: metamodels.attribute_file.event_listener.image_size_options: - class: MetaModels\AttributeFileBundle\EventListener\ImageSizeOptionsListener - public: true - tags: - - name: kernel.event_listener - event: dc-general.view.contao2backend.get-property-options - method: getPropertyOptions + class: MetaModels\AttributeFileBundle\EventListener\ImageSizeOptionsProvider + arguments: + $imageSizes: '@contao.image.sizes' + $translator: '@translator' metamodels.attribute_file.event_listener.remove_type_options: class: MetaModels\AttributeFileBundle\EventListener\DcGeneral\Table\Attribute\RemoveTypeOptions @@ -54,14 +52,24 @@ services: - name: kernel.event_listener event: dc-general.view.contao2backend.get-property-options + MetaModels\AttributeFileBundle\EventListener\DcGeneral\Table\DcaSetting\FeeFileImageSizeOptions: + public: false + arguments: + $scopeDeterminator: '@cca.dc-general.scope-matcher' + $factory: '@MetaModels\IFactory' + $connection: '@database_connection' + $optionsProvider: '@metamodels.attribute_file.event_listener.image_size_options' + tags: + - name: kernel.event_listener + event: dc-general.view.contao2backend.get-property-options + MetaModels\AttributeFileBundle\EventListener\DcGeneral\Table\RenderSetting\FileImageSizeOptions: public: false arguments: $scopeDeterminator: '@cca.dc-general.scope-matcher' $factory: '@MetaModels\IFactory' $connection: '@database_connection' - $imageSizes: '@contao.image.sizes' - $translator: '@translator' + $optionsProvider: '@metamodels.attribute_file.event_listener.image_size_options' tags: - name: kernel.event_listener event: dc-general.view.contao2backend.get-property-options diff --git a/src/Resources/contao/dca/tl_metamodel_dcasetting.php b/src/Resources/contao/dca/tl_metamodel_dcasetting.php index 1cd0c82..56ed2a1 100644 --- a/src/Resources/contao/dca/tl_metamodel_dcasetting.php +++ b/src/Resources/contao/dca/tl_metamodel_dcasetting.php @@ -238,16 +238,11 @@ 'description' => 'fe_widget_file_imageSize.description', 'exclude' => true, 'inputType' => 'imageSize', - 'options_callback' => static function () { - return System::getContainer()->get('contao.image.sizes')?->getOptionsForUser(BackendUser::getInstance()); - }, - 'reference' => &$GLOBALS['TL_LANG']['MSC'], 'sql' => 'varchar(255) NOT NULL default \'\'', 'eval' => [ 'rgxp' => 'digit', 'includeBlankOption' => true, 'nospace' => true, - 'helpwizard' => true, 'tl_class' => 'w50' ] ]; diff --git a/src/deprecated-autoload.php b/src/deprecated-autoload.php index 4085698..7a050dc 100644 --- a/src/deprecated-autoload.php +++ b/src/deprecated-autoload.php @@ -23,7 +23,7 @@ use MetaModels\AttributeFileBundle\Attribute\File; use MetaModels\AttributeFileBundle\Attribute\FileOrder; use MetaModels\AttributeFileBundle\DcGeneral\AttributeFileDefinition; -use MetaModels\AttributeFileBundle\EventListener\ImageSizeOptionsListener; +use MetaModels\AttributeFileBundle\EventListener\ImageSizeOptionsProvider; // This hack is to load the "old locations" of the classes. spl_autoload_register( @@ -33,7 +33,7 @@ function ($class) { 'MetaModels\Attribute\File\FileOrder' => FileOrder::class, 'MetaModels\Attribute\File\AttributeTypeFactory' => AttributeTypeFactory::class, 'MetaModels\DcGeneral\AttributeFileDefinition' => AttributeFileDefinition::class, - 'MetaModels\Events\Attribute\File\ImageSizeOptions' => ImageSizeOptionsListener::class + 'MetaModels\Events\Attribute\File\ImageSizeOptions' => ImageSizeOptionsProvider::class ]; if (isset($classes[$class])) { diff --git a/tests/DependencyInjection/MetaModelsAttributeFileExtensionTest.php b/tests/DependencyInjection/MetaModelsAttributeFileExtensionTest.php index b3c7fd7..02b795d 100644 --- a/tests/DependencyInjection/MetaModelsAttributeFileExtensionTest.php +++ b/tests/DependencyInjection/MetaModelsAttributeFileExtensionTest.php @@ -26,7 +26,7 @@ use MetaModels\ContaoFrontendEditingBundle\MetaModelsContaoFrontendEditingBundle; use MetaModels\AttributeFileBundle\EventListener\BuildAttributeListener; use MetaModels\AttributeFileBundle\EventListener\BuildDataDefinitionListener; -use MetaModels\AttributeFileBundle\EventListener\ImageSizeOptionsListener; +use MetaModels\AttributeFileBundle\EventListener\ImageSizeOptionsProvider; use MetaModels\AttributeFileBundle\Schema\DoctrineSchemaGenerator; use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -65,8 +65,6 @@ public function testFactoryIsRegistered(): void self::assertCount(1, $definition->getTag('kernel.event_listener')); self::assertTrue($container->hasDefinition('metamodels.attribute_file.event_listener.image_size_options')); - $definition = $container->getDefinition('metamodels.attribute_file.event_listener.image_size_options'); - self::assertCount(1, $definition->getTag('kernel.event_listener')); self::assertTrue($container->hasDefinition('metamodels.attribute_file.event_listener.build-data-definition')); $definition = $container->getDefinition('metamodels.attribute_file.event_listener.build-data-definition'); diff --git a/tests/DeprecatedAutoloaderTest.php b/tests/DeprecatedAutoloaderTest.php index d164e59..c2302fb 100644 --- a/tests/DeprecatedAutoloaderTest.php +++ b/tests/DeprecatedAutoloaderTest.php @@ -25,7 +25,7 @@ use MetaModels\AttributeFileBundle\Attribute\AttributeTypeFactory; use MetaModels\AttributeFileBundle\Attribute\FileOrder; use MetaModels\AttributeFileBundle\DcGeneral\AttributeFileDefinition; -use MetaModels\AttributeFileBundle\EventListener\ImageSizeOptionsListener; +use MetaModels\AttributeFileBundle\EventListener\ImageSizeOptionsProvider; use PHPUnit\Framework\TestCase; /** @@ -35,7 +35,7 @@ * @covers \MetaModels\AttributeFileBundle\Attribute\FileOrder * @covers \MetaModels\AttributeFileBundle\Attribute\AttributeTypeFactory * @covers \MetaModels\AttributeFileBundle\DcGeneral\AttributeFileDefinition - * @covers \MetaModels\AttributeFileBundle\EventListener\ImageSizeOptionsListener + * @covers \MetaModels\AttributeFileBundle\EventListener\ImageSizeOptionsProvider */ class DeprecatedAutoloaderTest extends TestCase { @@ -49,7 +49,7 @@ class DeprecatedAutoloaderTest extends TestCase 'MetaModels\Attribute\File\FileOrder' => FileOrder::class, 'MetaModels\Attribute\File\AttributeTypeFactory' => AttributeTypeFactory::class, 'MetaModels\DcGeneral\AttributeFileDefinition' => AttributeFileDefinition::class, - 'MetaModels\Events\Attribute\File\ImageSizeOptions' => ImageSizeOptionsListener::class, + 'MetaModels\Events\Attribute\File\ImageSizeOptions' => ImageSizeOptionsProvider::class, ]; /** From 12a8fa222815b0dcf7dde31573d03f4e96ae9c0b Mon Sep 17 00:00:00 2001 From: Ingolf Steinardt Date: Wed, 7 Aug 2024 20:56:57 +0200 Subject: [PATCH 44/56] Fix deprecations --- src/Attribute/File.php | 6 +++--- src/ContaoManager/Plugin.php | 7 ++++--- .../MetaModelsAttributeFileExtension.php | 8 ++++---- src/Resources/config/factory.yml | 2 +- src/Resources/config/services.yml | 5 ++++- 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/Attribute/File.php b/src/Attribute/File.php index f4cc322..59d6caf 100644 --- a/src/Attribute/File.php +++ b/src/Attribute/File.php @@ -3,7 +3,7 @@ /** * This file is part of MetaModels/attribute_file. * - * (c) 2012-2023 The MetaModels team. + * (c) 2012-2024 The MetaModels team. * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -23,7 +23,7 @@ * @author David Molineus * @author Sven Baumann * @author Ingolf Steinhardt - * @copyright 2012-2023 The MetaModels team. + * @copyright 2012-2024 The MetaModels team. * @license https://github.com/MetaModels/attribute_file/blob/master/LICENSE LGPL-3.0-or-later * @filesource */ @@ -141,7 +141,7 @@ public function __construct( } if (null === $toolboxFile) { - $toolboxFile = $this->fetchServiceForFallback('toolboxFile', 'metamodels.attribute_file.toolbox.file'); + $toolboxFile = $this->fetchServiceForFallback('toolboxFile', 'MetaModels\Helper\ToolboxFile'); assert($toolboxFile instanceof ToolboxFile); } diff --git a/src/ContaoManager/Plugin.php b/src/ContaoManager/Plugin.php index 573be26..c5f9410 100644 --- a/src/ContaoManager/Plugin.php +++ b/src/ContaoManager/Plugin.php @@ -3,7 +3,7 @@ /** * This file is part of MetaModels/attribute_file. * - * (c) 2012-2019 The MetaModels team. + * (c) 2012-2024 The MetaModels team. * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -13,7 +13,8 @@ * @package MetaModels/attribute_file * @author Christian Schiffler * @author Sven Baumann - * @copyright 2012-2019 The MetaModels team. + * @author Ingolf Steinhardt + * @copyright 2012-2024 The MetaModels team. * @license https://github.com/MetaModels/attribute_file/blob/master/LICENSE LGPL-3.0-or-later * @filesource */ @@ -35,7 +36,7 @@ class Plugin implements BundlePluginInterface /** * {@inheritdoc} */ - public function getBundles(ParserInterface $parser) + public function getBundles(ParserInterface $parser): array { return [ BundleConfig::create(MetaModelsAttributeFileBundle::class) diff --git a/src/DependencyInjection/MetaModelsAttributeFileExtension.php b/src/DependencyInjection/MetaModelsAttributeFileExtension.php index 6adc0d6..1e87d9c 100644 --- a/src/DependencyInjection/MetaModelsAttributeFileExtension.php +++ b/src/DependencyInjection/MetaModelsAttributeFileExtension.php @@ -3,7 +3,7 @@ /** * This file is part of MetaModels/attribute_file. * - * (c) 2012-2023 The MetaModels team. + * (c) 2012-2024 The MetaModels team. * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -14,7 +14,7 @@ * @author Christian Schiffler * @author Sven Baumann * @author Ingolf Steinhardt - * @copyright 2012-2023 The MetaModels team. + * @copyright 2012-2024 The MetaModels team. * @license https://github.com/MetaModels/attribute_file/blob/master/LICENSE LGPL-3.0-or-later * @filesource */ @@ -24,6 +24,7 @@ use MetaModels\AttributeFileBundle\EventListener\DcGeneral\Table\DcaSetting\FileWidgetModeOptions; use MetaModels\ContaoFrontendEditingBundle\MetaModelsContaoFrontendEditingBundle; use Symfony\Component\Cache\Adapter\ArrayAdapter; +use Symfony\Component\Config\Definition\ConfigurationInterface; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Extension\Extension; @@ -33,7 +34,6 @@ use function in_array; use function is_array; use function is_bool; -use function is_string; /** * This is the class that loads and manages the bundle configuration @@ -80,7 +80,7 @@ public function load(array $configs, ContainerBuilder $container): void /** * {@inheritDoc} */ - public function getConfiguration(array $config, ContainerBuilder $container) + public function getConfiguration(array $config, ContainerBuilder $container): ?ConfigurationInterface { $debug = $container->getParameter('kernel.debug'); assert(is_bool($debug)); diff --git a/src/Resources/config/factory.yml b/src/Resources/config/factory.yml index b405e8e..fe9fcaa 100644 --- a/src/Resources/config/factory.yml +++ b/src/Resources/config/factory.yml @@ -4,7 +4,7 @@ services: arguments: - "@database_connection" - "@metamodels.table_manipulator" - - "@metamodels.attribute_file.toolbox.file" + - '@MetaModels\Helper\ToolboxFile' - "@=service('contao.framework').getAdapter('Contao\\\\StringUtil')" - "@=service('contao.framework').getAdapter('Contao\\\\Validator')" - "@=service('contao.framework').getAdapter('Contao\\\\FilesModel')" diff --git a/src/Resources/config/services.yml b/src/Resources/config/services.yml index d947a3b..9c59da6 100644 --- a/src/Resources/config/services.yml +++ b/src/Resources/config/services.yml @@ -1,6 +1,9 @@ services: metamodels.attribute_file.toolbox.file: - deprecated: 'The "%alias_id%" service is deprecated. Use the "@MetaModels\Helper\ToolboxFile".' + deprecated: + package: metamodels /attribute_file + version: 2.1 + message: 'The "%alias_id%" service is deprecated. Use the "@MetaModels\Helper\ToolboxFile".' alias: MetaModels\Helper\ToolboxFile public: true From bd9814e50b5538cb0d3a468004a70f8dd48f3b2f Mon Sep 17 00:00:00 2001 From: Ingolf Steinardt Date: Tue, 13 Aug 2024 09:48:35 +0200 Subject: [PATCH 45/56] Fix dca filesize --- src/Resources/contao/dca/tl_metamodel_rendersetting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Resources/contao/dca/tl_metamodel_rendersetting.php b/src/Resources/contao/dca/tl_metamodel_rendersetting.php index eaa4fb6..8eb74b0 100644 --- a/src/Resources/contao/dca/tl_metamodel_rendersetting.php +++ b/src/Resources/contao/dca/tl_metamodel_rendersetting.php @@ -106,7 +106,7 @@ 'nospace' => true, 'tl_class' => 'clr w50' ], - 'sql' => 'varchar(128) COLLATE ascii_bin NOT NULL \'\'', + 'sql' => 'varchar(128) COLLATE ascii_bin NOT NULL default \'\'', ]; $GLOBALS['TL_DCA']['tl_metamodel_rendersetting']['fields']['file_placeholder'] = [ From d3f03b166d1dbff00789972153a3c4bb1e19f4aa Mon Sep 17 00:00:00 2001 From: Mini Model Date: Sun, 18 Aug 2024 22:16:41 +0200 Subject: [PATCH 46/56] Updated translations from transifex. --- .../tl_metamodel_attribute.fr.xlf | 62 +++++++ .../tl_metamodel_dcasetting.fr.xlf | 156 ++++++++++++++++++ .../tl_metamodel_rendersetting.fr.xlf | 78 +++++++++ 3 files changed, 296 insertions(+) create mode 100644 src/Resources/translations/tl_metamodel_attribute.fr.xlf create mode 100644 src/Resources/translations/tl_metamodel_dcasetting.fr.xlf create mode 100644 src/Resources/translations/tl_metamodel_rendersetting.fr.xlf diff --git a/src/Resources/translations/tl_metamodel_attribute.fr.xlf b/src/Resources/translations/tl_metamodel_attribute.fr.xlf new file mode 100644 index 0000000..26f346a --- /dev/null +++ b/src/Resources/translations/tl_metamodel_attribute.fr.xlf @@ -0,0 +1,62 @@ + + + + + File + Fichier + + + Customize the file tree + Personnaliser l'arborescence + + + Allows you to set custom options for the filetree. + Permet de personnaliser les options de l'arborescence. + + + Set file root folder + Spécifier le dossier racine + + + Selects the root point from which the user will select this file field. + Sélectionne le point racine à partir duquel l'utilisateur sélectionnera ce champ de fichier. + + + Valid file types + Types de fichiers autorisés + + + To overwrite the contao standard file types, please enter a comma separated list of extensions of valid file types for this field. + Saisir une liste d'extensions de fichiers séparées par des virgules pour remplacer les types standards définis dans Contao. + + + Allowed types for selection + Types autorisés à la sélection + + + Select a restriction on files or folders - default is no restriction on files or folders. + Définir une restriction de fichiers ou de dossiers. Par défaut, pas de restriction. + + + Multiple selection + Sélection multiple + + + If selected, user will be able to select more than one item. + Si coché, l'utilisateur pourra sélectionner plusieurs éléments. + + + Allow files and folders + Autoriser fichiers et dossiers + + + Allow files only + Autoriser seulement les fichiers + + + Allow folders only + Autoriser seulement les dossiers + + + + \ No newline at end of file diff --git a/src/Resources/translations/tl_metamodel_dcasetting.fr.xlf b/src/Resources/translations/tl_metamodel_dcasetting.fr.xlf new file mode 100644 index 0000000..df11f4d --- /dev/null +++ b/src/Resources/translations/tl_metamodel_dcasetting.fr.xlf @@ -0,0 +1,156 @@ + + + + + File upload settings + Paramètres de transfert de fichiers + + + Widget mode + Mode du widget + + + With the mode the display type can be selected. + Le mode permet de sélectionner le type d'affichage. + + + Preserve existing files + Préserver les fichiers existants + + + Add a numeric suffix to the new file, if the file name already exists. + Ajouter un suffixe numérique au nouveau fichier si le nom de fichier existe déjà. + + + Use home directory + Utiliser le répertoire personnel + + + If this option is active, store the file in the home directory if there is an authenticated user. If the target folder configured too and the user is authenticated, so this folder is the base upload folder. + Enregistrer le fichier dans le dossier personnel de l'utilisateur s'il s'est authentifié. Si le dossier cible est également configuré et que l'utilisateur est authentifié, ce dossier est le dossier de téléchargement de base. + + + Target folder + Dossier cible + + + Please select the target folder from the files directory. If the home dir configured too and is not authenticated a user, so this folder is the base folder. + Sélectionner un dossier cible dans le répertoire des fichiers. Si un répertoire personnel est configuré mais que l'utilisateur n'est pas authentifié, ce dossier sera le dossier de base. + + + Extend folder + + + Here you can extend the base upload folder path. The Contao insert tags are supported to extend the path. + + + Deselect file + Désélectionner le fichier + + + If this option deselect file is active, then that file entry is remove from this model. + Si cette option est active, cette entrée de fichier sera supprimée de ce modèle. + + + Delete file + Supprimer le fichier + + + If this option delete file is active, then that file entry is remove from this model and from the file directory. + Si cette option est active, cette entrée de fichier sera supprimée de ce modèle et du dossier. + + + Normalize extend folder + + + Normalize the extend folder with an alias generator from the string util. + + + Normalize filename + + + Normalize the filename with an alias generator from the string util. + + + Prefix filename + Préfixe de nom de fichier + + + Here you can prefix the filename. The Contao insert tags are supported to prefix the filename. + Ajouter un préfixe aux noms de fichiers. Les insert tags de Contao peuvent être utilisés. + + + Postfix filename + Suffixe de nom de fichier + + + Here you can postfix the filename. The Contao insert tags are supported to postfix the filename. + Ajouter un postfixe aux noms de fichiers. Les insert tags de Contao peuvent être utilisés. + + + Thumbnail width and height + Hauteur et largeur de la vignette + + + Please enter either the image width, the image height or both measures to resize the image. If you leave both fields blank, the original image size will be displayed. + Indiquer la largeur de l'image, sa hauteur ou les deux pour la redimensionner. Si les deux champs sont vides, l'image s'affichera à sa taille originale. + + + Order by + Classer + + + Please choose the sort order. + Sélectionner l'ordre de classement. + + + Show files as list. + Afficher les fichiers en liste + + + Show files as sortable file list e.g. for downloads. + Afficher les fichiers sous forme de liste à classer (ex : pour des téléchargements) + + + Show files as sortable images e.g. for gallery. + Afficher les fichiers sous forme d'images à classer (ex : pour une galerie) + + + Single file upload [only for frontend editing] + Télécharger un fichier unique [réservé à l'édition en frontend] + + + Single file upload with show thumbnail [only for frontend editing] + Télécharger un fichier unique avec la vignette [réservé à l'édition en frontend] + + + Multiple file upload [only for frontend editing] + Téléchargment multiple [pour l'édition en frontend] + + + Multiple file upload with show thumbnail [only for frontend editing] + Téléchargment multiple avec vignette [pour l'édition en frontend] + + + File name (ascending) + Nom de fichier (ascendant) + + + File name (descending) + Nom de fichier (descendant) + + + Date (ascending) + Date (ascendante) + + + Date (descending) + Date (descendante) + + + Random order + Ordre aléatoire + + + + \ No newline at end of file diff --git a/src/Resources/translations/tl_metamodel_rendersetting.fr.xlf b/src/Resources/translations/tl_metamodel_rendersetting.fr.xlf new file mode 100644 index 0000000..203eb64 --- /dev/null +++ b/src/Resources/translations/tl_metamodel_rendersetting.fr.xlf @@ -0,0 +1,78 @@ + + + + + Enable as image field with thumbnail + Gérer comme image avec vignette + + + If selected, a thumbnail will be created for image files. + Cocher pour créer une vignette pour les fichiers image. + + + Order by + Classer par + + + Please choose the sort order. + Choisir l'ordre de classement. + + + Create link as file download or image lightbox + Créer un lien de téléchargement ou une image lightbox. + + + Wraps the item in a link that will show the fullscreen image or download the file. + Enveloppe l'élément dans un lien qui affichera l'image en plein écran ou téléchargera le fichier. + + + Image width and height + Largeur et hauteur de l'image + + + Please enter either the image width, the image height or both measures to resize the image. If you leave both fields blank, the original image size will be displayed. + Indiquer la largeur, la hauteur ou les deux pour redimensionner l'image. Si les deux sont vides, l'image sera affichée en taille originale. + + + Image placeholder + Image de remplacement + + + Select an image as a placeholder if no image is selected. + Sélectionner une image de remplacement tant qu'aucune image n'est sélectionnée. + + + Protected download + Téléchargement sécurisé + + + If this option is selected, the URL is only temporarily valid. + Si l'option est sélectionnée, l'url sera temporaire. + + + File name (ascending) + Nom de fichier (ascendant) + + + File name (descending) + Nom de fichier (descendant) + + + Date (ascending) + Date (ascendante) + + + Date (descending) + Date (descendante) + + + Random order + Ordre aléatoire + + + Manual sorting + Ordre manuel + + + + \ No newline at end of file From 6d718c751421238f18195b981c28fd3b814fff03 Mon Sep 17 00:00:00 2001 From: Mini Model Date: Fri, 13 Sep 2024 10:20:23 +0200 Subject: [PATCH 47/56] Updated translations from transifex. --- src/Resources/translations/tl_metamodel_dcasetting.fr.xlf | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Resources/translations/tl_metamodel_dcasetting.fr.xlf b/src/Resources/translations/tl_metamodel_dcasetting.fr.xlf index df11f4d..99f6282 100644 --- a/src/Resources/translations/tl_metamodel_dcasetting.fr.xlf +++ b/src/Resources/translations/tl_metamodel_dcasetting.fr.xlf @@ -39,9 +39,11 @@ Extend folder + Étendre le chemin du dossier Here you can extend the base upload folder path. The Contao insert tags are supported to extend the path. + Ici vous pouvez étendre le chemin du dossier de téléchargement de base. Les insert tags de Contao sont supportés. Deselect file @@ -61,15 +63,19 @@ Normalize extend folder + Normaliser l'extension du chemin du dossier Normalize the extend folder with an alias generator from the string util. + Normaliser l'extension de dossier avec un générateur d'alias à partir de la chaîne util. Normalize filename + Normaliser le nom de fichier. Normalize the filename with an alias generator from the string util. + Normaliser le nom de fichier avec un générateur d'alias à partir de la chaîne util. Prefix filename From 6d6b9490d878062868f8ccd74d34aa583377ee3a Mon Sep 17 00:00:00 2001 From: Ingolf Steinhardt Date: Fri, 8 Nov 2024 19:51:43 +0100 Subject: [PATCH 48/56] add_support_file-usage --- .composer-require-checker.json | 7 +- .phpcq.lock | 2 +- composer.json | 3 + src/EventListener/BuildAttributeListener.php | 10 +- src/FileUsage/FileUsageProvider.php | 174 +++++++++++++++++++ src/Resources/config/services.yml | 11 ++ 6 files changed, 201 insertions(+), 6 deletions(-) create mode 100644 src/FileUsage/FileUsageProvider.php diff --git a/.composer-require-checker.json b/.composer-require-checker.json index 22e99e2..68d9d79 100644 --- a/.composer-require-checker.json +++ b/.composer-require-checker.json @@ -6,6 +6,11 @@ "Contao\\ManagerPlugin\\Bundle\\Config\\BundleConfig", "Contao\\ManagerPlugin\\Bundle\\Parser\\ParserInterface", "Contao\\ManagerPlugin\\Routing\\RoutingPluginInterface", - "MetaModels\\ContaoFrontendEditingBundle\\MetaModelsContaoFrontendEditingBundle" + "MetaModels\\ContaoFrontendEditingBundle\\MetaModelsContaoFrontendEditingBundle", + "InspiredMinds\\ContaoFileUsage\\Provider\\FileUsageProviderInterface", + "InspiredMinds\\ContaoFileUsage\\Result\\FileTreeMultipleResult", + "InspiredMinds\\ContaoFileUsage\\Result\\FileTreeSingleResult", + "InspiredMinds\\ContaoFileUsage\\Result\\ResultInterface", + "InspiredMinds\\ContaoFileUsage\\Result\\ResultsCollection" ] } diff --git a/.phpcq.lock b/.phpcq.lock index 52ac3b1..c8607bd 100644 --- a/.phpcq.lock +++ b/.phpcq.lock @@ -1 +1 @@ -{"plugins":{"phpunit":{"api-version":"1.0.0","version":"1.0.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpunit/phpunit-1.0.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0"},"tool":{"phpunit":"^6.0 || ^7.0 || ^8.0 || ^9.0"}},"checksum":{"type":"sha-512","value":"c73f15658e3ba62665f09492ec91c3a6a715760bfaa88473a987538439fff442540148e086e46a6aa18ce55a3ea2fbf76caaa581384cb84a38859fcc609ae7e4"},"tools":{"phpunit":{"version":"9.6.20","url":"https://phar.phpunit.de/phpunit-9.6.20.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*","ext-json":"*","ext-libxml":"*","ext-mbstring":"*","ext-xml":"*","ext-xmlwriter":"*"}},"checksum":{"type":"sha-256","value":"4b49fdf48a3fdb5f4f4b5b18c43a542e75787edaf6a6ab39713f579d0a018210"},"signature":"https://phar.phpunit.de/phpunit-9.6.20.phar.asc"}},"composerLock":null},"psalm":{"api-version":"1.0.0","version":"1.2.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/psalm/psalm-1.2.0.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0","ext-dom":"*"},"tool":{"psalm":"^3.0 || ^4.0 || ^5.0"}},"checksum":{"type":"sha-512","value":"4a550c9226d7bca582d7c10bd87cce01190c96398936b1613421640c83df62ed1c6e0d44c1b39635414ea8cf4a892a6458d27590793238add24e7cb5547e6ffd"},"tools":{"psalm":{"version":"5.25.0","url":"https://github.com/vimeo/psalm/releases/download/5.25.0/psalm.phar","requirements":{"php":{"php":"^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0","ext-SimpleXML":"*","ext-ctype":"*","ext-dom":"*","ext-json":"*","ext-libxml":"*","ext-mbstring":"*","ext-tokenizer":"*"}},"checksum":null,"signature":"https://github.com/vimeo/psalm/releases/download/5.25.0/psalm.phar.asc"}},"composerLock":null},"composer-require-checker":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/composer-require-checker/composer-require-checker-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0"},"tool":{"composer-require-checker":"^3.8 || ^4.0"}},"checksum":{"type":"sha-512","value":"d5415bddfe024c5749d894034583882aee4e5c3e1087815d9fdd81cb5e71630f631a0e35de0ff84b97fbbf738c16ece5f83bd8c00695913eb846aa6f04577dc2"},"tools":{"composer-require-checker":{"version":"4.11.0","url":"https://github.com/maglnet/ComposerRequireChecker/releases/download/4.11.0/composer-require-checker.phar","requirements":{"php":{"php":"~8.2.0 || ~8.3.0","ext-phar":"*"}},"checksum":null,"signature":"https://github.com/maglnet/ComposerRequireChecker/releases/download/4.11.0/composer-require-checker.phar.asc"}},"composerLock":null},"phpmd":{"api-version":"1.0.0","version":"1.0.2.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpmd/phpmd-1.0.2.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpmd":"^2.6.1"}},"checksum":{"type":"sha-512","value":"f22280a6dec8dbdd2ec1d83b294f23237fe32c34f4a298e52038e0a7a0074d541635b2b488b1a6098a42d8418a6cd8eb804406ea82b91e362be2b5d11a0915b0"},"tools":{"phpmd":{"version":"2.15.0","url":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar","requirements":{"php":{"php":">=5.3.9","ext-xml":"*"}},"checksum":null,"signature":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar.asc"}},"composerLock":null},"phpcpd":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpcpd/phpcpd-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcpd":"^6.0"}},"checksum":{"type":"sha-512","value":"1189ce0bf3fade4cb4241f1d96f915ef8fc7651f4450dc79fdf464ee3d6be3009316f0d423ce2d4af9d76ad50807b7fdf4d77bfa6d9ee2c91d6eda32ea214433"},"tools":{"phpcpd":{"version":"6.0.3","url":"https://phar.phpunit.de/phpcpd-6.0.3.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*"}},"checksum":{"type":"sha-256","value":"2cbaea7cfda1bb4299d863eb075e977c3f49055dd16d88529fae5150d48a84cb"},"signature":"https://phar.phpunit.de/phpcpd-6.0.3.phar.asc"}},"composerLock":null},"phploc":{"api-version":"1.0.0","version":"1.0.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phploc/phploc-1.0.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*","ext-json":"*"},"tool":{"phploc":"^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0"}},"checksum":{"type":"sha-512","value":"f67b02d494796adf553cb3dd13ec06c1cb8e53c799954061749424251379541637538199afb3afa3c7a01cabd1cb6f1c53eb621f015dff9644c6c7cbf10c56d1"},"tools":{"phploc":{"version":"7.0.2","url":"https://phar.phpunit.de/phploc-7.0.2.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*","ext-json":"*"}},"checksum":{"type":"sha-256","value":"3d59778ec86faf25fd00e3a329b2f9ad4a3c751ca91601ea7dab70f887b0bf46"},"signature":"https://phar.phpunit.de/phploc-7.0.2.phar.asc"}},"composerLock":null},"phpcs":{"api-version":"1.0.0","version":"1.2.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpcs/phpcs-1.2.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcs":"^3.0 || ^2.0","phpcbf":"^3.0 || ^2.0"}},"checksum":{"type":"sha-512","value":"b6ed00306e76068a6af5e3b1dec837724f9e1900ef1049ce88e7ce195b0583524ca33a73613fba13244307a7ca853b6ddaa14ded69f651c3f184ac130bd1aaad"},"tools":{"phpcs":{"version":"3.10.2","url":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.10.2/phpcs.phar","requirements":{"php":{"php":">=5.4.0","ext-simplexml":"*","ext-tokenizer":"*","ext-xmlwriter":"*"}},"checksum":null,"signature":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.10.2/phpcs.phar.asc"},"phpcbf":{"version":"3.10.2","url":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.10.2/phpcbf.phar","requirements":{"php":{"php":">=5.4.0","ext-simplexml":"*","ext-tokenizer":"*","ext-xmlwriter":"*"}},"checksum":null,"signature":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.10.2/phpcbf.phar.asc"}},"composerLock":null},"composer-normalize":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/composer-normalize/composer-normalize-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-json":"*"},"tool":{"composer-normalize":"^2.1"}},"checksum":{"type":"sha-512","value":"d9abda440b85d501c58abf9c81bf76f417594b397129215ffa8b777e9bb5e5eda37d7661d661db3c8d11c24f20345bc6fbe56f013b3b9435d459d2b94f086e0f"},"tools":{"composer-normalize":{"version":"2.43.0","url":"https://github.com/ergebnis/composer-normalize/releases/download/2.43.0/composer-normalize.phar","requirements":{"php":{"php":"~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0","ext-json":"*"}},"checksum":null,"signature":"https://github.com/ergebnis/composer-normalize/releases/download/2.43.0/composer-normalize.phar.asc"}},"composerLock":null}},"tools":[]} \ No newline at end of file +{"plugins":{"phpunit":{"api-version":"1.0.0","version":"1.0.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpunit/phpunit-1.0.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0"},"tool":{"phpunit":"^6.0 || ^7.0 || ^8.0 || ^9.0"}},"checksum":{"type":"sha-512","value":"c73f15658e3ba62665f09492ec91c3a6a715760bfaa88473a987538439fff442540148e086e46a6aa18ce55a3ea2fbf76caaa581384cb84a38859fcc609ae7e4"},"tools":{"phpunit":{"version":"9.6.21","url":"https://phar.phpunit.de/phpunit-9.6.21.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*","ext-json":"*","ext-libxml":"*","ext-mbstring":"*","ext-xml":"*","ext-xmlwriter":"*"}},"checksum":{"type":"sha-256","value":"32bd24e7f93be631898ae61a5038f23da9ebd0e40a1124e65d9ee633b33f1815"},"signature":"https://phar.phpunit.de/phpunit-9.6.21.phar.asc"}},"composerLock":null},"psalm":{"api-version":"1.0.0","version":"1.2.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/psalm/psalm-1.2.0.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0","ext-dom":"*"},"tool":{"psalm":"^3.0 || ^4.0 || ^5.0"}},"checksum":{"type":"sha-512","value":"4a550c9226d7bca582d7c10bd87cce01190c96398936b1613421640c83df62ed1c6e0d44c1b39635414ea8cf4a892a6458d27590793238add24e7cb5547e6ffd"},"tools":{"psalm":{"version":"5.26.1","url":"https://github.com/vimeo/psalm/releases/download/5.26.1/psalm.phar","requirements":{"php":{"php":"^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0","ext-SimpleXML":"*","ext-ctype":"*","ext-dom":"*","ext-json":"*","ext-libxml":"*","ext-mbstring":"*","ext-tokenizer":"*"}},"checksum":null,"signature":"https://github.com/vimeo/psalm/releases/download/5.26.1/psalm.phar.asc"}},"composerLock":null},"composer-require-checker":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/composer-require-checker/composer-require-checker-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0"},"tool":{"composer-require-checker":"^3.8 || ^4.0"}},"checksum":{"type":"sha-512","value":"d5415bddfe024c5749d894034583882aee4e5c3e1087815d9fdd81cb5e71630f631a0e35de0ff84b97fbbf738c16ece5f83bd8c00695913eb846aa6f04577dc2"},"tools":{"composer-require-checker":{"version":"4.13.0","url":"https://github.com/maglnet/ComposerRequireChecker/releases/download/4.13.0/composer-require-checker.phar","requirements":{"php":{"php":"~8.2.0 || ~8.3.0 || ~8.4.0","ext-phar":"*"}},"checksum":null,"signature":"https://github.com/maglnet/ComposerRequireChecker/releases/download/4.13.0/composer-require-checker.phar.asc"}},"composerLock":null},"phpmd":{"api-version":"1.0.0","version":"1.0.2.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpmd/phpmd-1.0.2.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpmd":"^2.6.1"}},"checksum":{"type":"sha-512","value":"f22280a6dec8dbdd2ec1d83b294f23237fe32c34f4a298e52038e0a7a0074d541635b2b488b1a6098a42d8418a6cd8eb804406ea82b91e362be2b5d11a0915b0"},"tools":{"phpmd":{"version":"2.15.0","url":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar","requirements":{"php":{"php":">=5.3.9","ext-xml":"*"}},"checksum":null,"signature":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar.asc"}},"composerLock":null},"phpcpd":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpcpd/phpcpd-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcpd":"^6.0"}},"checksum":{"type":"sha-512","value":"1189ce0bf3fade4cb4241f1d96f915ef8fc7651f4450dc79fdf464ee3d6be3009316f0d423ce2d4af9d76ad50807b7fdf4d77bfa6d9ee2c91d6eda32ea214433"},"tools":{"phpcpd":{"version":"6.0.3","url":"https://phar.phpunit.de/phpcpd-6.0.3.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*"}},"checksum":{"type":"sha-256","value":"2cbaea7cfda1bb4299d863eb075e977c3f49055dd16d88529fae5150d48a84cb"},"signature":"https://phar.phpunit.de/phpcpd-6.0.3.phar.asc"}},"composerLock":null},"phploc":{"api-version":"1.0.0","version":"1.0.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phploc/phploc-1.0.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*","ext-json":"*"},"tool":{"phploc":"^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0"}},"checksum":{"type":"sha-512","value":"f67b02d494796adf553cb3dd13ec06c1cb8e53c799954061749424251379541637538199afb3afa3c7a01cabd1cb6f1c53eb621f015dff9644c6c7cbf10c56d1"},"tools":{"phploc":{"version":"7.0.2","url":"https://phar.phpunit.de/phploc-7.0.2.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*","ext-json":"*"}},"checksum":{"type":"sha-256","value":"3d59778ec86faf25fd00e3a329b2f9ad4a3c751ca91601ea7dab70f887b0bf46"},"signature":"https://phar.phpunit.de/phploc-7.0.2.phar.asc"}},"composerLock":null},"phpcs":{"api-version":"1.0.0","version":"1.2.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpcs/phpcs-1.2.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcs":"^3.0 || ^2.0","phpcbf":"^3.0 || ^2.0"}},"checksum":{"type":"sha-512","value":"b6ed00306e76068a6af5e3b1dec837724f9e1900ef1049ce88e7ce195b0583524ca33a73613fba13244307a7ca853b6ddaa14ded69f651c3f184ac130bd1aaad"},"tools":{"phpcs":{"version":"3.10.3","url":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.10.3/phpcs.phar","requirements":{"php":{"php":">=5.4.0","ext-simplexml":"*","ext-tokenizer":"*","ext-xmlwriter":"*"}},"checksum":null,"signature":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.10.3/phpcs.phar.asc"},"phpcbf":{"version":"3.10.3","url":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.10.3/phpcbf.phar","requirements":{"php":{"php":">=5.4.0","ext-simplexml":"*","ext-tokenizer":"*","ext-xmlwriter":"*"}},"checksum":null,"signature":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.10.3/phpcbf.phar.asc"}},"composerLock":null},"composer-normalize":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/composer-normalize/composer-normalize-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-json":"*"},"tool":{"composer-normalize":"^2.1"}},"checksum":{"type":"sha-512","value":"d9abda440b85d501c58abf9c81bf76f417594b397129215ffa8b777e9bb5e5eda37d7661d661db3c8d11c24f20345bc6fbe56f013b3b9435d459d2b94f086e0f"},"tools":{"composer-normalize":{"version":"2.44.0","url":"https://github.com/ergebnis/composer-normalize/releases/download/2.44.0/composer-normalize.phar","requirements":{"php":{"php":"~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0","ext-json":"*"}},"checksum":null,"signature":"https://github.com/ergebnis/composer-normalize/releases/download/2.44.0/composer-normalize.phar.asc"}},"composerLock":null}},"tools":[]} \ No newline at end of file diff --git a/composer.json b/composer.json index 13e84ed..09fa693 100644 --- a/composer.json +++ b/composer.json @@ -39,12 +39,15 @@ "symfony/cache": "^5.4", "symfony/config": "^5.4", "symfony/dependency-injection": "^5.4", + "symfony/http-foundation": "^5.4", "symfony/http-kernel": "^5.4", + "symfony/routing": "^5.4", "symfony/security-core": "^5.4", "symfony/translation-contracts": "^2.5.2" }, "require-dev": { "contao/manager-plugin": "^2.1", + "inspiredminds/contao-file-usage": "^3.0.1", "menatwork/contao-multicolumnwizard-bundle": "^3.4", "metamodels/contao-frontend-editing": "^2.3@dev", "phpcq/runner-bootstrap": "^1.0@dev" diff --git a/src/EventListener/BuildAttributeListener.php b/src/EventListener/BuildAttributeListener.php index bcbcf75..979c121 100644 --- a/src/EventListener/BuildAttributeListener.php +++ b/src/EventListener/BuildAttributeListener.php @@ -27,9 +27,6 @@ use MetaModels\DcGeneral\Events\MetaModel\BuildAttributeEvent; use ContaoCommunityAlliance\DcGeneral\DataDefinition\ContainerInterface; -/** - * Class Attribute - */ class BuildAttributeListener { /** @@ -42,7 +39,10 @@ class BuildAttributeListener public function buildAttribute(BuildAttributeEvent $event) { $attribute = $event->getAttribute(); - if (!($attribute instanceof File) || !$attribute->get('file_multiple')) { + if ( + !($attribute instanceof File) + || !$attribute->get('file_multiple') + ) { return; } @@ -59,6 +59,7 @@ public function buildAttribute(BuildAttributeEvent $event) ->setWidgetType('fileTreeOrder') ->setLabel($nameSort) ->setExtra(['tl_class' => 'hidden']); + $this->addAttributeToDefinition($container, $name); } @@ -75,6 +76,7 @@ private function addAttributeToDefinition(ContainerInterface $container, string if (!$container->hasDefinition('metamodels.file-attributes')) { $container->setDefinition('metamodels.file-attributes', new AttributeFileDefinition()); } + $definition = $container->getDefinition('metamodels.file-attributes'); assert($definition instanceof AttributeFileDefinition); diff --git a/src/FileUsage/FileUsageProvider.php b/src/FileUsage/FileUsageProvider.php new file mode 100644 index 0000000..9b1e007 --- /dev/null +++ b/src/FileUsage/FileUsageProvider.php @@ -0,0 +1,174 @@ + + * @copyright 2012-2024 The MetaModels team. + * @license https://github.com/MetaModels/attribute_file/blob/master/LICENSE LGPL-3.0-or-later + * @filesource + */ + +namespace MetaModels\AttributeFileBundle\FileUsage; + +use Contao\CoreBundle\Csrf\ContaoCsrfTokenManager; +use Contao\FilesModel; +use Contao\Model\Collection; +use Contao\StringUtil; +use ContaoCommunityAlliance\DcGeneral\Data\ModelId; +use InspiredMinds\ContaoFileUsage\Provider\FileUsageProviderInterface; +use InspiredMinds\ContaoFileUsage\Result\ResultInterface; +use InspiredMinds\ContaoFileUsage\Result\ResultsCollection; +use MetaModels\AttributeFileBundle\Attribute\File; +use MetaModels\CoreBundle\FileUsage\MetaModelsMultipleResult; +use MetaModels\CoreBundle\FileUsage\MetaModelsSingleResult; +use MetaModels\IFactory; +use MetaModels\IMetaModel; +use Symfony\Component\HttpFoundation\RequestStack; +use Symfony\Component\Routing\Generator\UrlGeneratorInterface; + +/** + * This class supports the Contao extension 'file usage'. + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +class FileUsageProvider implements FileUsageProviderInterface +{ + private string $refererId = ''; + + public function __construct( + private readonly IFactory $factory, + private readonly UrlGeneratorInterface $urlGenerator, + private readonly RequestStack $requestStack, + private readonly ContaoCsrfTokenManager $csrfTokenManager, + private readonly string $csrfTokenName, + ) { + } + + public function find(): ResultsCollection + { + $this->refererId = $this->requestStack->getCurrentRequest()?->attributes->get('_contao_referer_id') ?? ''; + + $allTables = $this->factory->collectNames(); + + $collection = new ResultsCollection(); + foreach ($allTables as $table) { + $collection->mergeCollection($this->processTable($table)); + } + + return $collection; + } + + private function processTable(string $table): ResultsCollection + { + $collection = new ResultsCollection(); + $metaModel = $this->factory->getMetaModel($table); + assert($metaModel instanceof IMetaModel); + + $allIds = $metaModel->getIdsFromFilter($metaModel->getEmptyFilter()); + foreach ($metaModel->getAttributes() as $attribute) { + if (!$attribute instanceof File) { + continue; + } + + $attributeName = $attribute->getColName(); + + $allData = $attribute->getDataFor($allIds); + if ($attribute->get('file_multiple')) { + foreach ($allData as $itemId => $selectedFiles) { + $collection->mergeCollection( + $this->addMultipleFileReferences($selectedFiles['value'], $table, $attributeName, $itemId) + ); + } + continue; + } + + foreach ($allData as $itemId => $selectedFiles) { + $collection->addResult( + $selectedFiles['value'][0], + $this->createFileResult($table, $attributeName, $itemId, false) + ); + } + } + + return $collection; + } + + private function addMultipleFileReferences( + array $fileUuids, + string $tableName, + string $attributeName, + string $itemId, + ): ResultsCollection { + $collection = new ResultsCollection(); + foreach ($fileUuids as $uuid) { + $collection->addResult($uuid, $this->createFileResult($tableName, $attributeName, $itemId, true)); + // Also add children, if the reference is a folder. + $file = FilesModel::findByUuid($uuid); + if (null !== $file && 'folder' === $file->type) { + $files = FilesModel::findByPid($uuid); + if (null === $files) { + continue; + } + assert($files instanceof Collection); + foreach ($files as $child) { + $collection->addResult( + StringUtil::binToUuid($child->uuid), + $this->createFileResult($tableName, $attributeName, $itemId, true) + ); + } + } + } + + return $collection; + } + + private function createFileResult( + string $tableName, + string $attributeName, + string $itemId, + bool $isMultiple + ): ResultInterface { + if ($isMultiple) { + return new MetaModelsMultipleResult( + $tableName, + $attributeName, + $itemId, + $this->urlGenerator->generate( + 'metamodels.metamodel', + [ + 'tableName' => $tableName, + 'act' => 'edit', + 'id' => ModelId::fromValues($tableName, $itemId)->getSerialized(), + 'ref' => $this->refererId, + 'rt' => $this->csrfTokenManager->getToken($this->csrfTokenName)->getValue(), + ] + ) + ); + } + + return new MetaModelsSingleResult( + $tableName, + $attributeName, + $itemId, + $this->urlGenerator->generate( + 'metamodels.metamodel', + [ + 'tableName' => $tableName, + 'act' => 'edit', + 'id' => ModelId::fromValues($tableName, $itemId)->getSerialized(), + 'ref' => $this->refererId, + 'rt' => $this->csrfTokenManager->getToken($this->csrfTokenName)->getValue(), + ] + ) + ); + } +} diff --git a/src/Resources/config/services.yml b/src/Resources/config/services.yml index 9c59da6..d055001 100644 --- a/src/Resources/config/services.yml +++ b/src/Resources/config/services.yml @@ -32,3 +32,14 @@ services: - '@metamodels.table_manipulator' tags: - name: contao.migration + +# MetaModels\AttributeFileBundle\FileUsage\FileUsageProvider: +# public: true +# arguments: +# $factory: '@metamodels.factory' +# $urlGenerator: '@router' +# $requestStack: '@request_stack' +# $csrfTokenManager: '@contao.csrf.token_manager' +# $csrfTokenName: '%contao.csrf_token_name%' +# tags: +# - { name: contao_file_usage.provider } From 47061f579d12647f9426a3ea5bef1f2319e3a7f6 Mon Sep 17 00:00:00 2001 From: Ingolf Steinhardt Date: Fri, 8 Nov 2024 20:27:31 +0100 Subject: [PATCH 49/56] add_support_file-usage --- src/FileUsage/FileUsageProvider.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/FileUsage/FileUsageProvider.php b/src/FileUsage/FileUsageProvider.php index 9b1e007..a28b559 100644 --- a/src/FileUsage/FileUsageProvider.php +++ b/src/FileUsage/FileUsageProvider.php @@ -92,6 +92,9 @@ private function processTable(string $table): ResultsCollection } foreach ($allData as $itemId => $selectedFiles) { + if([] === $selectedFiles['value']) { + continue; + } $collection->addResult( $selectedFiles['value'][0], $this->createFileResult($table, $attributeName, $itemId, false) From 7ced914297025128fa22daa65fd12dc0154b3a6c Mon Sep 17 00:00:00 2001 From: Ingolf Steinhardt Date: Thu, 9 Jan 2025 09:37:43 +0100 Subject: [PATCH 50/56] Add search file --- psalm.xml | 19 +- src/Attribute/File.php | 80 +++++-- .../BuildFrontendUploadListener.php | 1 - src/FileUsage/FileUsageProvider.php | 2 +- .../contao/dca/tl_metamodel_dcasetting.php | 3 + tests/Attribute/FileTest.php | 198 ++++++++++++++++-- 6 files changed, 251 insertions(+), 52 deletions(-) diff --git a/psalm.xml b/psalm.xml index aa1a5c1..cd35238 100644 --- a/psalm.xml +++ b/psalm.xml @@ -1,16 +1,23 @@ - + + + + + + + + diff --git a/src/Attribute/File.php b/src/Attribute/File.php index 59d6caf..a3bdb6f 100644 --- a/src/Attribute/File.php +++ b/src/Attribute/File.php @@ -45,6 +45,17 @@ use MetaModels\IMetaModel; use MetaModels\Render\Template; +use function array_key_exists; +use function array_map; +use function array_merge; +use function array_values; +use function is_array; +use function serialize; +use function sprintf; +use function str_replace; +use function trigger_error; +use function trim; + /** * This is the MetaModel attribute class for handling file fields. * @@ -147,7 +158,7 @@ public function __construct( if (null === $stringUtil) { // @codingStandardsIgnoreStart - @\trigger_error( + @trigger_error( '"stringUtil"" is missing. It has to be passed in the constructor.' . 'Fallback will get removed in MetaModels 3.0', E_USER_DEPRECATED @@ -160,7 +171,7 @@ public function __construct( if (null === $validator) { // @codingStandardsIgnoreStart - @\trigger_error( + @trigger_error( '"validator"" is missing. It has to be passed in the constructor.' . 'Fallback will get removed in MetaModels 3.0', E_USER_DEPRECATED @@ -173,7 +184,7 @@ public function __construct( if (null === $fileRepository) { // @codingStandardsIgnoreStart - @\trigger_error( + @trigger_error( '"fileRepository"" is missing. It has to be passed in the constructor.' . 'Fallback will get removed in MetaModels 3.0', E_USER_DEPRECATED @@ -186,7 +197,7 @@ public function __construct( if (null === $config) { // @codingStandardsIgnoreStart - @\trigger_error( + @trigger_error( '"config"" is missing. It has to be passed in the constructor.' . 'Fallback will get removed in MetaModels 3.0', E_USER_DEPRECATED @@ -224,11 +235,11 @@ public function destroyAUX() // Try to delete the column. If it does not exist as we can assume it has been deleted already then. $tableColumns = $this->connection->createSchemaManager()->listTableColumns($metaModel); - if (($colName = $this->getColName()) && \array_key_exists($colName, $tableColumns)) { + if (($colName = $this->getColName()) && array_key_exists($colName, $tableColumns)) { $this->tableManipulator->dropColumn($metaModel, $colName); } - if (\array_key_exists($colName . '__sort', $tableColumns)) { + if (array_key_exists($colName . '__sort', $tableColumns)) { $this->tableManipulator->dropColumn($metaModel, $colName . '__sort'); } } @@ -254,26 +265,53 @@ public function initializeAUX() } /** + * Search for file names or UUIDs. + * Find items if one or more files are stored (serialised array) or the parent folder has been selected. + * * {@inheritdoc} */ - public function searchFor($strPattern) + public function searchFor($strPattern): ?array { $subSelect = $this->connection->createQueryBuilder(); $subSelect - ->select('f.uuid') - ->from('tl_files', 'f') - ->where($subSelect->expr()->like('f.path', ':value')); + ->select('f.uuid', 'f.pid') + ->from('tl_files', 'f'); + + if (Validator::isUuid($uuid = trim($strPattern, '*'))) { + $subSelect + ->where(('f.uuid = :value')) + ->setParameter('value', StringUtil::uuidToBin($uuid)); + } else { + $subSelect + ->where($subSelect->expr()->like('f.name', ':value')) + ->setParameter('value', str_replace(['*', '?'], ['%', '_'], $strPattern)); + } + + if ([] === ($subResults = $subSelect->executeQuery()->fetchAllAssociative())) { + return []; + } + $builder = $this->connection->createQueryBuilder(); $builder ->select('t.id') - ->from($this->getMetaModel()->getTableName(), 't') - ->where($builder->expr()->in($this->getColName(), $subSelect->getSQL())) - ->setParameter('value', \str_replace(['*', '?'], ['%', '_'], $strPattern)); + ->from($this->getMetaModel()->getTableName(), 't'); + + $uuids = []; + foreach ($subResults as $subResult) { + $uuids[$subResult['pid']] = $subResult['pid']; + $uuids[$subResult['uuid']] = $subResult['uuid']; + } + $colName = $this->getColName(); + foreach (array_values($uuids) as $key => $uuid) { + $builder + ->orWhere(sprintf('t.%s LIKE :value_%s', $colName, $key)) + ->setParameter('value_' . $key, '%' . $uuid . '%'); + } $statement = $builder->executeQuery(); // Return value list as list, parent function wants a list so we make a cast. - return \array_map(static fn(mixed $value) => (string) $value, $statement->fetchFirstColumn()); + return array_map(static fn(mixed $value) => (string) $value, $statement->fetchFirstColumn()); } /** @@ -330,7 +368,7 @@ public function getDataFor($arrIds) if (isset($row['sort'])) { // @codingStandardsIgnoreStart - @\trigger_error( + @trigger_error( 'The sort key from the attribute file is deprecated since 2.1 and where removed in 3.0' . 'Use the key bin_sorted', E_USER_DEPRECATED @@ -364,7 +402,7 @@ public function setDataFor($arrValues) // Check single file or multiple file. if ($this->get('file_multiple')) { - $files = \serialize($files); + $files = serialize($files); } else { $files = $files[0] ?? null; } @@ -393,7 +431,7 @@ public function getFilterOptions($idList, $usedOnly, &$arrCount = null) */ public function getAttributeSettingNames() { - return \array_merge( + return array_merge( parent::getAttributeSettingNames(), [ 'file_multiple', @@ -434,7 +472,7 @@ public function serializeData($mixValues) // Check single file or multiple file. if ($this->get('file_multiple')) { - return \serialize($data); + return serialize($data); } return $data[0] ?? ''; @@ -580,7 +618,7 @@ protected function prepareTemplate(Template $objTemplate, $arrRowData, $objSetti ->setBaseLanguage($this->getMetaModel()->getActiveLanguage()) ->setFallbackLanguage($this->getMetaModel()->getFallbackLanguage()) ->setLightboxId( - \sprintf( + sprintf( '%s.%s.%s', $this->getMetaModel()->getTableName(), (string) ($objSettings->get('id') ?? ''), @@ -593,7 +631,7 @@ protected function prepareTemplate(Template $objTemplate, $arrRowData, $objSetti $toolbox->setAcceptedExtensions($this->get('file_validFileTypes')); } - if (\is_array($imageSize = $objSettings->get('file_imageSize'))) { + if (is_array($imageSize = $objSettings->get('file_imageSize'))) { $toolbox->setResizeImages($imageSize); } @@ -615,7 +653,7 @@ protected function prepareTemplate(Template $objTemplate, $arrRowData, $objSetti private function fetchServiceForFallback(string $parameter, string $serviceName): null|object { // @codingStandardsIgnoreStart - @\trigger_error( + @trigger_error( '"'. $parameter . '" is missing. It has to be passed in the constructor.' . 'Fallback will get removed in MetaModels 3.0', E_USER_DEPRECATED diff --git a/src/EventListener/BuildFrontendUploadListener.php b/src/EventListener/BuildFrontendUploadListener.php index caeedfd..f616d08 100644 --- a/src/EventListener/BuildFrontendUploadListener.php +++ b/src/EventListener/BuildFrontendUploadListener.php @@ -24,7 +24,6 @@ use ContaoCommunityAlliance\DcGeneral\Contao\RequestScopeDeterminator; use ContaoCommunityAlliance\DcGeneral\Contao\RequestScopeDeterminatorAwareTrait; -use ContaoCommunityAlliance\DcGeneral\InputProviderInterface; use Contao\CoreBundle\InsertTag\InsertTagParser; use Contao\FrontendUser; use MetaModels\AttributeFileBundle\Attribute\File; diff --git a/src/FileUsage/FileUsageProvider.php b/src/FileUsage/FileUsageProvider.php index a28b559..1b167a2 100644 --- a/src/FileUsage/FileUsageProvider.php +++ b/src/FileUsage/FileUsageProvider.php @@ -92,7 +92,7 @@ private function processTable(string $table): ResultsCollection } foreach ($allData as $itemId => $selectedFiles) { - if([] === $selectedFiles['value']) { + if ([] === $selectedFiles['value']) { continue; } $collection->addResult( diff --git a/src/Resources/contao/dca/tl_metamodel_dcasetting.php b/src/Resources/contao/dca/tl_metamodel_dcasetting.php index 56ed2a1..ba69c80 100644 --- a/src/Resources/contao/dca/tl_metamodel_dcasetting.php +++ b/src/Resources/contao/dca/tl_metamodel_dcasetting.php @@ -33,6 +33,9 @@ 'functions' => [ 'mandatory', 'file_widgetMode' + ], + 'overview' => [ + 'searchable', ] ]; diff --git a/tests/Attribute/FileTest.php b/tests/Attribute/FileTest.php index fa7f0ae..d434ff5 100644 --- a/tests/Attribute/FileTest.php +++ b/tests/Attribute/FileTest.php @@ -24,6 +24,7 @@ use Contao\CoreBundle\Framework\Adapter; use Contao\CoreBundle\Image\ImageFactoryInterface; +use Contao\StringUtil; use Doctrine\DBAL\Connection; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Query\Expression\ExpressionBuilder; @@ -40,6 +41,8 @@ * Unit tests to test class File. * * @covers \MetaModels\AttributeFileBundle\Attribute\File + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class FileTest extends TestCase { @@ -216,50 +219,76 @@ public function testEmptyValues() ); self::assertEquals( ['bin' => [], 'value' => [], 'path' => [], 'meta' => []], - $file->widgetToValue(array(), 1) + $file->widgetToValue([], 1) ); } /** - * Test the search for method. - * - * @return void + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ - public function testSearchFor() + public function testSearchForFileName() { - $metaModel = $this->mockMetaModel('mm_test', 'en'); - $connection = $this->mockConnection(['createQueryBuilder']); - $manipulator = $this->mockTableManipulator($connection); + $metaModel = $this->mockMetaModel('mm_test', 'en'); + $connection = $this->mockConnection(['createQueryBuilder']); + $manipulator = $this->mockTableManipulator($connection); - $result = $this + $result1 = $this ->getMockBuilder(Result::class) ->disableOriginalConstructor() - ->onlyMethods(['fetchFirstColumn']) + ->onlyMethods(['fetchAllAssociative']) ->getMock(); - $result + $result1 ->expects(self::once()) - ->method('fetchFirstColumn') - ->willReturn(['1', '2', '3', '4', '5']); + ->method('fetchAllAssociative') + ->willReturn( + [ + [ + 'pid' => StringUtil::uuidToBin('b4a3201a-bef2-153c-85ae-66930f01feda'), + 'uuid' => StringUtil::uuidToBin('e68feb56-339b-1eb2-a675-7a5107362e40'), + ], + [ + 'pid' => StringUtil::uuidToBin('b4a3201a-bef2-153c-85ae-66930f01feda'), + 'uuid' => StringUtil::uuidToBin('6e38171a-47c3-1e91-83b4-b759ede063be'), + ], + [ + 'pid' => StringUtil::uuidToBin('314f23ae-30ce-11bb-bbd3-2009656507f7'), + 'uuid' => StringUtil::uuidToBin('0e9e4236-2468-1bfa-89f8-ca45602bec2a'), + ], + ] + ); $builder1 = $this ->getMockBuilder(QueryBuilder::class) ->setConstructorArgs([$connection]) - ->onlyMethods(['expr', 'getSQL']) + ->onlyMethods(['executeQuery', 'expr']) ->getMock(); $builder1->expects(self::once())->method('expr')->willReturn(new ExpressionBuilder($connection)); $builder1 ->expects(self::once()) - ->method('getSQL') - ->willReturn('SELECT f.uuid FROM tl_files f WHERE f.path LIKE :value'); + ->method('executeQuery') + ->willReturn($result1); + + $result2 = $this + ->getMockBuilder(Result::class) + ->disableOriginalConstructor() + ->onlyMethods(['fetchFirstColumn']) + ->getMock(); + $result2 + ->expects(self::once()) + ->method('fetchFirstColumn') + ->willReturn([1, 2, 3, 4, 5]); $builder2 = $this ->getMockBuilder(QueryBuilder::class) ->setConstructorArgs([$connection]) - ->onlyMethods(['executeQuery', 'expr']) + ->onlyMethods(['executeQuery']) ->getMock(); - $builder2->expects(self::once())->method('expr')->willReturn(new ExpressionBuilder($connection)); - $builder2->expects(self::once())->method('executeQuery')->willReturn($result); + + $builder2 + ->expects(self::once()) + ->method('executeQuery') + ->willReturn($result2); $connection ->expects(self::exactly(2)) @@ -283,12 +312,135 @@ public function testSearchFor() self::assertSame(['1', '2', '3', '4', '5'], $file->searchFor('*test?value')); - /** @var QueryBuilder $builder2 */ self::assertSame( - 'SELECT t.id FROM mm_test t ' . - 'WHERE file_attribute IN (SELECT f.uuid FROM tl_files f WHERE f.path LIKE :value)', + 'SELECT f.uuid, f.pid FROM tl_files f WHERE f.name LIKE :value', + $builder1->getSQL() + ); + self::assertSame(['value' => '%test_value'], $builder1->getParameters()); + + self::assertSame( + 'SELECT t.id FROM mm_test t WHERE ' . + '(t.file_attribute LIKE :value_0)' . + ' OR (t.file_attribute LIKE :value_1)' . + ' OR (t.file_attribute LIKE :value_2)' . + ' OR (t.file_attribute LIKE :value_3)' . + ' OR (t.file_attribute LIKE :value_4)', + $builder2->getSQL() + ); + self::assertSame( + [ + 'value_0' => '%' . StringUtil::uuidToBin('b4a3201a-bef2-153c-85ae-66930f01feda') . '%', + 'value_1' => '%' . StringUtil::uuidToBin('e68feb56-339b-1eb2-a675-7a5107362e40') . '%', + 'value_2' => '%' . StringUtil::uuidToBin('6e38171a-47c3-1e91-83b4-b759ede063be') . '%', + 'value_3' => '%' . StringUtil::uuidToBin('314f23ae-30ce-11bb-bbd3-2009656507f7') . '%', + 'value_4' => '%' . StringUtil::uuidToBin('0e9e4236-2468-1bfa-89f8-ca45602bec2a') . '%', + ], + $builder2->getParameters() + ); + } + + /** + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + */ + public function testSearchForUuid() + { + $metaModel = $this->mockMetaModel('mm_test', 'en'); + $connection = $this->mockConnection(['createQueryBuilder']); + $manipulator = $this->mockTableManipulator($connection); + + $result1 = $this + ->getMockBuilder(Result::class) + ->disableOriginalConstructor() + ->onlyMethods(['fetchAllAssociative']) + ->getMock(); + $result1 + ->expects(self::once()) + ->method('fetchAllAssociative') + ->willReturn( + [ + [ + 'pid' => StringUtil::uuidToBin('b4a3201a-bef2-153c-85ae-66930f01feda'), + 'uuid' => StringUtil::uuidToBin('e68feb56-339b-1eb2-a675-7a5107362e40'), + ], + ] + ); + + $builder1 = $this + ->getMockBuilder(QueryBuilder::class) + ->setConstructorArgs([$connection]) + ->onlyMethods(['executeQuery']) + ->getMock(); + + $builder1 + ->expects(self::once()) + ->method('executeQuery') + ->willReturn($result1); + + $result2 = $this + ->getMockBuilder(Result::class) + ->disableOriginalConstructor() + ->onlyMethods(['fetchFirstColumn']) + ->getMock(); + $result2 + ->expects(self::once()) + ->method('fetchFirstColumn') + ->willReturn([1, 2, 3, 4, 5]); + + $builder2 = $this + ->getMockBuilder(QueryBuilder::class) + ->setConstructorArgs([$connection]) + ->onlyMethods(['executeQuery']) + ->getMock(); + + $builder2 + ->expects(self::once()) + ->method('executeQuery') + ->willReturn($result2); + + $connection + ->expects(self::exactly(2)) + ->method('createQueryBuilder') + ->willReturnOnConsecutiveCalls($builder1, $builder2); + + $file = new File( + $metaModel, + [ + 'colname' => 'file_attribute', + 'file_multiple' => false + ], + $connection, + $manipulator, + $this->mockToolboxFile(), + $this->mockStringUtil(), + $this->mockValidator(), + $this->mockFileRepository(), + $this->mockConfig() + ); + + self::assertSame(['1', '2', '3', '4', '5'], $file->searchFor('*e68feb56-339b-1eb2-a675-7a5107362e40*')); + + self::assertSame( + ['value' => StringUtil::uuidToBin('e68feb56-339b-1eb2-a675-7a5107362e40')], + $builder1->getParameters() + ); + self::assertSame( + 'SELECT f.uuid, f.pid FROM tl_files f WHERE f.uuid = :value', + $builder1->getSQL() + ); + + self::assertSame( + 'SELECT t.id FROM mm_test t WHERE ' . + '(t.file_attribute LIKE :value_0)' . + ' OR (t.file_attribute LIKE :value_1)', $builder2->getSQL() ); - self::assertSame(['value' => '%test_value'], $builder2->getParameters()); + + self::assertSame( + [ + 'value_0' => '%' . StringUtil::uuidToBin('b4a3201a-bef2-153c-85ae-66930f01feda') . '%', + 'value_1' => '%' . StringUtil::uuidToBin('e68feb56-339b-1eb2-a675-7a5107362e40') . '%', + ], + $builder2->getParameters() + ); } } From 7712debfc46658cabd9d53f2701c5a3c48bbb3a4 Mon Sep 17 00:00:00 2001 From: Ingolf Steinhardt Date: Sun, 2 Mar 2025 16:03:24 +0100 Subject: [PATCH 51/56] Delete language files --- .phpcq.lock | 2 +- src/Resources/contao/languages/de/default.php | 25 -------- .../languages/de/tl_metamodel_attribute.php | 40 ------------ .../languages/de/tl_metamodel_dcasetting.php | 63 ------------------- .../de/tl_metamodel_rendersetting.php | 43 ------------- .../languages/el/tl_metamodel_attribute.php | 32 ---------- .../languages/el/tl_metamodel_dcasetting.php | 32 ---------- .../el/tl_metamodel_rendersetting.php | 27 -------- .../languages/et/tl_metamodel_attribute.php | 19 ------ .../languages/et/tl_metamodel_dcasetting.php | 30 --------- .../et/tl_metamodel_rendersetting.php | 21 ------- .../languages/fr/tl_metamodel_attribute.php | 35 ----------- .../languages/fr/tl_metamodel_dcasetting.php | 32 ---------- .../fr/tl_metamodel_rendersetting.php | 27 -------- .../languages/it/tl_metamodel_attribute.php | 33 ---------- .../languages/it/tl_metamodel_dcasetting.php | 32 ---------- .../it/tl_metamodel_rendersetting.php | 27 -------- .../languages/rm/tl_metamodel_attribute.php | 32 ---------- .../languages/rm/tl_metamodel_dcasetting.php | 32 ---------- .../rm/tl_metamodel_rendersetting.php | 27 -------- .../languages/ru/tl_metamodel_attribute.php | 36 ----------- .../languages/ru/tl_metamodel_dcasetting.php | 33 ---------- .../ru/tl_metamodel_rendersetting.php | 39 ------------ 23 files changed, 1 insertion(+), 718 deletions(-) delete mode 100644 src/Resources/contao/languages/de/default.php delete mode 100644 src/Resources/contao/languages/de/tl_metamodel_attribute.php delete mode 100644 src/Resources/contao/languages/de/tl_metamodel_dcasetting.php delete mode 100644 src/Resources/contao/languages/de/tl_metamodel_rendersetting.php delete mode 100644 src/Resources/contao/languages/el/tl_metamodel_attribute.php delete mode 100644 src/Resources/contao/languages/el/tl_metamodel_dcasetting.php delete mode 100644 src/Resources/contao/languages/el/tl_metamodel_rendersetting.php delete mode 100644 src/Resources/contao/languages/et/tl_metamodel_attribute.php delete mode 100644 src/Resources/contao/languages/et/tl_metamodel_dcasetting.php delete mode 100644 src/Resources/contao/languages/et/tl_metamodel_rendersetting.php delete mode 100644 src/Resources/contao/languages/fr/tl_metamodel_attribute.php delete mode 100644 src/Resources/contao/languages/fr/tl_metamodel_dcasetting.php delete mode 100644 src/Resources/contao/languages/fr/tl_metamodel_rendersetting.php delete mode 100644 src/Resources/contao/languages/it/tl_metamodel_attribute.php delete mode 100644 src/Resources/contao/languages/it/tl_metamodel_dcasetting.php delete mode 100644 src/Resources/contao/languages/it/tl_metamodel_rendersetting.php delete mode 100644 src/Resources/contao/languages/rm/tl_metamodel_attribute.php delete mode 100644 src/Resources/contao/languages/rm/tl_metamodel_dcasetting.php delete mode 100644 src/Resources/contao/languages/rm/tl_metamodel_rendersetting.php delete mode 100644 src/Resources/contao/languages/ru/tl_metamodel_attribute.php delete mode 100644 src/Resources/contao/languages/ru/tl_metamodel_dcasetting.php delete mode 100644 src/Resources/contao/languages/ru/tl_metamodel_rendersetting.php diff --git a/.phpcq.lock b/.phpcq.lock index c8607bd..8dde433 100644 --- a/.phpcq.lock +++ b/.phpcq.lock @@ -1 +1 @@ -{"plugins":{"phpunit":{"api-version":"1.0.0","version":"1.0.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpunit/phpunit-1.0.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0"},"tool":{"phpunit":"^6.0 || ^7.0 || ^8.0 || ^9.0"}},"checksum":{"type":"sha-512","value":"c73f15658e3ba62665f09492ec91c3a6a715760bfaa88473a987538439fff442540148e086e46a6aa18ce55a3ea2fbf76caaa581384cb84a38859fcc609ae7e4"},"tools":{"phpunit":{"version":"9.6.21","url":"https://phar.phpunit.de/phpunit-9.6.21.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*","ext-json":"*","ext-libxml":"*","ext-mbstring":"*","ext-xml":"*","ext-xmlwriter":"*"}},"checksum":{"type":"sha-256","value":"32bd24e7f93be631898ae61a5038f23da9ebd0e40a1124e65d9ee633b33f1815"},"signature":"https://phar.phpunit.de/phpunit-9.6.21.phar.asc"}},"composerLock":null},"psalm":{"api-version":"1.0.0","version":"1.2.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/psalm/psalm-1.2.0.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0","ext-dom":"*"},"tool":{"psalm":"^3.0 || ^4.0 || ^5.0"}},"checksum":{"type":"sha-512","value":"4a550c9226d7bca582d7c10bd87cce01190c96398936b1613421640c83df62ed1c6e0d44c1b39635414ea8cf4a892a6458d27590793238add24e7cb5547e6ffd"},"tools":{"psalm":{"version":"5.26.1","url":"https://github.com/vimeo/psalm/releases/download/5.26.1/psalm.phar","requirements":{"php":{"php":"^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0","ext-SimpleXML":"*","ext-ctype":"*","ext-dom":"*","ext-json":"*","ext-libxml":"*","ext-mbstring":"*","ext-tokenizer":"*"}},"checksum":null,"signature":"https://github.com/vimeo/psalm/releases/download/5.26.1/psalm.phar.asc"}},"composerLock":null},"composer-require-checker":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/composer-require-checker/composer-require-checker-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0"},"tool":{"composer-require-checker":"^3.8 || ^4.0"}},"checksum":{"type":"sha-512","value":"d5415bddfe024c5749d894034583882aee4e5c3e1087815d9fdd81cb5e71630f631a0e35de0ff84b97fbbf738c16ece5f83bd8c00695913eb846aa6f04577dc2"},"tools":{"composer-require-checker":{"version":"4.13.0","url":"https://github.com/maglnet/ComposerRequireChecker/releases/download/4.13.0/composer-require-checker.phar","requirements":{"php":{"php":"~8.2.0 || ~8.3.0 || ~8.4.0","ext-phar":"*"}},"checksum":null,"signature":"https://github.com/maglnet/ComposerRequireChecker/releases/download/4.13.0/composer-require-checker.phar.asc"}},"composerLock":null},"phpmd":{"api-version":"1.0.0","version":"1.0.2.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpmd/phpmd-1.0.2.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpmd":"^2.6.1"}},"checksum":{"type":"sha-512","value":"f22280a6dec8dbdd2ec1d83b294f23237fe32c34f4a298e52038e0a7a0074d541635b2b488b1a6098a42d8418a6cd8eb804406ea82b91e362be2b5d11a0915b0"},"tools":{"phpmd":{"version":"2.15.0","url":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar","requirements":{"php":{"php":">=5.3.9","ext-xml":"*"}},"checksum":null,"signature":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar.asc"}},"composerLock":null},"phpcpd":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpcpd/phpcpd-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcpd":"^6.0"}},"checksum":{"type":"sha-512","value":"1189ce0bf3fade4cb4241f1d96f915ef8fc7651f4450dc79fdf464ee3d6be3009316f0d423ce2d4af9d76ad50807b7fdf4d77bfa6d9ee2c91d6eda32ea214433"},"tools":{"phpcpd":{"version":"6.0.3","url":"https://phar.phpunit.de/phpcpd-6.0.3.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*"}},"checksum":{"type":"sha-256","value":"2cbaea7cfda1bb4299d863eb075e977c3f49055dd16d88529fae5150d48a84cb"},"signature":"https://phar.phpunit.de/phpcpd-6.0.3.phar.asc"}},"composerLock":null},"phploc":{"api-version":"1.0.0","version":"1.0.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phploc/phploc-1.0.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*","ext-json":"*"},"tool":{"phploc":"^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0"}},"checksum":{"type":"sha-512","value":"f67b02d494796adf553cb3dd13ec06c1cb8e53c799954061749424251379541637538199afb3afa3c7a01cabd1cb6f1c53eb621f015dff9644c6c7cbf10c56d1"},"tools":{"phploc":{"version":"7.0.2","url":"https://phar.phpunit.de/phploc-7.0.2.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*","ext-json":"*"}},"checksum":{"type":"sha-256","value":"3d59778ec86faf25fd00e3a329b2f9ad4a3c751ca91601ea7dab70f887b0bf46"},"signature":"https://phar.phpunit.de/phploc-7.0.2.phar.asc"}},"composerLock":null},"phpcs":{"api-version":"1.0.0","version":"1.2.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpcs/phpcs-1.2.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcs":"^3.0 || ^2.0","phpcbf":"^3.0 || ^2.0"}},"checksum":{"type":"sha-512","value":"b6ed00306e76068a6af5e3b1dec837724f9e1900ef1049ce88e7ce195b0583524ca33a73613fba13244307a7ca853b6ddaa14ded69f651c3f184ac130bd1aaad"},"tools":{"phpcs":{"version":"3.10.3","url":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.10.3/phpcs.phar","requirements":{"php":{"php":">=5.4.0","ext-simplexml":"*","ext-tokenizer":"*","ext-xmlwriter":"*"}},"checksum":null,"signature":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.10.3/phpcs.phar.asc"},"phpcbf":{"version":"3.10.3","url":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.10.3/phpcbf.phar","requirements":{"php":{"php":">=5.4.0","ext-simplexml":"*","ext-tokenizer":"*","ext-xmlwriter":"*"}},"checksum":null,"signature":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.10.3/phpcbf.phar.asc"}},"composerLock":null},"composer-normalize":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/composer-normalize/composer-normalize-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-json":"*"},"tool":{"composer-normalize":"^2.1"}},"checksum":{"type":"sha-512","value":"d9abda440b85d501c58abf9c81bf76f417594b397129215ffa8b777e9bb5e5eda37d7661d661db3c8d11c24f20345bc6fbe56f013b3b9435d459d2b94f086e0f"},"tools":{"composer-normalize":{"version":"2.44.0","url":"https://github.com/ergebnis/composer-normalize/releases/download/2.44.0/composer-normalize.phar","requirements":{"php":{"php":"~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0","ext-json":"*"}},"checksum":null,"signature":"https://github.com/ergebnis/composer-normalize/releases/download/2.44.0/composer-normalize.phar.asc"}},"composerLock":null}},"tools":[]} \ No newline at end of file +{"plugins":{"phpunit":{"api-version":"1.0.0","version":"1.0.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpunit/phpunit-1.0.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0"},"tool":{"phpunit":"^6.0 || ^7.0 || ^8.0 || ^9.0"}},"checksum":{"type":"sha-512","value":"c73f15658e3ba62665f09492ec91c3a6a715760bfaa88473a987538439fff442540148e086e46a6aa18ce55a3ea2fbf76caaa581384cb84a38859fcc609ae7e4"},"tools":{"phpunit":{"version":"9.6.22","url":"https://phar.phpunit.de/phpunit-9.6.22.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*","ext-json":"*","ext-libxml":"*","ext-mbstring":"*","ext-xml":"*","ext-xmlwriter":"*"}},"checksum":{"type":"sha-256","value":"9618d52015c9b06b4979a8e481ca9567be6be20e711e98926c61378a400e1f2e"},"signature":"https://phar.phpunit.de/phpunit-9.6.22.phar.asc"}},"composerLock":null},"psalm":{"api-version":"1.0.0","version":"1.2.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/psalm/psalm-1.2.0.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0","ext-dom":"*"},"tool":{"psalm":"^3.0 || ^4.0 || ^5.0"}},"checksum":{"type":"sha-512","value":"4a550c9226d7bca582d7c10bd87cce01190c96398936b1613421640c83df62ed1c6e0d44c1b39635414ea8cf4a892a6458d27590793238add24e7cb5547e6ffd"},"tools":{"psalm":{"version":"5.26.1","url":"https://github.com/vimeo/psalm/releases/download/5.26.1/psalm.phar","requirements":{"php":{"php":"^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0","ext-SimpleXML":"*","ext-ctype":"*","ext-dom":"*","ext-json":"*","ext-libxml":"*","ext-mbstring":"*","ext-tokenizer":"*"}},"checksum":null,"signature":"https://github.com/vimeo/psalm/releases/download/5.26.1/psalm.phar.asc"}},"composerLock":null},"composer-require-checker":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/composer-require-checker/composer-require-checker-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0"},"tool":{"composer-require-checker":"^3.8 || ^4.0"}},"checksum":{"type":"sha-512","value":"d5415bddfe024c5749d894034583882aee4e5c3e1087815d9fdd81cb5e71630f631a0e35de0ff84b97fbbf738c16ece5f83bd8c00695913eb846aa6f04577dc2"},"tools":{"composer-require-checker":{"version":"4.14.0","url":"https://github.com/maglnet/ComposerRequireChecker/releases/download/4.14.0/composer-require-checker.phar","requirements":{"php":{"php":"~8.2.0 || ~8.3.0 || ~8.4.0","ext-phar":"*"}},"checksum":null,"signature":"https://github.com/maglnet/ComposerRequireChecker/releases/download/4.14.0/composer-require-checker.phar.asc"}},"composerLock":null},"phpmd":{"api-version":"1.0.0","version":"1.0.2.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpmd/phpmd-1.0.2.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpmd":"^2.6.1"}},"checksum":{"type":"sha-512","value":"f22280a6dec8dbdd2ec1d83b294f23237fe32c34f4a298e52038e0a7a0074d541635b2b488b1a6098a42d8418a6cd8eb804406ea82b91e362be2b5d11a0915b0"},"tools":{"phpmd":{"version":"2.15.0","url":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar","requirements":{"php":{"php":">=5.3.9","ext-xml":"*"}},"checksum":null,"signature":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar.asc"}},"composerLock":null},"phpcpd":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpcpd/phpcpd-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcpd":"^6.0"}},"checksum":{"type":"sha-512","value":"1189ce0bf3fade4cb4241f1d96f915ef8fc7651f4450dc79fdf464ee3d6be3009316f0d423ce2d4af9d76ad50807b7fdf4d77bfa6d9ee2c91d6eda32ea214433"},"tools":{"phpcpd":{"version":"6.0.3","url":"https://phar.phpunit.de/phpcpd-6.0.3.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*"}},"checksum":{"type":"sha-256","value":"2cbaea7cfda1bb4299d863eb075e977c3f49055dd16d88529fae5150d48a84cb"},"signature":"https://phar.phpunit.de/phpcpd-6.0.3.phar.asc"}},"composerLock":null},"phploc":{"api-version":"1.0.0","version":"1.0.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phploc/phploc-1.0.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*","ext-json":"*"},"tool":{"phploc":"^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0"}},"checksum":{"type":"sha-512","value":"f67b02d494796adf553cb3dd13ec06c1cb8e53c799954061749424251379541637538199afb3afa3c7a01cabd1cb6f1c53eb621f015dff9644c6c7cbf10c56d1"},"tools":{"phploc":{"version":"7.0.2","url":"https://phar.phpunit.de/phploc-7.0.2.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*","ext-json":"*"}},"checksum":{"type":"sha-256","value":"3d59778ec86faf25fd00e3a329b2f9ad4a3c751ca91601ea7dab70f887b0bf46"},"signature":"https://phar.phpunit.de/phploc-7.0.2.phar.asc"}},"composerLock":null},"phpcs":{"api-version":"1.0.0","version":"1.2.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpcs/phpcs-1.2.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcs":"^3.0 || ^2.0","phpcbf":"^3.0 || ^2.0"}},"checksum":{"type":"sha-512","value":"b6ed00306e76068a6af5e3b1dec837724f9e1900ef1049ce88e7ce195b0583524ca33a73613fba13244307a7ca853b6ddaa14ded69f651c3f184ac130bd1aaad"},"tools":{"phpcs":{"version":"3.11.3","url":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.11.3/phpcs.phar","requirements":{"php":{"php":">=5.4.0","ext-simplexml":"*","ext-tokenizer":"*","ext-xmlwriter":"*"}},"checksum":null,"signature":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.11.3/phpcs.phar.asc"},"phpcbf":{"version":"3.11.3","url":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.11.3/phpcbf.phar","requirements":{"php":{"php":">=5.4.0","ext-simplexml":"*","ext-tokenizer":"*","ext-xmlwriter":"*"}},"checksum":null,"signature":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.11.3/phpcbf.phar.asc"}},"composerLock":null},"composer-normalize":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/composer-normalize/composer-normalize-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-json":"*"},"tool":{"composer-normalize":"^2.1"}},"checksum":{"type":"sha-512","value":"d9abda440b85d501c58abf9c81bf76f417594b397129215ffa8b777e9bb5e5eda37d7661d661db3c8d11c24f20345bc6fbe56f013b3b9435d459d2b94f086e0f"},"tools":{"composer-normalize":{"version":"2.45.0","url":"https://github.com/ergebnis/composer-normalize/releases/download/2.45.0/composer-normalize.phar","requirements":{"php":{"php":"~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0","ext-json":"*"}},"checksum":null,"signature":"https://github.com/ergebnis/composer-normalize/releases/download/2.45.0/composer-normalize.phar.asc"}},"composerLock":null}},"tools":[]} \ No newline at end of file diff --git a/src/Resources/contao/languages/de/default.php b/src/Resources/contao/languages/de/default.php deleted file mode 100644 index 25ba4bd..0000000 --- a/src/Resources/contao/languages/de/default.php +++ /dev/null @@ -1,25 +0,0 @@ - Date: Sun, 2 Mar 2025 16:18:55 +0100 Subject: [PATCH 52/56] Fix translation --- src/Resources/translations/tl_metamodel_dcasetting.de.xlf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Resources/translations/tl_metamodel_dcasetting.de.xlf b/src/Resources/translations/tl_metamodel_dcasetting.de.xlf index 526ee14..1db9d43 100644 --- a/src/Resources/translations/tl_metamodel_dcasetting.de.xlf +++ b/src/Resources/translations/tl_metamodel_dcasetting.de.xlf @@ -43,7 +43,7 @@ Here you can extend the base upload folder path. The Contao insert tags are supported to extend the path. - Hier können Sie den Basis-Upload-Ordnerpfad erweitern. Die Contao Insert-Tags werden unterstützt, um den Pfad zu erweitern. Die Insert-Tags aus der Filterregel "Eigener SQL" funktionieren auch hier. + Hier können Sie den Basis-Upload-Ordnerpfad erweitern. Die Contao Insert-Tags werden unterstützt, um den Pfad zu erweitern. Deselect file @@ -159,4 +159,4 @@ - \ No newline at end of file + From 8213991aec20b50add752abe9c97d6fa25f04b9b Mon Sep 17 00:00:00 2001 From: Ingolf Steinhardt Date: Mon, 10 Mar 2025 20:33:43 +0100 Subject: [PATCH 53/56] Fix phpcq --- .phpcq.lock | 2 +- psalm.xml | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.phpcq.lock b/.phpcq.lock index 8dde433..3ae3f45 100644 --- a/.phpcq.lock +++ b/.phpcq.lock @@ -1 +1 @@ -{"plugins":{"phpunit":{"api-version":"1.0.0","version":"1.0.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpunit/phpunit-1.0.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0"},"tool":{"phpunit":"^6.0 || ^7.0 || ^8.0 || ^9.0"}},"checksum":{"type":"sha-512","value":"c73f15658e3ba62665f09492ec91c3a6a715760bfaa88473a987538439fff442540148e086e46a6aa18ce55a3ea2fbf76caaa581384cb84a38859fcc609ae7e4"},"tools":{"phpunit":{"version":"9.6.22","url":"https://phar.phpunit.de/phpunit-9.6.22.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*","ext-json":"*","ext-libxml":"*","ext-mbstring":"*","ext-xml":"*","ext-xmlwriter":"*"}},"checksum":{"type":"sha-256","value":"9618d52015c9b06b4979a8e481ca9567be6be20e711e98926c61378a400e1f2e"},"signature":"https://phar.phpunit.de/phpunit-9.6.22.phar.asc"}},"composerLock":null},"psalm":{"api-version":"1.0.0","version":"1.2.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/psalm/psalm-1.2.0.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0","ext-dom":"*"},"tool":{"psalm":"^3.0 || ^4.0 || ^5.0"}},"checksum":{"type":"sha-512","value":"4a550c9226d7bca582d7c10bd87cce01190c96398936b1613421640c83df62ed1c6e0d44c1b39635414ea8cf4a892a6458d27590793238add24e7cb5547e6ffd"},"tools":{"psalm":{"version":"5.26.1","url":"https://github.com/vimeo/psalm/releases/download/5.26.1/psalm.phar","requirements":{"php":{"php":"^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0","ext-SimpleXML":"*","ext-ctype":"*","ext-dom":"*","ext-json":"*","ext-libxml":"*","ext-mbstring":"*","ext-tokenizer":"*"}},"checksum":null,"signature":"https://github.com/vimeo/psalm/releases/download/5.26.1/psalm.phar.asc"}},"composerLock":null},"composer-require-checker":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/composer-require-checker/composer-require-checker-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0"},"tool":{"composer-require-checker":"^3.8 || ^4.0"}},"checksum":{"type":"sha-512","value":"d5415bddfe024c5749d894034583882aee4e5c3e1087815d9fdd81cb5e71630f631a0e35de0ff84b97fbbf738c16ece5f83bd8c00695913eb846aa6f04577dc2"},"tools":{"composer-require-checker":{"version":"4.14.0","url":"https://github.com/maglnet/ComposerRequireChecker/releases/download/4.14.0/composer-require-checker.phar","requirements":{"php":{"php":"~8.2.0 || ~8.3.0 || ~8.4.0","ext-phar":"*"}},"checksum":null,"signature":"https://github.com/maglnet/ComposerRequireChecker/releases/download/4.14.0/composer-require-checker.phar.asc"}},"composerLock":null},"phpmd":{"api-version":"1.0.0","version":"1.0.2.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpmd/phpmd-1.0.2.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpmd":"^2.6.1"}},"checksum":{"type":"sha-512","value":"f22280a6dec8dbdd2ec1d83b294f23237fe32c34f4a298e52038e0a7a0074d541635b2b488b1a6098a42d8418a6cd8eb804406ea82b91e362be2b5d11a0915b0"},"tools":{"phpmd":{"version":"2.15.0","url":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar","requirements":{"php":{"php":">=5.3.9","ext-xml":"*"}},"checksum":null,"signature":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar.asc"}},"composerLock":null},"phpcpd":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpcpd/phpcpd-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcpd":"^6.0"}},"checksum":{"type":"sha-512","value":"1189ce0bf3fade4cb4241f1d96f915ef8fc7651f4450dc79fdf464ee3d6be3009316f0d423ce2d4af9d76ad50807b7fdf4d77bfa6d9ee2c91d6eda32ea214433"},"tools":{"phpcpd":{"version":"6.0.3","url":"https://phar.phpunit.de/phpcpd-6.0.3.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*"}},"checksum":{"type":"sha-256","value":"2cbaea7cfda1bb4299d863eb075e977c3f49055dd16d88529fae5150d48a84cb"},"signature":"https://phar.phpunit.de/phpcpd-6.0.3.phar.asc"}},"composerLock":null},"phploc":{"api-version":"1.0.0","version":"1.0.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phploc/phploc-1.0.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*","ext-json":"*"},"tool":{"phploc":"^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0"}},"checksum":{"type":"sha-512","value":"f67b02d494796adf553cb3dd13ec06c1cb8e53c799954061749424251379541637538199afb3afa3c7a01cabd1cb6f1c53eb621f015dff9644c6c7cbf10c56d1"},"tools":{"phploc":{"version":"7.0.2","url":"https://phar.phpunit.de/phploc-7.0.2.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*","ext-json":"*"}},"checksum":{"type":"sha-256","value":"3d59778ec86faf25fd00e3a329b2f9ad4a3c751ca91601ea7dab70f887b0bf46"},"signature":"https://phar.phpunit.de/phploc-7.0.2.phar.asc"}},"composerLock":null},"phpcs":{"api-version":"1.0.0","version":"1.2.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpcs/phpcs-1.2.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcs":"^3.0 || ^2.0","phpcbf":"^3.0 || ^2.0"}},"checksum":{"type":"sha-512","value":"b6ed00306e76068a6af5e3b1dec837724f9e1900ef1049ce88e7ce195b0583524ca33a73613fba13244307a7ca853b6ddaa14ded69f651c3f184ac130bd1aaad"},"tools":{"phpcs":{"version":"3.11.3","url":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.11.3/phpcs.phar","requirements":{"php":{"php":">=5.4.0","ext-simplexml":"*","ext-tokenizer":"*","ext-xmlwriter":"*"}},"checksum":null,"signature":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.11.3/phpcs.phar.asc"},"phpcbf":{"version":"3.11.3","url":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.11.3/phpcbf.phar","requirements":{"php":{"php":">=5.4.0","ext-simplexml":"*","ext-tokenizer":"*","ext-xmlwriter":"*"}},"checksum":null,"signature":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.11.3/phpcbf.phar.asc"}},"composerLock":null},"composer-normalize":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/composer-normalize/composer-normalize-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-json":"*"},"tool":{"composer-normalize":"^2.1"}},"checksum":{"type":"sha-512","value":"d9abda440b85d501c58abf9c81bf76f417594b397129215ffa8b777e9bb5e5eda37d7661d661db3c8d11c24f20345bc6fbe56f013b3b9435d459d2b94f086e0f"},"tools":{"composer-normalize":{"version":"2.45.0","url":"https://github.com/ergebnis/composer-normalize/releases/download/2.45.0/composer-normalize.phar","requirements":{"php":{"php":"~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0","ext-json":"*"}},"checksum":null,"signature":"https://github.com/ergebnis/composer-normalize/releases/download/2.45.0/composer-normalize.phar.asc"}},"composerLock":null}},"tools":[]} \ No newline at end of file +{"plugins":{"phpunit":{"api-version":"1.0.0","version":"1.0.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpunit/phpunit-1.0.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0"},"tool":{"phpunit":"^6.0 || ^7.0 || ^8.0 || ^9.0"}},"checksum":{"type":"sha-512","value":"c73f15658e3ba62665f09492ec91c3a6a715760bfaa88473a987538439fff442540148e086e46a6aa18ce55a3ea2fbf76caaa581384cb84a38859fcc609ae7e4"},"tools":{"phpunit":{"version":"9.6.22","url":"https://phar.phpunit.de/phpunit-9.6.22.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*","ext-json":"*","ext-libxml":"*","ext-mbstring":"*","ext-xml":"*","ext-xmlwriter":"*"}},"checksum":{"type":"sha-256","value":"9618d52015c9b06b4979a8e481ca9567be6be20e711e98926c61378a400e1f2e"},"signature":"https://phar.phpunit.de/phpunit-9.6.22.phar.asc"}},"composerLock":null},"psalm":{"api-version":"1.0.0","version":"1.2.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/psalm/psalm-1.2.0.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0","ext-dom":"*"},"tool":{"psalm":"^3.0 || ^4.0 || ^5.0"}},"checksum":{"type":"sha-512","value":"4a550c9226d7bca582d7c10bd87cce01190c96398936b1613421640c83df62ed1c6e0d44c1b39635414ea8cf4a892a6458d27590793238add24e7cb5547e6ffd"},"tools":{"psalm":{"version":"5.26.1","url":"https://github.com/vimeo/psalm/releases/download/5.26.1/psalm.phar","requirements":{"php":{"php":"^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0","ext-SimpleXML":"*","ext-ctype":"*","ext-dom":"*","ext-json":"*","ext-libxml":"*","ext-mbstring":"*","ext-tokenizer":"*"}},"checksum":null,"signature":"https://github.com/vimeo/psalm/releases/download/5.26.1/psalm.phar.asc"}},"composerLock":null},"composer-require-checker":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/composer-require-checker/composer-require-checker-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0"},"tool":{"composer-require-checker":"^3.8 || ^4.0"}},"checksum":{"type":"sha-512","value":"d5415bddfe024c5749d894034583882aee4e5c3e1087815d9fdd81cb5e71630f631a0e35de0ff84b97fbbf738c16ece5f83bd8c00695913eb846aa6f04577dc2"},"tools":{"composer-require-checker":{"version":"4.16.1","url":"https://github.com/maglnet/ComposerRequireChecker/releases/download/4.16.1/composer-require-checker.phar","requirements":{"php":{"php":"~8.2.0 || ~8.3.0 || ~8.4.0","ext-phar":"*"}},"checksum":null,"signature":"https://github.com/maglnet/ComposerRequireChecker/releases/download/4.16.1/composer-require-checker.phar.asc"}},"composerLock":null},"phpmd":{"api-version":"1.0.0","version":"1.0.2.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpmd/phpmd-1.0.2.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpmd":"^2.6.1"}},"checksum":{"type":"sha-512","value":"f22280a6dec8dbdd2ec1d83b294f23237fe32c34f4a298e52038e0a7a0074d541635b2b488b1a6098a42d8418a6cd8eb804406ea82b91e362be2b5d11a0915b0"},"tools":{"phpmd":{"version":"2.15.0","url":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar","requirements":{"php":{"php":">=5.3.9","ext-xml":"*"}},"checksum":null,"signature":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar.asc"}},"composerLock":null},"phpcpd":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpcpd/phpcpd-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcpd":"^6.0"}},"checksum":{"type":"sha-512","value":"1189ce0bf3fade4cb4241f1d96f915ef8fc7651f4450dc79fdf464ee3d6be3009316f0d423ce2d4af9d76ad50807b7fdf4d77bfa6d9ee2c91d6eda32ea214433"},"tools":{"phpcpd":{"version":"6.0.3","url":"https://phar.phpunit.de/phpcpd-6.0.3.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*"}},"checksum":{"type":"sha-256","value":"2cbaea7cfda1bb4299d863eb075e977c3f49055dd16d88529fae5150d48a84cb"},"signature":"https://phar.phpunit.de/phpcpd-6.0.3.phar.asc"}},"composerLock":null},"phploc":{"api-version":"1.0.0","version":"1.0.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phploc/phploc-1.0.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*","ext-json":"*"},"tool":{"phploc":"^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0"}},"checksum":{"type":"sha-512","value":"f67b02d494796adf553cb3dd13ec06c1cb8e53c799954061749424251379541637538199afb3afa3c7a01cabd1cb6f1c53eb621f015dff9644c6c7cbf10c56d1"},"tools":{"phploc":{"version":"7.0.2","url":"https://phar.phpunit.de/phploc-7.0.2.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*","ext-json":"*"}},"checksum":{"type":"sha-256","value":"3d59778ec86faf25fd00e3a329b2f9ad4a3c751ca91601ea7dab70f887b0bf46"},"signature":"https://phar.phpunit.de/phploc-7.0.2.phar.asc"}},"composerLock":null},"phpcs":{"api-version":"1.0.0","version":"1.2.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpcs/phpcs-1.2.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcs":"^3.0 || ^2.0","phpcbf":"^3.0 || ^2.0"}},"checksum":{"type":"sha-512","value":"b6ed00306e76068a6af5e3b1dec837724f9e1900ef1049ce88e7ce195b0583524ca33a73613fba13244307a7ca853b6ddaa14ded69f651c3f184ac130bd1aaad"},"tools":{"phpcs":{"version":"3.11.3","url":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.11.3/phpcs.phar","requirements":{"php":{"php":">=5.4.0","ext-simplexml":"*","ext-tokenizer":"*","ext-xmlwriter":"*"}},"checksum":null,"signature":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.11.3/phpcs.phar.asc"},"phpcbf":{"version":"3.11.3","url":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.11.3/phpcbf.phar","requirements":{"php":{"php":">=5.4.0","ext-simplexml":"*","ext-tokenizer":"*","ext-xmlwriter":"*"}},"checksum":null,"signature":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.11.3/phpcbf.phar.asc"}},"composerLock":null},"composer-normalize":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/composer-normalize/composer-normalize-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-json":"*"},"tool":{"composer-normalize":"^2.1"}},"checksum":{"type":"sha-512","value":"d9abda440b85d501c58abf9c81bf76f417594b397129215ffa8b777e9bb5e5eda37d7661d661db3c8d11c24f20345bc6fbe56f013b3b9435d459d2b94f086e0f"},"tools":{"composer-normalize":{"version":"2.45.0","url":"https://github.com/ergebnis/composer-normalize/releases/download/2.45.0/composer-normalize.phar","requirements":{"php":{"php":"~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0","ext-json":"*"}},"checksum":null,"signature":"https://github.com/ergebnis/composer-normalize/releases/download/2.45.0/composer-normalize.phar.asc"}},"composerLock":null}},"tools":[]} \ No newline at end of file diff --git a/psalm.xml b/psalm.xml index cd35238..663fb43 100644 --- a/psalm.xml +++ b/psalm.xml @@ -10,7 +10,6 @@ - From e9eaefbdca142e1ccc2e07cb15dd74325284484a Mon Sep 17 00:00:00 2001 From: Ingolf Steinhardt Date: Thu, 20 Mar 2025 17:07:17 +0100 Subject: [PATCH 54/56] Fix phpcq --- .check-author.yml | 16 ------- .github/workflows/diagnostics.yml | 71 ++++++++++++++++++++----------- .gitignore | 1 + .phpcq.yaml.dist | 3 ++ composer.json | 4 +- src/Resources/config/services.yml | 20 ++++----- 6 files changed, 63 insertions(+), 52 deletions(-) delete mode 100644 .check-author.yml diff --git a/.check-author.yml b/.check-author.yml deleted file mode 100644 index f266ac9..0000000 --- a/.check-author.yml +++ /dev/null @@ -1,16 +0,0 @@ -ignore: - - 'Mini Model ' - -exclude: - - /^src\/Resources\/contao\/languages/ - -mapping: - 'Andreas Isaak ': 'Andreas Isaak ' - 'Christopher Boelter ': - - 'cogizz ' - - 'cboelter ' - - 'Christopher Boelter ' - 'Ingolf Steinhardt ': - - 'zonky2 ' - - 'Ingolf Steinhardt ' - - 'Ingolf Steinhardt ' diff --git a/.github/workflows/diagnostics.yml b/.github/workflows/diagnostics.yml index 218a32c..9d4510b 100644 --- a/.github/workflows/diagnostics.yml +++ b/.github/workflows/diagnostics.yml @@ -1,52 +1,75 @@ name: MetaModels attribute_file on: - push: - branches-ignore: - - '**-translation' pull_request: + push: + branches: jobs: build: runs-on: ubuntu-latest + name: 'PHP: ${{ matrix.php }} Contao: ${{ matrix.contao }}' strategy: + fail-fast: false matrix: - php: [7.4] - contao: [~4.9.0] + php: [ '8.1', '8.2', '8.3' ] + contao: [ '~4.13.0' ] + phpcq_install: [ 'update' ] + output: [ '-o github-action -o default' ] steps: - - name: PHP ${{ matrix.php }} ${{ matrix.contao }} Pull source - uses: actions/checkout@v3 - with: - fetch-depth: 0 + - name: Pull source + uses: actions/checkout@v4 - # see https://github.com/shivammathur/setup-php - - name: PHP ${{ matrix.php }} ${{ matrix.contao }} Setup PHP. + - name: Setup PHP with PECL extension uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} - coverage: none - - name: PHP ${{ matrix.php }} ${{ matrix.contao }} Cache composer cache directory - uses: actions/cache@v3 + # setup caches + - name: Cache composer cache directory + uses: actions/cache@v4 env: cache-name: composer-cache-dir with: path: ~/.cache/composer - key: ${{ runner.os }}-build-${{ env.cache-name }} + key: ${{ runner.os }}-${{ matrix.php }}-build-${{ env.cache-name }} - - name: PHP ${{ matrix.php }} ${{ matrix.contao }} Cache vendor directory - uses: actions/cache@v3 + - name: Cache vendor directory + uses: actions/cache@v4 env: - cache-name: composer-vendor + cache-name: vendor with: path: vendor - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/composer.lock') }} + key: ${{ runner.os }}-${{ matrix.php }}-${{ matrix.contao }}-build-${{ env.cache-name }}-${{ hashFiles('**/composer.lock') }} restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-${{ matrix.php }}-${{ matrix.contao }}-build-${{ env.cache-name }}- - - name: PHP ${{ matrix.php }} ${{ matrix.contao }} Install composer dependencies - run: composer update --prefer-dist --no-interaction --no-suggest + - name: Cache phpcq directory + uses: actions/cache@v4 + env: + cache-name: phpcq + with: + path: .phpcq + key: ${{ runner.os }}-${{ matrix.php }}-build-${{ env.cache-name }}-${{ hashFiles('**/.phpcq.lock') }} + restore-keys: | + ${{ runner.os }}-${{ matrix.php }}-build-${{ env.cache-name }}- + + # install dependencies and tools + - name: Install composer dependencies + run: | + composer require contao/core-bundle ${{ matrix.contao }} --no-update + composer install + - name: Install phpcq toolchain + run: ./vendor/bin/phpcq ${{ matrix.phpcq_install }} -v - - name: PHP ${{ matrix.php }} ${{ matrix.contao }} Run tests - run: ant -keep-going + # run tests + - name: Run tests + run: ./vendor/bin/phpcq run -v ${{ matrix.output }} + + - name: Upload build directory to artifact + uses: actions/upload-artifact@v4 + if: ${{ success() }} || ${{ failure() }} + with: + name: phpcq-builds-php-${{ matrix.php }}-${{ matrix.contao }} + path: .phpcq/build/ diff --git a/.gitignore b/.gitignore index 3707056..eccdc19 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ Thumbs.db .build/ .external*/ .idea/ +.phpcq/ nbproject/ # composer related diff --git a/.phpcq.yaml.dist b/.phpcq.yaml.dist index a9616d5..a0ff982 100644 --- a/.phpcq.yaml.dist +++ b/.phpcq.yaml.dist @@ -15,6 +15,9 @@ phpcq: psalm: version: ^1.0 signed: false + requirements: + psalm: + version: ^5.26.1 composer-require-checker: version: ^1.0 signed: false diff --git a/composer.json b/composer.json index 09fa693..ec2aa94 100644 --- a/composer.json +++ b/composer.json @@ -35,7 +35,7 @@ "contao-community-alliance/dc-general": "^2.3", "contao/core-bundle": "^4.13.0 <5.0", "doctrine/dbal": "^3.6.0", - "metamodels/core": "^2.3@dev", + "metamodels/core": "^2.3", "symfony/cache": "^5.4", "symfony/config": "^5.4", "symfony/dependency-injection": "^5.4", @@ -49,7 +49,7 @@ "contao/manager-plugin": "^2.1", "inspiredminds/contao-file-usage": "^3.0.1", "menatwork/contao-multicolumnwizard-bundle": "^3.4", - "metamodels/contao-frontend-editing": "^2.3@dev", + "metamodels/contao-frontend-editing": "^2.3", "phpcq/runner-bootstrap": "^1.0@dev" }, "autoload": { diff --git a/src/Resources/config/services.yml b/src/Resources/config/services.yml index d055001..9fb8c94 100644 --- a/src/Resources/config/services.yml +++ b/src/Resources/config/services.yml @@ -33,13 +33,13 @@ services: tags: - name: contao.migration -# MetaModels\AttributeFileBundle\FileUsage\FileUsageProvider: -# public: true -# arguments: -# $factory: '@metamodels.factory' -# $urlGenerator: '@router' -# $requestStack: '@request_stack' -# $csrfTokenManager: '@contao.csrf.token_manager' -# $csrfTokenName: '%contao.csrf_token_name%' -# tags: -# - { name: contao_file_usage.provider } + MetaModels\AttributeFileBundle\FileUsage\FileUsageProvider: + public: true + arguments: + $factory: '@metamodels.factory' + $urlGenerator: '@router' + $requestStack: '@request_stack' + $csrfTokenManager: '@contao.csrf.token_manager' + $csrfTokenName: '%contao.csrf_token_name%' + tags: + - { name: contao_file_usage.provider } From b724f576b466ef45d2bdbb1eceb7a8a343fd20b3 Mon Sep 17 00:00:00 2001 From: Ingolf Steinhardt Date: Thu, 20 Mar 2025 17:21:26 +0100 Subject: [PATCH 55/56] Fix phpcq --- .phpcq.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.phpcq.lock b/.phpcq.lock index 3ae3f45..f19c1f3 100644 --- a/.phpcq.lock +++ b/.phpcq.lock @@ -1 +1 @@ -{"plugins":{"phpunit":{"api-version":"1.0.0","version":"1.0.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpunit/phpunit-1.0.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0"},"tool":{"phpunit":"^6.0 || ^7.0 || ^8.0 || ^9.0"}},"checksum":{"type":"sha-512","value":"c73f15658e3ba62665f09492ec91c3a6a715760bfaa88473a987538439fff442540148e086e46a6aa18ce55a3ea2fbf76caaa581384cb84a38859fcc609ae7e4"},"tools":{"phpunit":{"version":"9.6.22","url":"https://phar.phpunit.de/phpunit-9.6.22.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*","ext-json":"*","ext-libxml":"*","ext-mbstring":"*","ext-xml":"*","ext-xmlwriter":"*"}},"checksum":{"type":"sha-256","value":"9618d52015c9b06b4979a8e481ca9567be6be20e711e98926c61378a400e1f2e"},"signature":"https://phar.phpunit.de/phpunit-9.6.22.phar.asc"}},"composerLock":null},"psalm":{"api-version":"1.0.0","version":"1.2.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/psalm/psalm-1.2.0.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0","ext-dom":"*"},"tool":{"psalm":"^3.0 || ^4.0 || ^5.0"}},"checksum":{"type":"sha-512","value":"4a550c9226d7bca582d7c10bd87cce01190c96398936b1613421640c83df62ed1c6e0d44c1b39635414ea8cf4a892a6458d27590793238add24e7cb5547e6ffd"},"tools":{"psalm":{"version":"5.26.1","url":"https://github.com/vimeo/psalm/releases/download/5.26.1/psalm.phar","requirements":{"php":{"php":"^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0","ext-SimpleXML":"*","ext-ctype":"*","ext-dom":"*","ext-json":"*","ext-libxml":"*","ext-mbstring":"*","ext-tokenizer":"*"}},"checksum":null,"signature":"https://github.com/vimeo/psalm/releases/download/5.26.1/psalm.phar.asc"}},"composerLock":null},"composer-require-checker":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/composer-require-checker/composer-require-checker-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0"},"tool":{"composer-require-checker":"^3.8 || ^4.0"}},"checksum":{"type":"sha-512","value":"d5415bddfe024c5749d894034583882aee4e5c3e1087815d9fdd81cb5e71630f631a0e35de0ff84b97fbbf738c16ece5f83bd8c00695913eb846aa6f04577dc2"},"tools":{"composer-require-checker":{"version":"4.16.1","url":"https://github.com/maglnet/ComposerRequireChecker/releases/download/4.16.1/composer-require-checker.phar","requirements":{"php":{"php":"~8.2.0 || ~8.3.0 || ~8.4.0","ext-phar":"*"}},"checksum":null,"signature":"https://github.com/maglnet/ComposerRequireChecker/releases/download/4.16.1/composer-require-checker.phar.asc"}},"composerLock":null},"phpmd":{"api-version":"1.0.0","version":"1.0.2.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpmd/phpmd-1.0.2.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpmd":"^2.6.1"}},"checksum":{"type":"sha-512","value":"f22280a6dec8dbdd2ec1d83b294f23237fe32c34f4a298e52038e0a7a0074d541635b2b488b1a6098a42d8418a6cd8eb804406ea82b91e362be2b5d11a0915b0"},"tools":{"phpmd":{"version":"2.15.0","url":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar","requirements":{"php":{"php":">=5.3.9","ext-xml":"*"}},"checksum":null,"signature":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar.asc"}},"composerLock":null},"phpcpd":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpcpd/phpcpd-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcpd":"^6.0"}},"checksum":{"type":"sha-512","value":"1189ce0bf3fade4cb4241f1d96f915ef8fc7651f4450dc79fdf464ee3d6be3009316f0d423ce2d4af9d76ad50807b7fdf4d77bfa6d9ee2c91d6eda32ea214433"},"tools":{"phpcpd":{"version":"6.0.3","url":"https://phar.phpunit.de/phpcpd-6.0.3.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*"}},"checksum":{"type":"sha-256","value":"2cbaea7cfda1bb4299d863eb075e977c3f49055dd16d88529fae5150d48a84cb"},"signature":"https://phar.phpunit.de/phpcpd-6.0.3.phar.asc"}},"composerLock":null},"phploc":{"api-version":"1.0.0","version":"1.0.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phploc/phploc-1.0.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*","ext-json":"*"},"tool":{"phploc":"^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0"}},"checksum":{"type":"sha-512","value":"f67b02d494796adf553cb3dd13ec06c1cb8e53c799954061749424251379541637538199afb3afa3c7a01cabd1cb6f1c53eb621f015dff9644c6c7cbf10c56d1"},"tools":{"phploc":{"version":"7.0.2","url":"https://phar.phpunit.de/phploc-7.0.2.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*","ext-json":"*"}},"checksum":{"type":"sha-256","value":"3d59778ec86faf25fd00e3a329b2f9ad4a3c751ca91601ea7dab70f887b0bf46"},"signature":"https://phar.phpunit.de/phploc-7.0.2.phar.asc"}},"composerLock":null},"phpcs":{"api-version":"1.0.0","version":"1.2.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpcs/phpcs-1.2.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcs":"^3.0 || ^2.0","phpcbf":"^3.0 || ^2.0"}},"checksum":{"type":"sha-512","value":"b6ed00306e76068a6af5e3b1dec837724f9e1900ef1049ce88e7ce195b0583524ca33a73613fba13244307a7ca853b6ddaa14ded69f651c3f184ac130bd1aaad"},"tools":{"phpcs":{"version":"3.11.3","url":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.11.3/phpcs.phar","requirements":{"php":{"php":">=5.4.0","ext-simplexml":"*","ext-tokenizer":"*","ext-xmlwriter":"*"}},"checksum":null,"signature":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.11.3/phpcs.phar.asc"},"phpcbf":{"version":"3.11.3","url":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.11.3/phpcbf.phar","requirements":{"php":{"php":">=5.4.0","ext-simplexml":"*","ext-tokenizer":"*","ext-xmlwriter":"*"}},"checksum":null,"signature":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.11.3/phpcbf.phar.asc"}},"composerLock":null},"composer-normalize":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/composer-normalize/composer-normalize-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-json":"*"},"tool":{"composer-normalize":"^2.1"}},"checksum":{"type":"sha-512","value":"d9abda440b85d501c58abf9c81bf76f417594b397129215ffa8b777e9bb5e5eda37d7661d661db3c8d11c24f20345bc6fbe56f013b3b9435d459d2b94f086e0f"},"tools":{"composer-normalize":{"version":"2.45.0","url":"https://github.com/ergebnis/composer-normalize/releases/download/2.45.0/composer-normalize.phar","requirements":{"php":{"php":"~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0","ext-json":"*"}},"checksum":null,"signature":"https://github.com/ergebnis/composer-normalize/releases/download/2.45.0/composer-normalize.phar.asc"}},"composerLock":null}},"tools":[]} \ No newline at end of file +{"plugins":{"phpunit":{"api-version":"1.0.0","version":"1.0.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpunit/phpunit-1.0.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0"},"tool":{"phpunit":"^6.0 || ^7.0 || ^8.0 || ^9.0"}},"checksum":{"type":"sha-512","value":"c73f15658e3ba62665f09492ec91c3a6a715760bfaa88473a987538439fff442540148e086e46a6aa18ce55a3ea2fbf76caaa581384cb84a38859fcc609ae7e4"},"tools":{"phpunit":{"version":"9.6.22","url":"https://phar.phpunit.de/phpunit-9.6.22.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*","ext-json":"*","ext-libxml":"*","ext-mbstring":"*","ext-xml":"*","ext-xmlwriter":"*"}},"checksum":{"type":"sha-256","value":"9618d52015c9b06b4979a8e481ca9567be6be20e711e98926c61378a400e1f2e"},"signature":"https://phar.phpunit.de/phpunit-9.6.22.phar.asc"}},"composerLock":null},"psalm":{"api-version":"1.0.0","version":"1.3.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/psalm/psalm-1.3.0.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0","ext-dom":"*"},"tool":{"psalm":"^3.0 || ^4.0 || ^5.0 || ^6.0"}},"checksum":{"type":"sha-512","value":"4a550c9226d7bca582d7c10bd87cce01190c96398936b1613421640c83df62ed1c6e0d44c1b39635414ea8cf4a892a6458d27590793238add24e7cb5547e6ffd"},"tools":{"psalm":{"version":"5.26.1","url":"https://github.com/vimeo/psalm/releases/download/5.26.1/psalm.phar","requirements":{"php":{"php":"^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0","ext-SimpleXML":"*","ext-ctype":"*","ext-dom":"*","ext-json":"*","ext-libxml":"*","ext-mbstring":"*","ext-tokenizer":"*"}},"checksum":null,"signature":"https://github.com/vimeo/psalm/releases/download/5.26.1/psalm.phar.asc"}},"composerLock":null},"composer-require-checker":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/composer-require-checker/composer-require-checker-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0"},"tool":{"composer-require-checker":"^3.8 || ^4.0"}},"checksum":{"type":"sha-512","value":"d5415bddfe024c5749d894034583882aee4e5c3e1087815d9fdd81cb5e71630f631a0e35de0ff84b97fbbf738c16ece5f83bd8c00695913eb846aa6f04577dc2"},"tools":{"composer-require-checker":{"version":"4.7.1","url":"https://github.com/maglnet/ComposerRequireChecker/releases/download/4.7.1/composer-require-checker.phar","requirements":{"php":{"php":"~8.1.0 || ~8.2.0 || ~8.3.0","ext-phar":"*"}},"checksum":null,"signature":"https://github.com/maglnet/ComposerRequireChecker/releases/download/4.7.1/composer-require-checker.phar.asc"}},"composerLock":null},"phpmd":{"api-version":"1.0.0","version":"1.0.2.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpmd/phpmd-1.0.2.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpmd":"^2.6.1"}},"checksum":{"type":"sha-512","value":"f22280a6dec8dbdd2ec1d83b294f23237fe32c34f4a298e52038e0a7a0074d541635b2b488b1a6098a42d8418a6cd8eb804406ea82b91e362be2b5d11a0915b0"},"tools":{"phpmd":{"version":"2.15.0","url":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar","requirements":{"php":{"php":">=5.3.9","ext-xml":"*"}},"checksum":null,"signature":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar.asc"}},"composerLock":null},"phpcpd":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpcpd/phpcpd-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcpd":"^6.0"}},"checksum":{"type":"sha-512","value":"1189ce0bf3fade4cb4241f1d96f915ef8fc7651f4450dc79fdf464ee3d6be3009316f0d423ce2d4af9d76ad50807b7fdf4d77bfa6d9ee2c91d6eda32ea214433"},"tools":{"phpcpd":{"version":"6.0.3","url":"https://phar.phpunit.de/phpcpd-6.0.3.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*"}},"checksum":{"type":"sha-256","value":"2cbaea7cfda1bb4299d863eb075e977c3f49055dd16d88529fae5150d48a84cb"},"signature":"https://phar.phpunit.de/phpcpd-6.0.3.phar.asc"}},"composerLock":null},"phploc":{"api-version":"1.0.0","version":"1.0.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phploc/phploc-1.0.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*","ext-json":"*"},"tool":{"phploc":"^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0"}},"checksum":{"type":"sha-512","value":"f67b02d494796adf553cb3dd13ec06c1cb8e53c799954061749424251379541637538199afb3afa3c7a01cabd1cb6f1c53eb621f015dff9644c6c7cbf10c56d1"},"tools":{"phploc":{"version":"7.0.2","url":"https://phar.phpunit.de/phploc-7.0.2.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*","ext-json":"*"}},"checksum":{"type":"sha-256","value":"3d59778ec86faf25fd00e3a329b2f9ad4a3c751ca91601ea7dab70f887b0bf46"},"signature":"https://phar.phpunit.de/phploc-7.0.2.phar.asc"}},"composerLock":null},"phpcs":{"api-version":"1.0.0","version":"1.2.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpcs/phpcs-1.2.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcs":"^3.0 || ^2.0","phpcbf":"^3.0 || ^2.0"}},"checksum":{"type":"sha-512","value":"b6ed00306e76068a6af5e3b1dec837724f9e1900ef1049ce88e7ce195b0583524ca33a73613fba13244307a7ca853b6ddaa14ded69f651c3f184ac130bd1aaad"},"tools":{"phpcs":{"version":"3.12.0","url":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.12.0/phpcs.phar","requirements":{"php":{"php":">=5.4.0","ext-simplexml":"*","ext-tokenizer":"*","ext-xmlwriter":"*"}},"checksum":null,"signature":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.12.0/phpcs.phar.asc"},"phpcbf":{"version":"3.12.0","url":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.12.0/phpcbf.phar","requirements":{"php":{"php":">=5.4.0","ext-simplexml":"*","ext-tokenizer":"*","ext-xmlwriter":"*"}},"checksum":null,"signature":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.12.0/phpcbf.phar.asc"}},"composerLock":null},"composer-normalize":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/composer-normalize/composer-normalize-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-json":"*"},"tool":{"composer-normalize":"^2.1"}},"checksum":{"type":"sha-512","value":"d9abda440b85d501c58abf9c81bf76f417594b397129215ffa8b777e9bb5e5eda37d7661d661db3c8d11c24f20345bc6fbe56f013b3b9435d459d2b94f086e0f"},"tools":{"composer-normalize":{"version":"2.45.0","url":"https://github.com/ergebnis/composer-normalize/releases/download/2.45.0/composer-normalize.phar","requirements":{"php":{"php":"~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0","ext-json":"*"}},"checksum":null,"signature":"https://github.com/ergebnis/composer-normalize/releases/download/2.45.0/composer-normalize.phar.asc"}},"composerLock":null}},"tools":[]} \ No newline at end of file From 1e905d5b4a56c2507540df65b82730e1debcd0f3 Mon Sep 17 00:00:00 2001 From: Ingolf Steinhardt Date: Fri, 21 Mar 2025 12:46:53 +0100 Subject: [PATCH 56/56] Fix services for file usage --- .composer-require-checker.json | 1 + src/DependencyInjection/Configuration.php | 10 +++++---- .../MetaModelsAttributeFileExtension.php | 22 ++++++++++++------- src/Resources/config/file_usage/services.yml | 11 ++++++++++ src/Resources/config/services.yml | 11 ---------- 5 files changed, 32 insertions(+), 23 deletions(-) create mode 100644 src/Resources/config/file_usage/services.yml diff --git a/.composer-require-checker.json b/.composer-require-checker.json index 68d9d79..1fbb404 100644 --- a/.composer-require-checker.json +++ b/.composer-require-checker.json @@ -7,6 +7,7 @@ "Contao\\ManagerPlugin\\Bundle\\Parser\\ParserInterface", "Contao\\ManagerPlugin\\Routing\\RoutingPluginInterface", "MetaModels\\ContaoFrontendEditingBundle\\MetaModelsContaoFrontendEditingBundle", + "InspiredMinds\\ContaoFileUsage\\ContaoFileUsageBundle", "InspiredMinds\\ContaoFileUsage\\Provider\\FileUsageProviderInterface", "InspiredMinds\\ContaoFileUsage\\Result\\FileTreeMultipleResult", "InspiredMinds\\ContaoFileUsage\\Result\\FileTreeSingleResult", diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 2081b4e..d945b14 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -3,7 +3,7 @@ /** * This file is part of MetaModels/attribute_file. * - * (c) 2012-2023 The MetaModels team. + * (c) 2012-2025 The MetaModels team. * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -13,7 +13,7 @@ * @package MetaModels/attribute_file * @author Sven Baumann * @author Ingolf Steinhardt - * @copyright 2012-2023 The MetaModels team. + * @copyright 2012-2025 The MetaModels team. * @license https://github.com/MetaModels/attribute_file/blob/master/LICENSE LGPL-3.0-or-later * @filesource */ @@ -45,7 +45,7 @@ final class Configuration implements ConfigurationInterface */ public function __construct(bool $debug) { - $this->debug = $debug; + $this->debug = $debug; } /** @@ -61,7 +61,9 @@ public function getConfigTreeBuilder(): TreeBuilder $children->booleanNode('enable_cache')->defaultValue(!$this->debug)->end(); $children ->scalarNode('cache_dir') - ->defaultValue('%metamodels.cache_dir%' . DIRECTORY_SEPARATOR . 'attribute_file'); + ->defaultValue('%metamodels.cache_dir%' . DIRECTORY_SEPARATOR . 'attribute_file') + ->end(); + $children->booleanNode('file_usage')->defaultValue(false)->end(); return $treeBuilder; } diff --git a/src/DependencyInjection/MetaModelsAttributeFileExtension.php b/src/DependencyInjection/MetaModelsAttributeFileExtension.php index 1e87d9c..38d6790 100644 --- a/src/DependencyInjection/MetaModelsAttributeFileExtension.php +++ b/src/DependencyInjection/MetaModelsAttributeFileExtension.php @@ -3,7 +3,7 @@ /** * This file is part of MetaModels/attribute_file. * - * (c) 2012-2024 The MetaModels team. + * (c) 2012-2025 The MetaModels team. * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -14,13 +14,14 @@ * @author Christian Schiffler * @author Sven Baumann * @author Ingolf Steinhardt - * @copyright 2012-2024 The MetaModels team. + * @copyright 2012-2025 The MetaModels team. * @license https://github.com/MetaModels/attribute_file/blob/master/LICENSE LGPL-3.0-or-later * @filesource */ namespace MetaModels\AttributeFileBundle\DependencyInjection; +use InspiredMinds\ContaoFileUsage\ContaoFileUsageBundle; use MetaModels\AttributeFileBundle\EventListener\DcGeneral\Table\DcaSetting\FileWidgetModeOptions; use MetaModels\ContaoFrontendEditingBundle\MetaModelsContaoFrontendEditingBundle; use Symfony\Component\Cache\Adapter\ArrayAdapter; @@ -57,18 +58,23 @@ public function load(array $configs, ContainerBuilder $container): void $config = $this->processConfiguration($configuration, $configs); $this->buildCacheService($container, $config); - $frontendEditing = false; - $bundles = $container->getParameter('kernel.bundles'); assert(is_array($bundles)); - // Load configuration for the frontend editing. + + // Load configuration for the frontend editing extension. + $frontendEditing = false; if (in_array(MetaModelsContaoFrontendEditingBundle::class, $bundles, true)) { $frontendEditing = true; $loader->load('frontend_editing/event_listener.yml'); } - $this->addFrontendEditingArgument($container, $frontendEditing); + // Load configuration for the file usage extension. + if (in_array(ContaoFileUsageBundle::class, $bundles, true) && (bool) ($config['file_usage'] ?? false)) { + $loader->load('file_usage/services.yml'); + } + + // Schema manager $typeNames = $container->hasParameter('metamodels.managed-schema-type-names') ? $container->getParameter('metamodels.managed-schema-type-names') : null; @@ -96,9 +102,9 @@ public function getConfiguration(array $config, ContainerBuilder $container): ?C * * @return void */ - private function buildCacheService(ContainerBuilder $container, array $config) + private function buildCacheService(ContainerBuilder $container, array $config): void { - // if cache disabled, swap it out with the dummy cache. + // If cache disabled, swap it out with the dummy cache. if (!$config['enable_cache']) { $cache = $container->getDefinition('metamodels.attribute_file.cache_system'); $cache->setClass(ArrayAdapter::class); diff --git a/src/Resources/config/file_usage/services.yml b/src/Resources/config/file_usage/services.yml new file mode 100644 index 0000000..63e41d7 --- /dev/null +++ b/src/Resources/config/file_usage/services.yml @@ -0,0 +1,11 @@ +services: + MetaModels\AttributeFileBundle\FileUsage\FileUsageProvider: + public: true + arguments: + $factory: '@metamodels.factory' + $urlGenerator: '@router' + $requestStack: '@request_stack' + $csrfTokenManager: '@contao.csrf.token_manager' + $csrfTokenName: '%contao.csrf_token_name%' + tags: + - { name: contao_file_usage.provider } diff --git a/src/Resources/config/services.yml b/src/Resources/config/services.yml index 9fb8c94..9c59da6 100644 --- a/src/Resources/config/services.yml +++ b/src/Resources/config/services.yml @@ -32,14 +32,3 @@ services: - '@metamodels.table_manipulator' tags: - name: contao.migration - - MetaModels\AttributeFileBundle\FileUsage\FileUsageProvider: - public: true - arguments: - $factory: '@metamodels.factory' - $urlGenerator: '@router' - $requestStack: '@request_stack' - $csrfTokenManager: '@contao.csrf.token_manager' - $csrfTokenName: '%contao.csrf_token_name%' - tags: - - { name: contao_file_usage.provider }