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 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 diff --git a/src/Configuration/Dao.php b/src/Configuration/Dao.php index 81c9074d..df62b2f4 100644 --- a/src/Configuration/Dao.php +++ b/src/Configuration/Dao.php @@ -24,6 +24,8 @@ * Class Dao * * @package Pimcore\Bundle\DataHubBundle\Configuration + * + * @property Configuration $model */ class Dao extends Model\Dao\PimcoreLocationAwareConfigDao { @@ -65,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(); @@ -238,7 +240,7 @@ public static function getList(): array /** * @param string $id - * @param $data + * @param mixed $data * * @return \array[][][] */ 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(); 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(); } 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(); } 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'); } /** diff --git a/src/WorkspaceHelper.php b/src/WorkspaceHelper.php index 64e8c07b..b3c16031 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 ($element->getId()) { + $parentIds[] = $element->getId(); + } try { $db = Db::get();