Skip to content

Commit

Permalink
fix: add Shopware 6.5 support
Browse files Browse the repository at this point in the history
  • Loading branch information
lacknere committed Oct 19, 2023
1 parent a954b0b commit 3746411
Show file tree
Hide file tree
Showing 13 changed files with 53 additions and 37 deletions.
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "runelaenen/sw6-redirects",
"description": "Redirect plugin for Shopware 6",
"version": "1.4.0",
"version": "2.0.0",
"type": "shopware-platform-plugin",
"license": "MIT",
"authors": [
Expand All @@ -12,7 +12,8 @@
}
],
"require": {
"php": "^7.4 || ^8.0"
"php": "^8.1",
"shopware/core": "^6.5"
},
"extra": {
"shopware-plugin-class": "RuneLaenen\\Redirects\\RuneLaenenRedirects",
Expand Down
2 changes: 1 addition & 1 deletion src/Migration/Migration160198215Redirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function getCreationTimestamp(): int

public function update(Connection $connection): void
{
$connection->executeUpdate(
$connection->executeStatement(
<<<SQL
CREATE TABLE IF NOT EXISTS `rl_redirects_redirect` (
`id` BINARY(16) NOT NULL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@ import './page/rl-redirects-list';
import './page/rl-redirects-details';
import './page/rl-redirects-create';

Shopware.Module.register('rl-redirects', {
const { Component, Module } = Shopware;

Component.register('rl-redirects-list', () => import('./page/rl-redirects-list'));
Component.register('rl-redirects-details', () => import('./page/rl-redirects-details'));
Component.extend('rl-redirects-create', 'rl-redirects-details', () => import('./page/rl-redirects-create'));

Module.register('rl-redirects', {
type: 'plugin',
name: 'rl-redirects',
title: 'rl-redirects.general.title',
description: 'rl-redirects.general.title',
color: '#189eff',
icon: 'default-object-rocket',
icon: 'regular-rocket',

routes: {
list: {
Expand Down Expand Up @@ -41,6 +47,6 @@ Shopware.Module.register('rl-redirects', {
settingsItem: [{
to: 'rl.redirects.list',
group: 'shop',
icon: 'small-arrow-large-double-right',
icon: 'regular-double-chevron-right-s',
}],
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
const { Component } = Shopware;

Component.extend('rl-redirects-create', 'rl-redirects-details', {
export default {
methods: {
getRedirect() {
this.redirect = this.redirectRepository.create(Shopware.Context.api);
Expand Down Expand Up @@ -32,4 +30,4 @@ Component.extend('rl-redirects-create', 'rl-redirects-details', {
},
},

});
};
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import template from './rl-redirects-details.html.twig';

const { Component, Mixin } = Shopware;
const { Mixin } = Shopware;

Component.register('rl-redirects-details', {
export default {
template,

inject: [
Expand Down Expand Up @@ -87,4 +87,4 @@ Component.register('rl-redirects-details', {
},
},

});
};
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import template from './rl-redirects-list.html.twig';

const { Component } = Shopware;
const Criteria = Shopware.Data.Criteria;

Component.register('rl-redirects-list', {
export default {
template,

inject: [
Expand Down Expand Up @@ -56,4 +55,4 @@ Component.register('rl-redirects-list', {
});
},

});
};
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
:items="redirects"
:repository="redirectRepository"
:columns="columns"
detailRoute="rl.redirect.details">
detailRoute="rl.redirects.details">
</sw-entity-listing>
{% endblock %}
</template>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export default {
computed: {
supportedEntities() {
const supportedEntities = this.$super('supportedEntities');

supportedEntities.push({
value: 'rl_redirects_redirect',
label: this.$tc('sw-import-export.profile.rlRedirectLabel'),
type: 'import-export',
});

return supportedEntities;
},
},

};

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
import './component/sw-import-export-edit-profile-modal';
Shopware.Component.override('sw-import-export-edit-profile-general', () => import('./component/sw-import-export-edit-profile-general'));
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"sw-import-export": {
"profile": {
"rlRedirectLabel": "Weiterleitung"
}
}
}
2 changes: 1 addition & 1 deletion src/RuneLaenenRedirects.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ public function uninstall(UninstallContext $uninstallContext): void

/** @var Connection $connection */
$connection = $this->container->get(Connection::class);
$connection->executeUpdate('DROP TABLE IF EXISTS `rl_redirects_redirect`;');
$connection->executeStatement('DROP TABLE IF EXISTS `rl_redirects_redirect`;');
}
}
14 changes: 7 additions & 7 deletions src/Subscriber/RequestSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
use RuneLaenen\Redirects\Content\Redirect\RedirectEntity;
use Shopware\Core\Framework\Adapter\Cache\CacheCompressor;
use Shopware\Core\Framework\Context;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
use Shopware\Core\Framework\DataAbstractionLayer\FieldSerializer\JsonFieldSerializer;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsAnyFilter;
use Shopware\Core\Framework\Event\BeforeSendRedirectResponseEvent;
use Shopware\Core\Framework\Event\BeforeSendResponseEvent;
use Shopware\Core\Framework\Util\Json;
use Symfony\Component\Cache\Adapter\TagAwareAdapterInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
Expand All @@ -21,15 +21,15 @@ class RequestSubscriber implements EventSubscriberInterface
{
private const TAG_KEY = 'rl_redirects_cache';

private EntityRepositoryInterface $redirectRepository;
private EntityRepository $redirectRepository;

private EntityRepositoryInterface $seoUrlRepository;
private EntityRepository $seoUrlRepository;

private TagAwareAdapterInterface $cache;

public function __construct(
EntityRepositoryInterface $redirectRepository,
EntityRepositoryInterface $seoUrlRepository,
EntityRepository $redirectRepository,
EntityRepository $seoUrlRepository,
TagAwareAdapterInterface $cache
) {
$this->redirectRepository = $redirectRepository;
Expand Down Expand Up @@ -69,7 +69,7 @@ public function redirectBeforeRedirectResponse(BeforeSendRedirectResponseEvent $

private function handleRequestCached(Request $request, ?string $requestUri = null): ?Response
{
$cacheKey = md5(JsonFieldSerializer::encodeJson([
$cacheKey = md5(Json::encode([
$requestUri ?? (string) $request->get('resolved-uri'),
$request->get('sw-storefront-url'),
$request->getBaseUrl(),
Expand Down

0 comments on commit 3746411

Please sign in to comment.