Skip to content
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
8 changes: 8 additions & 0 deletions importmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,12 @@
'@symfony/ux-live-component' => [
'path' => './vendor/symfony/ux-live-component/assets/dist/live_controller.js',
],
'tom-select/dist/css/tom-select.bootstrap4.css' => [

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need both?

@loic425 loic425 Sep 25, 2025

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's automatical now, after the composer install. Here, it's only on the test application.

'version' => '2.4.3',
'type' => 'css',
],
'tom-select/dist/css/tom-select.bootstrap5.css' => [
'version' => '2.4.3',
'type' => 'css',
],
];
14 changes: 14 additions & 0 deletions src/AdminUi/config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

use Sylius\AdminUi\Context\Context;
use Sylius\AdminUi\Context\RoutingContext;
use Sylius\AdminUi\Knp\Menu\MenuBuilder;
use Sylius\AdminUi\Knp\Menu\MenuBuilderInterface;
use Sylius\AdminUi\TwigHooks\Hookable\Metadata\RoutingHookableMetadataFactory;
Expand All @@ -35,4 +37,16 @@
param('sylius_admin_ui.routing'),
])
;

$services->set('sylius_admin_ui.routing_context', RoutingContext::class)
->args([
param('sylius_admin_ui.routing'),
])
;

$services->set('sylius_admin_ui.context', Context::class)
->args([
service('sylius_admin_ui.routing_context'),
])
;
};
8 changes: 8 additions & 0 deletions src/AdminUi/config/services/twig/extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

use Sylius\AdminUi\Twig\Extension\ContextExtension;
use Sylius\AdminUi\Twig\Extension\RedirectPathExtension;

return function (ContainerConfigurator $configurator): void {
Expand All @@ -25,4 +26,11 @@
])
->tag(name: 'twig.extension')
;

$services->set('sylius_admin_ui.twig.extension.context', ContextExtension::class)
->args([
service('sylius_admin_ui.context'),
])
->tag(name: 'twig.extension')
;
};
27 changes: 27 additions & 0 deletions src/AdminUi/src/Context/Context.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

/*
* This file is part of the Sylius package.
*
* (c) Sylius Sp. z o.o.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Sylius\AdminUi\Context;

final class Context
{
public function __construct(
private readonly RoutingContext $routing,
) {
}

public function getRouting(): RoutingContext
{
return $this->routing;
}
}
27 changes: 27 additions & 0 deletions src/AdminUi/src/Context/RoutingContext.php

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should both Context and RoutingContext have interfaces? In case I would want to override those classes at end-user projects.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want user to change those contexts for now. That's only to bring access to admin ui configuration.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either interfaces or some other extension point would be great, but yeah, it could be added at a later date.

@loic425 loic425 Sep 25, 2025

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes but before adding some extension point, it's preferable to be stable on data accessors. I think I need to add login path and things like that before. Or just adding the interface on the main context class.

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

/*
* This file is part of the Sylius package.
*
* (c) Sylius Sp. z o.o.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Sylius\AdminUi\Context;

final class RoutingContext
{
public function __construct(
private readonly array $routing,
) {
}

public function getDashboardPath(): string
{
return $this->routing['dashboard_path'] ?? '/admin';
}
}
33 changes: 33 additions & 0 deletions src/AdminUi/src/Twig/Extension/ContextExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

/*
* This file is part of the Sylius package.
*
* (c) Sylius Sp. z o.o.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Sylius\AdminUi\Twig\Extension;

use Sylius\AdminUi\Context\Context;
use Twig\Extension\AbstractExtension;
use Twig\Extension\GlobalsInterface;

final class ContextExtension extends AbstractExtension implements GlobalsInterface
{
public function __construct(
private readonly Context $context,
) {
}

public function getGlobals(): array
{
return [
'sylius_admin_ui_context' => $this->context,
];
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% set dashboard_path = hookable_metadata.context.routing.dashboard_path|default('/admin') %}
{% set dashboard_path = sylius_admin_ui_context.routing.dashboardPath %}

<h1 class="navbar-brand">
<a href="{{ dashboard_path }}">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
)
%}

{% set dashboard_path = hookable_metadata.context.routing.dashboard_path|default('/admin') %}
{% set dashboard_path = sylius_admin_ui_context.routing.dashboardPath %}

{{ breadcrumbs([
{ name: 'sylius.ui.dashboard', url: dashboard_path, active: false },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
{% set title = hookable_metadata.configuration.title %}
{% endif %}

{% set dashboard_path = hookable_metadata.context.routing.dashboard_path|default('/admin') %}
{% set dashboard_path = sylius_admin_ui_context.routing.dashboardPath %}

{{ breadcrumbs([
{ 'name': 'sylius.ui.dashboard', 'url': dashboard_path, 'active': false },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
{% set resource_show = { name: resource_show_name, active: true} %}
{% endif %}

{% set dashboard_path = hookable_metadata.context.routing.dashboard_path|default('/admin') %}
{% set dashboard_path = sylius_admin_ui_context.routing.dashboardPath %}

{{ breadcrumbs([
{ name: 'sylius.ui.dashboard', url: dashboard_path, active: false },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
{% set resource_edit = { name: resource_edit_name, active: true} %}
{% endif %}

{% set dashboard_path = hookable_metadata.context.routing.dashboard_path|default('/admin') %}
{% set dashboard_path = sylius_admin_ui_context.routing.dashboardPath %}

{{ breadcrumbs([
{ name: 'sylius.ui.dashboard', url: dashboard_path, active: false },
Expand Down
9 changes: 9 additions & 0 deletions symfony.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@
"ref": "64d8583af5ea57b7afa4aba4b159907f3a148b05"
}
},
"doctrine/deprecations": {
"version": "1.1",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "1.0",
"ref": "87424683adc81d7dc305eefec1fced883084aab9"
}
},
"doctrine/doctrine-bundle": {
"version": "2.12",
"recipe": {
Expand Down