Skip to content

Commit

Permalink
Merge pull request #73 from kjkooistra-youwe/chore/pimcore10.6Compati…
Browse files Browse the repository at this point in the history
…bility

chore: Pimcore 10.6 compatibility
  • Loading branch information
kjkooistra-youwe authored Jul 14, 2023
2 parents 36ee4bc + 2b234d5 commit 64ce8d3
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 44 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
],
"require": {
"php": "^8.0",
"pimcore/pimcore": "^10.0.0"
"pimcore/pimcore": "^10.6.0"
},
"autoload": {
"psr-4": {
Expand Down
29 changes: 11 additions & 18 deletions src/WorkflowGui/Controller/WorkflowController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@

namespace Youwe\Pimcore\WorkflowGui\Controller;

use Pimcore\Bundle\AdminBundle\Controller\AdminController;
use Pimcore\Bundle\CoreBundle\DependencyInjection\Configuration;
use Pimcore\Cache\Symfony\CacheClearer;
use Pimcore\Controller\Traits\JsonHelperTrait;
use Pimcore\Controller\UserAwareController;
use Pimcore\Model\User;
use Pimcore\Tool\Console;
use Symfony\Component\Config\Definition\Processor;
Expand All @@ -32,24 +33,16 @@
use Youwe\Pimcore\WorkflowGui\Repository\WorkflowRepositoryInterface;
use Youwe\Pimcore\WorkflowGui\Resolver\ConfigFileResolverInterface;

class WorkflowController extends AdminController
class WorkflowController extends UserAwareController
{
protected WorkflowRepositoryInterface $repository;
protected ConfigFileResolverInterface $configResolver;
protected KernelInterface $kernel;
protected CacheClearer $cacheClearer;
use JsonHelperTrait;

public function __construct(
WorkflowRepositoryInterface $repository,
ConfigFileResolverInterface $configFileResolver,
KernelInterface $kernel,
CacheClearer $cacheClearer
) {
$this->repository = $repository;
$this->configResolver = $configFileResolver;
$this->kernel = $kernel;
$this->cacheClearer = $cacheClearer;
}
protected WorkflowRepositoryInterface $repository,
protected ConfigFileResolverInterface $configFileResolver,
protected KernelInterface $kernel,
protected CacheClearer $cacheClearer,
) {}

public function listAction(): JsonResponse
{
Expand Down Expand Up @@ -198,15 +191,15 @@ public function searchRolesAction(Request $request): JsonResponse
}
}

return $this->adminJson([
return $this->jsonResponse([
'success' => true,
'roles' => $roles,
]);
}

protected function isGrantedOr403(): void
{
$user = $this->getAdminUser();
$user = $this->getPimcoreUser();

if (null === $user) {
throw new AccessDeniedException();
Expand Down
9 changes: 3 additions & 6 deletions src/WorkflowGui/Repository/WorkflowRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,9 @@

class WorkflowRepository implements WorkflowRepositoryInterface
{
protected ConfigFileResolverInterface $configFileResolver;

public function __construct(ConfigFileResolverInterface $configFileResolver)
{
$this->configFileResolver = $configFileResolver;
}
public function __construct(
protected ConfigFileResolverInterface $configFileResolver,
) {}

public function findAll(): array
{
Expand Down
9 changes: 3 additions & 6 deletions src/WorkflowGui/Resolver/ConfigFileResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,9 @@

class ConfigFileResolver implements ConfigFileResolverInterface
{
protected string $configFile;

public function __construct(string $configFile)
{
$this->configFile = $configFile;
}
public function __construct(
protected string $configFile,
) {}

public function getConfigPath(): string
{
Expand Down
2 changes: 2 additions & 0 deletions src/WorkflowGui/Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ services:
- { name: controller.service_arguments }
calls:
- { method: setContainer, arguments: [ '@service_container' ] }
- { method: setTokenResolver, arguments: [ '@Pimcore\Security\User\TokenStorageUserResolver' ] }
- { method: setPimcoreSerializer, arguments: [ '@pimcore.serializer' ] }
21 changes: 8 additions & 13 deletions src/WorkflowGui/Resources/public/js/pimcore/startup.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,14 @@
* @license https://github.com/YouweGit/pimcore-workflow-gui/blob/master/LICENSE.md GNU General Public License version 3 (GPLv3)
*/

pimcore.registerNS('pimcore.plugin.WorkflowGuiBundle');
pimcore.registerNS('pimcore.plugin.WorkflowGuiBundle.startup');

pimcore.plugin.WorkflowGuiBundle = Class.create(pimcore.plugin.admin, {
getClassName: function () {
return 'pimcore.plugin.WorkflowGuiBundle';
},

initialize: function () {
pimcore.plugin.broker.registerPlugin(this);
},

pimcoreReady: function (params,broker) {
pimcore.plugin.WorkflowGuiBundle.startup = {
addMenuItem: function () {
var user = pimcore.globalmanager.get('user');
var perspectiveCfg = pimcore.globalmanager.get('perspective');

if(user.isAllowed('workflow_gui') && perspectiveCfg.inToolbar('settings.workflow_gui')) {
if (user.isAllowed('workflow_gui') && perspectiveCfg.inToolbar('settings.workflow_gui')) {
var settingsMenu = new Ext.Action({
text: t('workflows'),
icon: '/bundles/pimcoreadmin/img/flat-white-icons/workflow.svg',
Expand All @@ -45,6 +37,9 @@ pimcore.plugin.WorkflowGuiBundle = Class.create(pimcore.plugin.admin, {
pimcore.globalmanager.add('workflows', new pimcore.plugin.workflow.panel());
}
},
};

document.addEventListener(pimcore.events.pimcoreReady, function () {
pimcore.plugin.WorkflowGuiBundle.startup.addMenuItem();
});

var WorkflowGuiBundlePlugin = new pimcore.plugin.WorkflowGuiBundle();

0 comments on commit 64ce8d3

Please sign in to comment.