diff --git a/composer.json b/composer.json index ae107748..80bbf588 100644 --- a/composer.json +++ b/composer.json @@ -6,26 +6,26 @@ "require": { "php": ">=8.1", "ext-json": "*", - "doctrine/collections": "^1.6", - "doctrine/orm": "^2.7", + "doctrine/collections": "^1.6 || ^2.0", + "doctrine/orm": "^2.7 || ^3.0", "doctrine/persistence": "^1.3 || ^2.0 || ^3.0", "knplabs/knp-menu": "^3.1", - "league/flysystem": "^1.1 || ^2.1", - "league/flysystem-bundle": "^1.1 || ^2.4", + "league/flysystem": "^1.1 || ^2.1 || ^3.0", + "league/flysystem-bundle": "^1.1 || ^2.4 || ^3.0", "liip/imagine-bundle": "^2.4", "psr/event-dispatcher": "^1.0", "psr/log": "^1.0 || ^2.0 || ^3.0", "setono/doctrine-orm-batcher": "^0.6", "setono/doctrine-orm-batcher-bundle": "^0.3.4", "spatie/enum": "^3.7", - "sylius/channel": "^1.0", - "sylius/channel-bundle": "^1.0", - "sylius/core": "^1.0", - "sylius/core-bundle": "^1.0", - "sylius/inventory": "^1.0", - "sylius/locale": "^1.0", - "sylius/resource-bundle": "^1.6", - "sylius/ui-bundle": "^1.0", + "sylius/channel": "^1.0 || ^2.0", + "sylius/channel-bundle": "^1.0 || ^2.0", + "sylius/core": "^1.0 || ^2.0", + "sylius/core-bundle": "^1.0 || ^2.0", + "sylius/inventory": "^1.0 || ^2.0", + "sylius/locale": "^1.0 || ^2.0", + "sylius/resource-bundle": "^1.6 || ^2.0", + "sylius/ui-bundle": "^1.0 || ^2.0", "symfony/config": "^6.4 || ^7.4", "symfony/console": "^6.4 || ^7.4", "symfony/dependency-injection": "^6.4 || ^7.4", diff --git a/src/DependencyInjection/Compiler/RegisterFilesystemPass.php b/src/DependencyInjection/Compiler/RegisterFilesystemPass.php index bd9d471c..fbe90355 100644 --- a/src/DependencyInjection/Compiler/RegisterFilesystemPass.php +++ b/src/DependencyInjection/Compiler/RegisterFilesystemPass.php @@ -9,6 +9,7 @@ use League\Flysystem\FilesystemOperator; use RuntimeException; use Symfony\Component\Config\Definition\Exception\InvalidDefinitionException; +use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Webmozart\Assert\Assert; @@ -39,7 +40,12 @@ public function process(ContainerBuilder $container): void throw new InvalidArgumentException(sprintf('No service definition exists with id "%s"', $parameterValue)); } - $definitionClass = $container->getDefinition($parameterValue)->getClass(); + $definition = $container->getDefinition($parameterValue); + if ($definition->getClass() === null && $definition instanceof ChildDefinition) { + $definition = $container->getDefinition($definition->getParent()); + } + + $definitionClass = $definition->getClass(); Assert::notNull($definitionClass); if (interface_exists(FilesystemInterface::class)) { diff --git a/src/Resources/config/routing/admin.yaml b/src/Resources/config/routing/admin.yaml index af9a4c21..55ec8e5e 100644 --- a/src/Resources/config/routing/admin.yaml +++ b/src/Resources/config/routing/admin.yaml @@ -39,7 +39,7 @@ setono_sylius_feed_admin_feed_violations_index: route: parameters: id: $id - template: '@SyliusAdmin/Crud/index.html.twig' + template: '@SyliusAdmin/shared/crud/index.html.twig' grid: setono_sylius_feed_admin_violation section: admin permission: true diff --git a/src/Resources/views/Admin/Feed/Label/State/error.html.twig b/src/Resources/views/Admin/Feed/Label/State/error.html.twig index 975b6820..d8d7a9f4 100644 --- a/src/Resources/views/Admin/Feed/Label/State/error.html.twig +++ b/src/Resources/views/Admin/Feed/Label/State/error.html.twig @@ -1,4 +1 @@ - - - {{ value|trans }} - +{{ value|trans }} diff --git a/src/Resources/views/Admin/Feed/Label/State/processing.html.twig b/src/Resources/views/Admin/Feed/Label/State/processing.html.twig index 7ddb4177..e07d831c 100644 --- a/src/Resources/views/Admin/Feed/Label/State/processing.html.twig +++ b/src/Resources/views/Admin/Feed/Label/State/processing.html.twig @@ -1,4 +1 @@ - - - {{ value|trans }} - +{{ value|trans }} diff --git a/src/Resources/views/Admin/Feed/Label/State/ready.html.twig b/src/Resources/views/Admin/Feed/Label/State/ready.html.twig index 1c06a31c..c43ee90c 100644 --- a/src/Resources/views/Admin/Feed/Label/State/ready.html.twig +++ b/src/Resources/views/Admin/Feed/Label/State/ready.html.twig @@ -1,4 +1 @@ - - - {{ value|trans }} - +{{ value|trans }} diff --git a/src/Resources/views/Admin/Feed/Label/State/unprocessed.html.twig b/src/Resources/views/Admin/Feed/Label/State/unprocessed.html.twig index ab67612f..fbe69d8d 100644 --- a/src/Resources/views/Admin/Feed/Label/State/unprocessed.html.twig +++ b/src/Resources/views/Admin/Feed/Label/State/unprocessed.html.twig @@ -1,4 +1 @@ - - - {{ value|trans }} - +{{ value|trans }} diff --git a/src/Resources/views/Admin/Feed/Show/_breadcrumb.html.twig b/src/Resources/views/Admin/Feed/Show/_breadcrumb.html.twig index 12e64d68..e8a144cf 100644 --- a/src/Resources/views/Admin/Feed/Show/_breadcrumb.html.twig +++ b/src/Resources/views/Admin/Feed/Show/_breadcrumb.html.twig @@ -1,10 +1,7 @@ -{% import '@SyliusAdmin/Macro/breadcrumb.html.twig' as breadcrumb %} - -{% set breadcrumbs = [ - { label: 'sylius.ui.administration'|trans, url: path('sylius_admin_dashboard') }, - { label: 'setono_sylius_feed.ui.feeds'|trans, url: path('setono_sylius_feed_admin_feed_index') }, - { label: '#'~feed.id } -] -%} - -{{ breadcrumb.crumble(breadcrumbs) }} + diff --git a/src/Resources/views/Admin/Feed/Show/_header.html.twig b/src/Resources/views/Admin/Feed/Show/_header.html.twig index cce09349..d40f6354 100644 --- a/src/Resources/views/Admin/Feed/Show/_header.html.twig +++ b/src/Resources/views/Admin/Feed/Show/_header.html.twig @@ -1,18 +1,21 @@ -{# @var \Setono\SyliusFeedPlugin\Model\FeedInterface feed #} - -

- -
- {{ 'setono_sylius_feed.ui.feed'|trans }} {{ feed.name }} -
-
-
- {{ 'setono_sylius_feed.ui.feed_type'|trans ~ ': ' ~ feed.feedType }} {# todo output the label of the feed type #} -
-
-
{{ ('setono_sylius_feed.ui.' ~ feed.state)|trans }}
-
-
+
+
+

+ {{ 'setono_sylius_feed.ui.feed'|trans }} {{ feed.name }} +

+
+ {{ 'setono_sylius_feed.ui.feed_type'|trans }}: {{ feed.feedType }} + + {{ ('setono_sylius_feed.ui.' ~ feed.state)|trans }} +
-

+
+ {% set menu = knp_menu_get('setono_sylius_feed.admin.feed.show', [], {'feed': feed}) %} + {% for child in menu.children %} + + {{ child.label|trans }} + + {% endfor %} +
+ diff --git a/src/Resources/views/Admin/Feed/show.html.twig b/src/Resources/views/Admin/Feed/show.html.twig index 5cc1a250..7fc0372b 100644 --- a/src/Resources/views/Admin/Feed/show.html.twig +++ b/src/Resources/views/Admin/Feed/show.html.twig @@ -1,112 +1,81 @@ -{% extends '@SyliusAdmin/layout.html.twig' %} - -{# @var \Setono\SyliusFeedPlugin\Model\FeedInterface feed #} - -{% block title %}{{ 'setono_sylius_feed.ui.feed'|trans ~' '~ feed.name }} {{ parent() }}{% endblock %} - -{% block content %} - {{ sonata_block_render_event('setono_sylius_feed.admin.feed.show.before_header', {'resource': resource}) }} - -
-
- {% include '@SetonoSyliusFeedPlugin/Admin/Feed/Show/_header.html.twig' %} -
- - {% set menu = knp_menu_get('setono_sylius_feed.admin.feed.show', [], {'feed': feed}) %} - {{ knp_menu_render(menu, {'template': '@SyliusUi/Menu/top.html.twig'}) }} -
- - {{ sonata_block_render_event('setono_sylius_feed.admin.feed.show.after_header', {'resource': resource}) }} - - {% include '@SetonoSyliusFeedPlugin/Admin/Feed/Show/_breadcrumb.html.twig' %} - - {{ sonata_block_render_event('setono_sylius_feed.admin.feed.show.after_breadcrumb', {'resource': resource}) }} - - {% if workflow_has_marked_place(feed, constant('Setono\\SyliusFeedPlugin\\Workflow\\FeedGraph::STATE_READY')) or workflow_has_marked_place(feed, constant('Setono\\SyliusFeedPlugin\\Workflow\\FeedGraph::STATE_PROCESSING')) %} -
- - - - - - - - - - {% for channel in feed.channels %} - {% for locale in channel.locales %} - - - - - - {% endfor %} - {% endfor %} - -
{{ 'sylius.ui.channel'|trans }}{{ 'sylius.ui.locale'|trans }}{{ 'setono_sylius_feed.ui.link'|trans }}
{{ channel.name }}{{ locale.name }} -
- - - -
-
-
- {% else %} -
-
-
- {{ 'setono_sylius_feed.ui.unprocessed_feed_header'|trans }} -
-

{{ 'setono_sylius_feed.ui.unprocessed_feed_body'|trans }}

+{% extends '@SyliusAdmin/shared/layout/base.html.twig' %} + +{% block title %}{{ 'setono_sylius_feed.ui.feed'|trans ~ ' ' ~ feed.name }} {{ parent() }}{% endblock %} + +{% block body %} + {% include '@SyliusAdmin/shared/crud/common/sidebar.html.twig' %} + +
+ {% include '@SyliusAdmin/shared/crud/common/navbar.html.twig' %} + +
+
+ {% include '@SetonoSyliusFeedPlugin/Admin/Feed/Show/_header.html.twig' %} + + {% include '@SetonoSyliusFeedPlugin/Admin/Feed/Show/_breadcrumb.html.twig' %} + + {% if workflow_has_marked_place(feed, constant('Setono\\SyliusFeedPlugin\\Workflow\\FeedGraph::STATE_READY')) or workflow_has_marked_place(feed, constant('Setono\\SyliusFeedPlugin\\Workflow\\FeedGraph::STATE_PROCESSING')) %} +
+
+ + + + + + + + + + {% for channel in feed.channels %} + {% for locale in channel.locales %} + + + + + + {% endfor %} + {% endfor %} + +
{{ 'sylius.ui.channel'|trans }}{{ 'sylius.ui.locale'|trans }}{{ 'setono_sylius_feed.ui.link'|trans }}
{{ channel.name }}{{ locale.name }} +
+ + +
+
+
+
+ {% else %} +
+ {{ 'setono_sylius_feed.ui.unprocessed_feed_header'|trans }} +

{{ 'setono_sylius_feed.ui.unprocessed_feed_body'|trans }}

+
+ {% endif %} + + {% if feed.violations|length > 0 %} +

{{ 'setono_sylius_feed.ui.violation_summary'|trans }}

+

{{ 'setono_sylius_feed.ui.view_all_violations'|trans({'%path%': path('setono_sylius_feed_admin_feed_violations_index', {'id': feed.id})})|raw }}

+ {{ render(controller('setono_sylius_feed.controller.action.admin.severity_count', {'feed': feed.id})) }} + {% endif %}
- {% endif %} - {% if feed.violations|length > 0 %} -

{{ 'setono_sylius_feed.ui.violation_summary'|trans }}

-

{{ 'setono_sylius_feed.ui.view_all_violations'|trans({'%path%' : path('setono_sylius_feed_admin_feed_violations_index', {'id' : feed.id})})|raw }}

- - {{ render(controller('setono_sylius_feed.controller.action.admin.severity_count', {'feed': feed.id})) }} - {% endif %} - - {{ sonata_block_render_event('setono_sylius_feed.admin.feed.show.after_content', {'resource': resource}) }} + {% include '@SyliusAdmin/shared/crud/common/content/footer.html.twig' %} +
{% endblock %} {% block javascripts %} {{ parent() }} - {% endblock %} diff --git a/src/Resources/views/Admin/Violation/Grid/Field/data.html.twig b/src/Resources/views/Admin/Violation/Grid/Field/data.html.twig index 51424588..e8285ec8 100644 --- a/src/Resources/views/Admin/Violation/Grid/Field/data.html.twig +++ b/src/Resources/views/Admin/Violation/Grid/Field/data.html.twig @@ -1,9 +1,4 @@ -
-
- - {{ 'sylius.ui.view'|trans }} -
-
-
{{ data }}
-
-
+
+ {{ 'sylius.ui.view'|trans }} +
{{ data }}
+
diff --git a/src/Resources/views/Admin/Violation/severity_count.html.twig b/src/Resources/views/Admin/Violation/severity_count.html.twig index 2044dbb6..c8d585af 100644 --- a/src/Resources/views/Admin/Violation/severity_count.html.twig +++ b/src/Resources/views/Admin/Violation/severity_count.html.twig @@ -1,20 +1,21 @@ {# @var \Setono\SyliusFeedPlugin\DTO\SeverityCount[] severityCounts #} -
- - - - - - - - - {% set severityMap = {'error': 'negative', 'warning': 'warning', 'notice': ''} %} - {% for severityCount in severityCounts %} - - - +
+
+
{{ 'setono_sylius_feed.ui.severity'|trans }}{{ 'setono_sylius_feed.ui.count'|trans }}
{{ ('setono_sylius_feed.ui.severities.' ~ severityCount.severity)|trans }}{{ severityCount.count }}
+ + + + - {% endfor %} - -
{{ 'setono_sylius_feed.ui.severity'|trans }}{{ 'setono_sylius_feed.ui.count'|trans }}
+ + + {% for severityCount in severityCounts %} + + {{ ('setono_sylius_feed.ui.severities.' ~ severityCount.severity)|trans }} + {{ severityCount.count }} + + {% endfor %} + + +
diff --git a/src/Twig/Extension.php b/src/Twig/Extension.php index 5f1600b4..b0cb6935 100644 --- a/src/Twig/Extension.php +++ b/src/Twig/Extension.php @@ -9,6 +9,7 @@ use Sylius\Component\Locale\Model\LocaleInterface; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; +use Symfony\Component\Routing\RouterInterface; use Twig\Extension\AbstractExtension; use Twig\TwigFilter; use Twig\TwigFunction; @@ -42,10 +43,17 @@ public function removeEmptyTags(string $xml): string public function generateFeedUrl(FeedInterface $feed, ChannelInterface $channel, LocaleInterface $locale): string { - $path = $this->urlGenerator->generate('setono_sylius_feed_shop_feed_show', [ - '_locale' => $locale->getCode(), - 'code' => $feed->getCode(), - ]); + $params = ['code' => $feed->getCode()]; + + // Only pass _locale if the route has it as a parameter + if ($this->urlGenerator instanceof RouterInterface) { + $route = $this->urlGenerator->getRouteCollection()->get('setono_sylius_feed_shop_feed_show'); + if (null !== $route && str_contains($route->getPath(), '{_locale}')) { + $params['_locale'] = $locale->getCode(); + } + } + + $path = $this->urlGenerator->generate('setono_sylius_feed_shop_feed_show', $params); // todo maybe inject request context into router instead to 'make it right' return sprintf('%s://%s%s', $this->getScheme(), (string) $channel->getHostname(), $path);