Skip to content

Commit a2f392f

Browse files
authored
improve bundle connector management (#193)
1 parent 977b1a2 commit a2f392f

File tree

11 files changed

+56
-107
lines changed

11 files changed

+56
-107
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ The Toolbox is a Kickstarter for your every day project. It provides some import
1515

1616
| Release | Supported Pimcore Versions | Supported Symfony Versions | Release Date | Maintained | Branch |
1717
|---------|-----------------------------------|----------------------------|--------------|----------------|------------|
18-
| **4.x** | `10.1` - `10.5` | `5.4` | 01.10.2021 | Feature Branch | master |
18+
| **4.x** | `10.5` - `10.6 ` | `5.4` | 01.10.2021 | Feature Branch | master |
1919
| **3.x** | `6.0` - `6.9` | `3.4`, `^4.4` | 16.07.2019 | Unsupported | 3.x |
2020
| **2.8** | `5.4`, `5.5`, `5.6`, `5.7`, `5.8` | `3.4` | 30.06.2019 | Unsupported | 2.8 |
2121
| **1.8** | `4.0` | -- | 28.04.2017 | Unsupported | pimcore4 |
@@ -24,7 +24,7 @@ The Toolbox is a Kickstarter for your every day project. It provides some import
2424

2525
```json
2626
"require" : {
27-
"dachcom-digital/toolbox" : "~4.0.0"
27+
"dachcom-digital/toolbox" : "~4.1.0"
2828
}
2929
```
3030

UPGRADE.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Upgrade Notes
22

3+
## Version 4.1.0
4+
- [FEATURE] PIMCORE 10.5 support only
5+
- [IMPROVEMENT] Compatibility with Members 4.1 added
6+
- [IMPROVEMENT] Remove unused js classes
7+
- [BUGFIX] [VHS Element] Use right element context in video type selector
8+
39
## Version 4.0.10
410
- [BUGFIX] fix case sensitivity for accordion in bootstrap3 theme `Resources/views/toolbox/bootstrap3/accordion/partial/Accordion => Resources/views/toolbox/bootstrap3/accordion/partial/accordion`
511

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
}
3232
},
3333
"require": {
34-
"pimcore/pimcore": "^10.1"
34+
"pimcore/pimcore": "^10.5"
3535
},
3636
"require-dev": {
3737
"codeception/codeception": "^4.1",

src/ToolboxBundle/Connector/BundleConnector.php

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,16 @@
22

33
namespace ToolboxBundle\Connector;
44

5-
use Pimcore\Extension\Bundle\PimcoreBundleManager;
65
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
76

87
class BundleConnector
98
{
10-
protected PimcoreBundleManager $bundleManager;
9+
protected array $activeBundles = [];
1110
protected array $services = [];
1211

13-
public function __construct(PimcoreBundleManager $bundleManager)
12+
public function addActiveBundle(string $bundleName): void
1413
{
15-
$this->bundleManager = $bundleManager;
14+
$this->activeBundles[$bundleName] = true;
1615
}
1716

1817
public function registerBundleService(string $serviceId, mixed $service): void
@@ -29,14 +28,8 @@ public function getBundleService(string $serviceId): mixed
2928
return $this->services[$serviceId];
3029
}
3130

32-
public function hasBundle(string $bundleName = 'ExtensionBundle\ExtensionBundle'): bool
31+
public function hasBundle(string $bundleName): bool
3332
{
34-
try {
35-
$hasExtension = $this->bundleManager->isEnabled($bundleName);
36-
} catch (\Exception $e) {
37-
$hasExtension = false;
38-
}
39-
40-
return $hasExtension;
33+
return array_key_exists($bundleName, $this->activeBundles);
4134
}
4235
}

src/ToolboxBundle/DependencyInjection/Compiler/MembersBundlePass.php

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,17 @@ public function process(ContainerBuilder $container): void
1818
return;
1919
}
2020

21-
$toolboxBundleConnector = $container->getDefinition(BundleConnector::class);
22-
foreach ($this->getRequiredServices() as $service) {
23-
$toolboxBundleConnector->addMethodCall(
24-
'registerBundleService',
25-
[$service, new Reference($service)]
26-
);
27-
}
28-
}
29-
30-
private function getRequiredServices(): array
31-
{
32-
return [
21+
$requiredServices = [
3322
\MembersBundle\Manager\RestrictionManager::class,
3423
\MembersBundle\Security\RestrictionUri::class,
3524
\MembersBundle\Security\RestrictionQuery::class,
3625
];
26+
27+
$toolboxBundleConnector = $container->getDefinition(BundleConnector::class);
28+
$toolboxBundleConnector->addMethodCall('addActiveBundle', ['MembersBundle']);
29+
30+
foreach ($requiredServices as $service) {
31+
$toolboxBundleConnector->addMethodCall('registerBundleService', [$service, new Reference($service)]);
32+
}
3733
}
3834
}

src/ToolboxBundle/Document/Areabrick/Download/Download.php

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace ToolboxBundle\Document\Areabrick\Download;
44

5+
use Doctrine\DBAL\Query\QueryBuilder;
56
use Pimcore\Model\Document\Editable\Relations;
67
use Symfony\Component\HttpFoundation\Response;
78
use ToolboxBundle\Connector\BundleConnector;
@@ -11,11 +12,8 @@
1112

1213
class Download extends AbstractAreabrick
1314
{
14-
protected BundleConnector $bundleConnector;
15-
16-
public function __construct(BundleConnector $bundleConnector)
15+
public function __construct(protected BundleConnector $bundleConnector)
1716
{
18-
$this->bundleConnector = $bundleConnector;
1917
}
2018

2119
public function action(Info $info): ?Response
@@ -44,7 +42,7 @@ public function action(Info $info): ?Response
4442

4543
protected function getByFile(Asset $node): array
4644
{
47-
if (!$this->hasMembersBundle()) {
45+
if (!$this->bundleConnector->hasBundle('MembersBundle')) {
4846
return [$node];
4947
}
5048

@@ -64,9 +62,10 @@ protected function getByFolder(Asset\Folder $node): array
6462
$assetListing->addConditionParam('path LIKE ?', $fullPath . '%');
6563
$assetListing->addConditionParam('type != ?', 'folder');
6664

67-
if ($this->hasMembersBundle()) {
68-
$assetListing->onCreateQueryBuilder(function (\Doctrine\DBAL\Query\QueryBuilder $query) use ($assetListing) {
69-
$this->bundleConnector->getBundleService(\MembersBundle\Security\RestrictionQuery::class)
65+
if ($this->bundleConnector->hasBundle('MembersBundle')) {
66+
$assetListing->onCreateQueryBuilder(function (QueryBuilder $query) use ($assetListing) {
67+
$this->bundleConnector
68+
->getBundleService(\MembersBundle\Security\RestrictionQuery::class)
7069
->addRestrictionInjection($query, $assetListing, 'id');
7170
});
7271
}
@@ -77,11 +76,6 @@ protected function getByFolder(Asset\Folder $node): array
7776
return $assetListing->getAssets();
7877
}
7978

80-
protected function hasMembersBundle(): bool
81-
{
82-
return $this->bundleConnector->hasBundle('MembersBundle\MembersBundle');
83-
}
84-
8579
public function getName(): string
8680
{
8781
return 'Downloads';

src/ToolboxBundle/Resources/public/js/backend/toolbox.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/ToolboxBundle/Resources/public/js/document/editables/vhs/editor.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,11 @@ pimcore.plugin.toolbox.vhs.editor = Class.create({
9393
}.bind(this),
9494
keyup: function (el) {
9595
if ((el.getValue().indexOf('youtu.be') >= 0 || el.getValue().indexOf('youtube.com') >= 0) && el.getValue().indexOf('http') >= 0) {
96-
this.up('form').getComponent('type').setValue('youtube');
96+
el.up('form').getComponent('type').setValue('youtube');
9797
} else if (el.getValue().indexOf('vimeo') >= 0 && el.getValue().indexOf('http') >= 0) {
98-
this.up('form').getComponent('type').setValue('vimeo');
98+
el.up('form').getComponent('type').setValue('vimeo');
9999
} else if ((el.getValue().indexOf('dai.ly') >= 0 || el.getValue().indexOf('dailymotion') >= 0) && el.getValue().indexOf('http') >= 0) {
100-
this.up('form').getComponent('type').setValue('dailymotion');
100+
el.up('form').getComponent('type').setValue('dailymotion');
101101
}
102102
}.bind(this)
103103
}
@@ -334,7 +334,6 @@ pimcore.plugin.toolbox.vhs.editor = Class.create({
334334
values['videoParameter'] = videoParameter;
335335

336336
return values;
337-
338337
},
339338

340339
hideWindow: function () {
@@ -344,7 +343,6 @@ pimcore.plugin.toolbox.vhs.editor = Class.create({
344343
this.form = {};
345344

346345
document.body.classList.remove('toolbox-modal-open');
347-
348346
},
349347

350348
onNodeOver: function (target, dd, e, data) {

src/ToolboxBundle/Resources/public/js/startup.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/ToolboxBundle/ToolboxBundle.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,13 @@ public function getJsPaths(): array
4141
return [
4242
'/admin/toolbox-ckeditor-object-style.js',
4343
'/bundles/toolbox/js/toolbox-ckeditor-plugins.js',
44-
'/bundles/toolbox/js/document/edit.js',
45-
'/bundles/toolbox/js/startup.js',
44+
'/bundles/toolbox/js/document/edit.js'
4645
];
4746
}
4847

4948
public function getEditmodeJsPaths(): array
5049
{
5150
return [
52-
'/bundles/toolbox/js/backend/toolbox.js',
5351
'/bundles/toolbox/js/toolbox-ckeditor-plugins.js',
5452
'/bundles/toolbox/js/document/editables/areablock.js',
5553
'/bundles/toolbox/js/document/editables/googlemap.js',

0 commit comments

Comments
 (0)