Skip to content

Commit

Permalink
[Bug] Workspaces from non writeable configurations cannot be updated
Browse files Browse the repository at this point in the history
  • Loading branch information
mcop1 committed Feb 23, 2022
1 parent aa982b8 commit 54673a5
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 3 deletions.
8 changes: 5 additions & 3 deletions doc/20_Deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,23 @@ When deploying configurations following steps are necessary:
- 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`
- Rebuild workspaces by running `datahub:configuration:rebuild-workspaces`


Either call
```bash
datahub:graphql:rebuild-definitions
datahub:configuration:rebuild-workspaces
```
to do that for all definitions, or


```bash
datahub:graphql:rebuild-definitions --definitions=newsapp,otherendpoint
datahub:configuration:rebuild-workspaces --configs=assets,events
```
for specific definitions.

>Note: The command ```datahub:graphql:rebuild-definitions ``` is marked as deprecated and will be removed in a future release.
### Configuration Storage

The configuration user interface utilizes the `LocationAwareConfigRepository` for storing the configuration. With
Expand Down
93 changes: 93 additions & 0 deletions src/Command/Configuration/RebuildWorkspacesCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?php

/**
* Pimcore
*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - Pimcore Commercial License (PCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org)
* @license http://www.pimcore.org/license GPLv3 and PCL
*/

namespace Pimcore\Bundle\DataHubBundle\Command\Configuration;

use Pimcore\Bundle\DataHubBundle\Configuration;
use Pimcore\Bundle\DataHubBundle\WorkspaceHelper;
use Pimcore\Console\AbstractCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

class RebuildWorkspacesCommand extends AbstractCommand
{
/**
* {@inheritDoc}
*/
protected function configure()
{
$this
->setName('datahub:configuration:rebuild-workspaces')
->setDescription('Migrate workspaces from configuration files to database.')
->addOption(
'configs',
null,
InputOption::VALUE_OPTIONAL,
'Comma separated list of configurations'
);
}

/**
*
* @param InputInterface $input
* @param OutputInterface $output
*
* @return int|null
*
* @throws \Exception
*/
public function execute(InputInterface $input, OutputInterface $output)
{
$list = [];
$options = $input->getOption('configs');
if ($options) {
$option = $input->getOption('configs');
$configs = explode(',', $option);
foreach($configs as $configFromOption) {
$config = Configuration::getByName($configFromOption);
if (!$config) {
$this->output->writeln('<error>Config ' . $configFromOption . ': Not found.</error>');
}
else {
$list[] = $config;
}
}
} else {
$list = Configuration::getList();
}

foreach ($list as $config) {
$configName = $config->getName();
$this->output->writeln("Config $configName: Processing ...");
$workspaces = $config->getConfiguration()['workspaces'] ?? null;
if(isset($workspaces) === true && count($workspaces) > 0) {
$workspaces = WorkspaceHelper::cleanupWorkspaces($workspaces);
WorkspaceHelper::saveWorkspaces($config, $workspaces);
$this->output->writeln("Config $configName: Workspaces saved.");
}
else {
$this->output->writeln("Config $configName: No workspaces found.");
}
}

if (defined('Symfony\Component\Console\Command\Command::SUCCESS')) {
return Command::SUCCESS;
} else {
return 0;
}
}
}
3 changes: 3 additions & 0 deletions src/Command/GraphQL/RebuildDefinitionsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ protected function configure()
}

/**
*
* @deprecated Use Pimcore\Bundle\DataHubBundle\Command\Configuration\RebuildWorkspacesCommand instead.
*
* @param InputInterface $input
* @param OutputInterface $output
*
Expand Down

0 comments on commit 54673a5

Please sign in to comment.