Skip to content

Commit

Permalink
Merge branch '1.1' into 1.x
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/Installer.php
  • Loading branch information
weisswurstkanone committed Jan 18, 2022
2 parents 2d78723 + ce5d758 commit 1bcd67d
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 25 deletions.
13 changes: 8 additions & 5 deletions 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
Expand All @@ -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
* have `plugin_datahub_config` permission
10 changes: 7 additions & 3 deletions 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`
Expand All @@ -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
Expand Down
6 changes: 4 additions & 2 deletions src/Configuration/Dao.php
Expand Up @@ -24,6 +24,8 @@
* Class Dao
*
* @package Pimcore\Bundle\DataHubBundle\Configuration
*
* @property Configuration $model
*/
class Dao extends Model\Dao\PimcoreLocationAwareConfigDao
{
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -238,7 +240,7 @@ public static function getList(): array

/**
* @param string $id
* @param $data
* @param mixed $data
*
* @return \array[][][]
*/
Expand Down
1 change: 1 addition & 0 deletions src/DependencyInjection/Configuration.php
Expand Up @@ -55,6 +55,7 @@ private function addConfigurationsNode(ArrayNodeDefinition $rootNode)
$rootNode
->children()
->arrayNode('configurations')
->normalizeKeys(false)
->variablePrototype()->end()
->end()
->end();
Expand Down
Expand Up @@ -42,7 +42,7 @@ public function getGraphQlMutationFieldConfig($nodeDef, $class, $container = nul

$allowedFcTypes = [];
foreach ($list as $fcDef) {
$allowedFcTypes[] = $fcDef->getName();
$allowedFcTypes[] = $fcDef->getKey();
}
}

Expand Down
Expand Up @@ -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
{
Expand Down Expand Up @@ -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();
}
Expand Down
2 changes: 0 additions & 2 deletions src/GraphQL/DataObjectType/BlockEntryType.php
Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion src/GraphQL/DataObjectType/MultihrefMetadataType.php
Expand Up @@ -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);
Expand Down
9 changes: 5 additions & 4 deletions src/GraphQL/DataObjectType/ObjectMetadataType.php
Expand Up @@ -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
{
Expand All @@ -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();
}
Expand Down
3 changes: 2 additions & 1 deletion src/GraphQL/Resolver/QuantityValue.php
Expand Up @@ -17,6 +17,7 @@

use GraphQL\Type\Definition\ResolveInfo;
use Pimcore\Bundle\DataHubBundle\GraphQL\Traits\ServiceTrait;
use Pimcore\Model\DataObject\Data\InputQuantityValue;

class QuantityValue
{
Expand Down Expand Up @@ -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();
}

Expand Down
9 changes: 8 additions & 1 deletion src/Migrations/PimcoreX/Version20210305134111.php
Expand Up @@ -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!
Expand All @@ -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');
}

/**
Expand Down
4 changes: 3 additions & 1 deletion src/WorkspaceHelper.php
Expand Up @@ -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();
Expand Down

0 comments on commit 1bcd67d

Please sign in to comment.