Skip to content

Fix services for file usage #109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .composer-require-checker.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"Contao\\ManagerPlugin\\Bundle\\Parser\\ParserInterface",
"Contao\\ManagerPlugin\\Routing\\RoutingPluginInterface",
"MetaModels\\ContaoFrontendEditingBundle\\MetaModelsContaoFrontendEditingBundle",
"InspiredMinds\\ContaoFileUsage\\ContaoFileUsageBundle",
"InspiredMinds\\ContaoFileUsage\\Provider\\FileUsageProviderInterface",
"InspiredMinds\\ContaoFileUsage\\Result\\FileTreeMultipleResult",
"InspiredMinds\\ContaoFileUsage\\Result\\FileTreeSingleResult",
Expand Down
22 changes: 14 additions & 8 deletions src/DependencyInjection/MetaModelsAttributeFileExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* This file is part of MetaModels/attribute_file.
*
* (c) 2012-2024 The MetaModels team.
* (c) 2012-2025 The MetaModels team.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -14,13 +14,14 @@
* @author Christian Schiffler <c.schiffler@cyberspectrum.de>
* @author Sven Baumann <baumann.sv@gmail.com>
* @author Ingolf Steinhardt <info@e-spin.de>
* @copyright 2012-2024 The MetaModels team.
* @copyright 2012-2025 The MetaModels team.
* @license https://github.com/MetaModels/attribute_file/blob/master/LICENSE LGPL-3.0-or-later
* @filesource
*/

namespace MetaModels\AttributeFileBundle\DependencyInjection;

use InspiredMinds\ContaoFileUsage\ContaoFileUsageBundle;
use MetaModels\AttributeFileBundle\EventListener\DcGeneral\Table\DcaSetting\FileWidgetModeOptions;
use MetaModels\ContaoFrontendEditingBundle\MetaModelsContaoFrontendEditingBundle;
use Symfony\Component\Cache\Adapter\ArrayAdapter;
Expand Down Expand Up @@ -57,18 +58,23 @@ public function load(array $configs, ContainerBuilder $container): void
$config = $this->processConfiguration($configuration, $configs);
$this->buildCacheService($container, $config);

$frontendEditing = false;

$bundles = $container->getParameter('kernel.bundles');
assert(is_array($bundles));
// Load configuration for the frontend editing.

// Load configuration for the frontend editing extension.
$frontendEditing = false;
if (in_array(MetaModelsContaoFrontendEditingBundle::class, $bundles, true)) {
$frontendEditing = true;
$loader->load('frontend_editing/event_listener.yml');
}

$this->addFrontendEditingArgument($container, $frontendEditing);

// Load configuration for the file usage extension.
if (in_array(ContaoFileUsageBundle::class, $bundles, true)) {
$loader->load('file_usage/services.yml');
}

// Schema manager
$typeNames = $container->hasParameter('metamodels.managed-schema-type-names')
? $container->getParameter('metamodels.managed-schema-type-names')
: null;
Expand Down Expand Up @@ -96,9 +102,9 @@ public function getConfiguration(array $config, ContainerBuilder $container): ?C
*
* @return void
*/
private function buildCacheService(ContainerBuilder $container, array $config)
private function buildCacheService(ContainerBuilder $container, array $config): void
{
// if cache disabled, swap it out with the dummy cache.
// If cache disabled, swap it out with the dummy cache.
if (!$config['enable_cache']) {
$cache = $container->getDefinition('metamodels.attribute_file.cache_system');
$cache->setClass(ArrayAdapter::class);
Expand Down
11 changes: 11 additions & 0 deletions src/Resources/config/file_usage/services.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
services:
# MetaModels\AttributeFileBundle\FileUsage\FileUsageProvider:
# public: true
# arguments:
# $factory: '@metamodels.factory'
# $urlGenerator: '@router'
# $requestStack: '@request_stack'
# $csrfTokenManager: '@contao.csrf.token_manager'
# $csrfTokenName: '%contao.csrf_token_name%'
# tags:
# - { name: contao_file_usage.provider }
11 changes: 0 additions & 11 deletions src/Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,3 @@ services:
- '@metamodels.table_manipulator'
tags:
- name: contao.migration

MetaModels\AttributeFileBundle\FileUsage\FileUsageProvider:
public: true
arguments:
$factory: '@metamodels.factory'
$urlGenerator: '@router'
$requestStack: '@request_stack'
$csrfTokenManager: '@contao.csrf.token_manager'
$csrfTokenName: '%contao.csrf_token_name%'
tags:
- { name: contao_file_usage.provider }