From 1e6f6f55c5deac3f09b9f9ee6ec9c1398892c091 Mon Sep 17 00:00:00 2001 From: dvesh3 Date: Fri, 19 Nov 2021 15:29:04 +0100 Subject: [PATCH 01/10] [Installer] Proper way of marking bundle installed on upgrade - follow up to https://github.com/pimcore/data-hub/commit/a98b64591c12fa8f5e6dea96d6cb28f6c43626d7 --- src/Installer.php | 18 ------------------ .../PimcoreX/Version20210305134111.php | 9 ++++++++- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/src/Installer.php b/src/Installer.php index cb62c70d..0a799e64 100644 --- a/src/Installer.php +++ b/src/Installer.php @@ -67,24 +67,6 @@ public function install() return true; } - public function isInstalled() - { - // When switching to SettingsStoreAwareInstaller, we need to explicitly mark this bundle installed, if Settingstore entry doesn't exists and datahub permission is installed - // e.g. updating from 1.0.* to 1.1.* - $installEntry = SettingsStore::get($this->getSettingsStoreInstallationId(), 'pimcore'); - if (!$installEntry) { - $db = Db::get(); - $check = $db->fetchOne('SELECT `key` FROM users_permission_definitions where `key` = ?', [ConfigController::CONFIG_NAME]); - if ($check) { - SettingsStore::set('BUNDLE_INSTALLED__Pimcore\\Bundle\\DataHubBundle\\PimcoreDataHubBundle', true, 'bool', 'pimcore'); - - return true; - } - } - - return parent::isInstalled(); - } - public function getLastMigrationVersionClassName(): ?string { return Version20210305134111::class; diff --git a/src/Migrations/PimcoreX/Version20210305134111.php b/src/Migrations/PimcoreX/Version20210305134111.php index 1b9f7153..4c296868 100644 --- a/src/Migrations/PimcoreX/Version20210305134111.php +++ b/src/Migrations/PimcoreX/Version20210305134111.php @@ -17,6 +17,7 @@ use Doctrine\DBAL\Schema\Schema; use Pimcore\Migrations\BundleAwareMigration; +use Pimcore\Model\Tool\SettingsStore; /** * Auto-generated Migration: Please modify to your needs! @@ -28,12 +29,18 @@ protected function getBundleName(): string return 'PimcoreDataHubBundle'; } + protected function checkBundleInstalled() + { + //need to always return true here, as the migration is setting the bundle installed + return true; + } + /** * @param Schema $schema */ public function up(Schema $schema): void { - // nothing to do + SettingsStore::set('BUNDLE_INSTALLED__Pimcore\\Bundle\\DataHubBundle\\PimcoreDataHubBundle', true, 'bool', 'pimcore'); } /** From d7bc9849ff8064ae718c034861f68d63683a4613 Mon Sep 17 00:00:00 2001 From: dvesh3 Date: Fri, 19 Nov 2021 14:29:48 +0000 Subject: [PATCH 02/10] Apply php-cs-fixer changes --- src/Installer.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Installer.php b/src/Installer.php index 0a799e64..24a903f9 100644 --- a/src/Installer.php +++ b/src/Installer.php @@ -20,7 +20,6 @@ use Pimcore\Db; use Pimcore\Extension\Bundle\Installer\SettingsStoreAwareInstaller; use Pimcore\Logger; -use Pimcore\Model\Tool\SettingsStore; class Installer extends SettingsStoreAwareInstaller { From 93274618f0887e6704432fcb657d3caa7b2280da Mon Sep 17 00:00:00 2001 From: Divesh Pahuja Date: Thu, 25 Nov 2021 14:43:25 +0100 Subject: [PATCH 03/10] Compatibility with pimcore/pimcore - resolves #442 --- doc/01_Installation.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/doc/01_Installation.md b/doc/01_Installation.md index 5dd18c46..5e0f3185 100644 --- a/doc/01_Installation.md +++ b/doc/01_Installation.md @@ -1,16 +1,19 @@ # Installation -## Minimum Requirements - -* Pimcore >= 5.7 - ## Install Install bundle via composer: + +For Pimcore version >= 10.2: ```bash composer require pimcore/data-hub ``` +For Pimcore version < 10.2: +```bash +composer require pimcore/data-hub:~1.0.11 +``` + Enable bundle via console or extensions manager: ```bash php bin/console pimcore:bundle:enable PimcoreDataHubBundle @@ -31,4 +34,4 @@ bin/console pimcore:bundle:list ## Required Backend User Permission To access Datahub, user needs to meet one of following criteria: * be an `admin` -* have `plugin_datahub_config` permission \ No newline at end of file +* have `plugin_datahub_config` permission From 67b8105cf494fc3be811e55a8cc4630ec42eb509 Mon Sep 17 00:00:00 2001 From: dvesh3 Date: Mon, 29 Nov 2021 11:55:47 +0100 Subject: [PATCH 04/10] [Config Improvement] Do not normalize key when using symfony-config storage - resolves configuration breaks, if there is "-" in the name #441 --- src/DependencyInjection/Configuration.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 014c932f..7fd45c37 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -55,6 +55,7 @@ private function addConfigurationsNode(ArrayNodeDefinition $rootNode) $rootNode ->children() ->arrayNode('configurations') + ->normalizeKeys(false) ->variablePrototype()->end() ->end() ->end(); From 567f8b0610581a5608ceacf4b3c24197ff441f6d Mon Sep 17 00:00:00 2001 From: dvesh3 Date: Fri, 10 Dec 2021 11:08:15 +0100 Subject: [PATCH 05/10] Update Deployment docs - resolves #445 --- doc/20_Deployment.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/doc/20_Deployment.md b/doc/20_Deployment.md index 8d056575..013b5861 100644 --- a/doc/20_Deployment.md +++ b/doc/20_Deployment.md @@ -1,11 +1,11 @@ # Configuration & Deployment -The configuration is saved in `var/config/datahub-configurations.php`. +The configuration by default is saved in `var/config/data-hub/example.yaml`. Additionally, a workspace permission index is kept in the database for better query performance when -checking for permissions. +checking for permissions. When deploying configurations following steps are necessary: -- Deploy configuration file `var/config/datahub-configurations.php` - e.g. check it into your VCS and +- Deploy configuration file `/var/config/.../example.yaml` - e.g. check it into your VCS and deploy it with your deployment mechanisms. - Rebuild workspace permission index by running `datahub:graphql:rebuild-definitions` @@ -31,6 +31,10 @@ the environment variable `PIMCORE_WRITE_TARGET_DATA_HUB` the storage location ca - `settings-store` - write configs to the SettingsStore - `disabled` - do not allow to edit/write configs at all +> Important: When using symfony-config write target, configs are written to Symfony +Config files (yaml), which are only getting revalidated in debug mode. So if you're changing configs in production you +won't see any update, because these configs are read only. + Details also see [Pimcore Docs](https://pimcore.com/docs/pimcore/current/Development_Documentation/Deployment/Configuration_Environments.html#page_Configuration-Storage-Locations-Fallbacks). #### Example From 4435016bcea6db58e4171b11bc1e55384ba6d661 Mon Sep 17 00:00:00 2001 From: Sebastian Blank Date: Fri, 17 Dec 2021 09:08:51 +0100 Subject: [PATCH 06/10] Configuration: Fix wrong setName() in save() method --- src/Configuration/Dao.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Configuration/Dao.php b/src/Configuration/Dao.php index a793a4b7..df62b2f4 100644 --- a/src/Configuration/Dao.php +++ b/src/Configuration/Dao.php @@ -17,7 +17,6 @@ use Pimcore\Bundle\DataHubBundle\Configuration; use Pimcore\Config; -use Pimcore\File; use Pimcore\Model; use Symfony\Component\Uid\Uuid as Uid; @@ -25,6 +24,8 @@ * Class Dao * * @package Pimcore\Bundle\DataHubBundle\Configuration + * + * @property Configuration $model */ class Dao extends Model\Dao\PimcoreLocationAwareConfigDao { @@ -66,7 +67,7 @@ public function configure() public function save(): void { if (!$this->model->getName()) { - $this->model->getName(Uid::v4()); + $this->model->setName(Uid::v4()); } $ts = time(); @@ -239,7 +240,7 @@ public static function getList(): array /** * @param string $id - * @param $data + * @param mixed $data * * @return \array[][][] */ From 8fc72a7151261c8270a14975bae273caed29f9fc Mon Sep 17 00:00:00 2001 From: Sebastian Blank Date: Fri, 17 Dec 2021 09:14:48 +0100 Subject: [PATCH 07/10] Fix usage of FieldcollectionDefinition and ObjectbrickDefinition --- .../Fieldcollections.php | 2 +- .../AbstractTable.php | 9 +++++---- src/GraphQL/DataObjectType/BlockEntryType.php | 2 -- src/GraphQL/DataObjectType/MultihrefMetadataType.php | 2 +- src/GraphQL/DataObjectType/ObjectMetadataType.php | 9 +++++---- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/GraphQL/DataObjectMutationFieldConfigGenerator/Fieldcollections.php b/src/GraphQL/DataObjectMutationFieldConfigGenerator/Fieldcollections.php index 13b3a9cd..23f482f6 100644 --- a/src/GraphQL/DataObjectMutationFieldConfigGenerator/Fieldcollections.php +++ b/src/GraphQL/DataObjectMutationFieldConfigGenerator/Fieldcollections.php @@ -42,7 +42,7 @@ public function getGraphQlMutationFieldConfig($nodeDef, $class, $container = nul $allowedFcTypes = []; foreach ($list as $fcDef) { - $allowedFcTypes[] = $fcDef->getName(); + $allowedFcTypes[] = $fcDef->getKey(); } } diff --git a/src/GraphQL/DataObjectQueryFieldConfigGenerator/AbstractTable.php b/src/GraphQL/DataObjectQueryFieldConfigGenerator/AbstractTable.php index 4ffc546a..c5ff2fd1 100644 --- a/src/GraphQL/DataObjectQueryFieldConfigGenerator/AbstractTable.php +++ b/src/GraphQL/DataObjectQueryFieldConfigGenerator/AbstractTable.php @@ -22,7 +22,8 @@ use GraphQL\Type\Definition\Type; use Pimcore\Bundle\DataHubBundle\GraphQL\Service; use Pimcore\Model\DataObject\ClassDefinition\Data; -use Pimcore\Model\DataObject\Fieldcollection\Definition; +use Pimcore\Model\DataObject\Fieldcollection\Definition as FieldcollectionDefinition; +use Pimcore\Model\DataObject\Objectbrick\Definition as ObjectbrickDefinition; abstract class AbstractTable extends Base { @@ -81,10 +82,10 @@ function ($k) { */ public function getFieldType(Data $fieldDefinition, $class = null, $container = null) { - if ($class instanceof Definition) { - $name = 'fieldcollection_' . $class->getKey() . '_' . $fieldDefinition->getName(); - } elseif ($class instanceof \Pimcore\Model\DataObject\Objectbrick\Definition) { + if ($class instanceof ObjectbrickDefinition) { $name = 'objectbrick_' . $class->getKey() . '_' . $fieldDefinition->getName(); + } elseif ($class instanceof FieldcollectionDefinition) { + $name = 'fieldcollection_' . $class->getKey() . '_' . $fieldDefinition->getName(); } else { $name = 'object_' . $class->getName() . '_' . $fieldDefinition->getName(); } diff --git a/src/GraphQL/DataObjectType/BlockEntryType.php b/src/GraphQL/DataObjectType/BlockEntryType.php index 7136e8f5..f0ecb34d 100644 --- a/src/GraphQL/DataObjectType/BlockEntryType.php +++ b/src/GraphQL/DataObjectType/BlockEntryType.php @@ -81,8 +81,6 @@ public function build(&$config) { if ($this->class instanceof Definition) { $name = $this->class->getKey(); - } elseif ($this->class instanceof \Pimcore\Model\DataObject\Objectbrick\Definition) { - $name = $this->class->getKey(); } else { $name = $this->class->getName(); } diff --git a/src/GraphQL/DataObjectType/MultihrefMetadataType.php b/src/GraphQL/DataObjectType/MultihrefMetadataType.php index a3a9b5f1..9e8e72fd 100644 --- a/src/GraphQL/DataObjectType/MultihrefMetadataType.php +++ b/src/GraphQL/DataObjectType/MultihrefMetadataType.php @@ -48,7 +48,7 @@ public function __construct(Service $graphQlService, Data $fieldDefinition = nul $this->class = $class; $this->setGraphQlService($graphQlService); $this->fieldDefinition = $fieldDefinition; - $name = ($class instanceof Definition || $class instanceof \Pimcore\Model\DataObject\Objectbrick\Definition) ? $class->getKey() : $class->getName(); + $name = ($class instanceof Definition) ? $class->getKey() : $class->getName(); $config['name'] = 'object_'.$name.'_'.$fieldDefinition->getName(); $this->build($config); diff --git a/src/GraphQL/DataObjectType/ObjectMetadataType.php b/src/GraphQL/DataObjectType/ObjectMetadataType.php index e9165ee1..bc4bdcff 100644 --- a/src/GraphQL/DataObjectType/ObjectMetadataType.php +++ b/src/GraphQL/DataObjectType/ObjectMetadataType.php @@ -22,7 +22,8 @@ use Pimcore\Bundle\DataHubBundle\GraphQL\Service; use Pimcore\Bundle\DataHubBundle\GraphQL\Traits\ServiceTrait; use Pimcore\Model\DataObject\ClassDefinition\Data; -use Pimcore\Model\DataObject\Fieldcollection\Definition; +use Pimcore\Model\DataObject\Fieldcollection\Definition as FieldcollectionDefinition; +use Pimcore\Model\DataObject\Objectbrick\Definition as ObjectbrickDefinition; class ObjectMetadataType extends ObjectType { @@ -46,10 +47,10 @@ public function __construct(Service $graphQlService, Data $fieldDefinition = nul $this->setGraphQLService($graphQlService); $this->class = $class; $this->fieldDefinition = $fieldDefinition; - if ($class instanceof Definition) { - $config['name'] = 'fieldcollection_' . $class->getKey() . '_' . $fieldDefinition->getName(); - } elseif ($class instanceof \Pimcore\Model\DataObject\Objectbrick\Definition) { + if ($class instanceof ObjectbrickDefinition) { $config['name'] = 'objectbrick_' . $class->getKey() . '_' . $fieldDefinition->getName(); + } elseif ($class instanceof FieldcollectionDefinition) { + $config['name'] = 'fieldcollection_' . $class->getKey() . '_' . $fieldDefinition->getName(); } else { $config['name'] = 'object_' . $class->getName() . '_' . $fieldDefinition->getName(); } From d3ad922bd20bfec01f8961994a16bd4199f8397e Mon Sep 17 00:00:00 2001 From: weisswurstkanone Date: Thu, 13 Jan 2022 16:54:36 +0100 Subject: [PATCH 08/10] Querying on inputQuantityValue from Classificationstore returns null values (always) #454 --- src/GraphQL/Resolver/QuantityValue.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/GraphQL/Resolver/QuantityValue.php b/src/GraphQL/Resolver/QuantityValue.php index 19315eea..ee281f6b 100644 --- a/src/GraphQL/Resolver/QuantityValue.php +++ b/src/GraphQL/Resolver/QuantityValue.php @@ -17,6 +17,7 @@ use GraphQL\Type\Definition\ResolveInfo; use Pimcore\Bundle\DataHubBundle\GraphQL\Traits\ServiceTrait; +use Pimcore\Model\DataObject\Data\InputQuantityValue; class QuantityValue { @@ -55,7 +56,7 @@ public function resolveUnit($value = null, $args = [], $context = [], ResolveInf */ public function resolveValue($value = null, $args = [], $context = [], ResolveInfo $resolveInfo = null) { - if ($value instanceof \Pimcore\Model\DataObject\Data\QuantityValue) { + if ($value instanceof \Pimcore\Model\DataObject\Data\QuantityValue || $value instanceof InputQuantityValue) { return $value->getValue(); } From ffe8e35e6e2131a63b82d3198a45a5dc1cb93d72 Mon Sep 17 00:00:00 2001 From: weisswurstkanone Date: Mon, 17 Jan 2022 17:41:15 +0100 Subject: [PATCH 09/10] Fields not set when using create mutation #452 --- src/WorkspaceHelper.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/WorkspaceHelper.php b/src/WorkspaceHelper.php index 64e8c07b..6cf16a40 100644 --- a/src/WorkspaceHelper.php +++ b/src/WorkspaceHelper.php @@ -280,7 +280,9 @@ public static function isAllowed($element, Configuration $configuration, string $parent = $parent->getParent(); } } - $parentIds[] = $element->getId(); + if (!is_null($element->getId())) { + $parentIds[] = $element->getId(); + } try { $db = Db::get(); From 0d9e0767309901d37e80be89a15364a46b892ccc Mon Sep 17 00:00:00 2001 From: Josef Aichhorn Date: Tue, 18 Jan 2022 08:26:54 +0100 Subject: [PATCH 10/10] Update src/WorkspaceHelper.php Co-authored-by: Sebastian Blank --- src/WorkspaceHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/WorkspaceHelper.php b/src/WorkspaceHelper.php index 6cf16a40..b3c16031 100644 --- a/src/WorkspaceHelper.php +++ b/src/WorkspaceHelper.php @@ -280,7 +280,7 @@ public static function isAllowed($element, Configuration $configuration, string $parent = $parent->getParent(); } } - if (!is_null($element->getId())) { + if ($element->getId()) { $parentIds[] = $element->getId(); }