Skip to content

Commit

Permalink
IBX-426: Created additional UDW config for adding Location to Content (
Browse files Browse the repository at this point in the history
…#1772)

* IBX-426: Created additional UDW config for adding Location to Content

* IBX-426: CS

* IBX-426: Applied review remark
  • Loading branch information
barw4 committed Jun 16, 2021
1 parent 4be0503 commit 2e3943d
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/bundle/Resources/config/universal_discovery_widget.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,5 @@ system:
multiple_user_group:
multiple: true
allowed_content_types: ['user_group']
add_location:
multiple: false
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@

{% macro table_header_tools(form_add, form_remove, can_add) %}
<button
data-udw-config="{{ ez_udw_config('single', {}) }}"
data-udw-config="{{ ez_udw_config('add_location', {}) }}"
class="btn btn-icon btn--udw-add"
title="{{ 'tab.locations.action.add'|trans|desc('Add Location') }}"
{{ not can_add ? 'disabled' }}>
Expand Down
34 changes: 34 additions & 0 deletions src/lib/UniversalDiscovery/Event/Subscriber/AddLocation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

/**
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace EzSystems\EzPlatformAdminUi\UniversalDiscovery\Event\Subscriber;

use EzSystems\EzPlatformAdminUi\UniversalDiscovery\Event\ConfigResolveEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

final class AddLocation implements EventSubscriberInterface
{
public static function getSubscribedEvents(): array
{
return [
ConfigResolveEvent::NAME => ['onUdwConfigResolve', -10],
];
}

public function onUdwConfigResolve(ConfigResolveEvent $event): void
{
if ($event->getConfigName() !== 'add_location') {
return;
}

$config = $event->getConfig();
$config['allowed_content_types'] = null;

$event->setConfig($config);
}
}

0 comments on commit 2e3943d

Please sign in to comment.