Skip to content

Commit

Permalink
feat: shopware 6.6 compatibility (#237)
Browse files Browse the repository at this point in the history
* feat: shopware 6.6 compatibility

* Update code-style.yml

---------

Co-authored-by: Shyim <[email protected]>
  • Loading branch information
stefanpoensgen and shyim authored Jan 22, 2024
1 parent d278848 commit cee454a
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 56 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/code-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ jobs:
uses: shopware/github-actions/.github/workflows/phpstan.yml@main
with:
extensionName: FroshTools
shopwareVersion: 6.5.x
shopwareVersion: v6.6.0.0-rc1
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "frosh/tools",
"version": "1.2.6",
"version": "2.0.0",
"description": "Provides some basic things for managing the Shopware Installation",
"type": "shopware-platform-plugin",
"license": "MIT",
Expand Down Expand Up @@ -35,7 +35,7 @@
}
},
"require": {
"shopware/core": "~6.5.2"
"shopware/core": "~6.6.0"
},
"config": {
"allow-plugins": {
Expand Down
32 changes: 5 additions & 27 deletions src/Controller/ScheduledTaskController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Shopware\Core\Framework\MessageQueue\ScheduledTask\ScheduledTaskDefinition;
use Shopware\Core\Framework\MessageQueue\ScheduledTask\ScheduledTaskEntity;
use Shopware\Core\Framework\MessageQueue\ScheduledTask\ScheduledTaskHandler;
use Shopware\Core\Framework\MessageQueue\ScheduledTask\Scheduler\TaskRunner;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\DependencyInjection\Attribute\TaggedIterator;
use Symfony\Component\HttpFoundation\JsonResponse;
Expand All @@ -23,14 +24,12 @@
class ScheduledTaskController extends AbstractController
{
/**
* @param iterable<ScheduledTaskHandler> $taskHandler
* @param EntityRepository<ScheduledTaskCollection> $scheduledTaskRepository
*/
public function __construct(# @phpstan-ignore-line
#[TaggedIterator('messenger.message_handler')]
private readonly iterable $taskHandler,
public function __construct(
private readonly EntityRepository $scheduledTaskRepository,
private readonly TaskRegistry $taskRegistry
private readonly TaskRegistry $taskRegistry,
private readonly TaskRunner $taskRunner
) {}

#[Route(path: '/scheduled-task/{id}', name: 'api.frosh.tools.scheduled.task.run', methods: ['POST'])]
Expand All @@ -51,28 +50,7 @@ public function runTask(string $id, Context $context): JsonResponse
],
], $context);

$className = $scheduledTask->getScheduledTaskClass();
/** @var ScheduledTask $task */
$task = new $className();
$task->setTaskId($id);

foreach ($this->taskHandler as $handler) {
if (!$handler instanceof ScheduledTaskHandler) {
continue;
}

// @phpstan-ignore-next-line
$handledMessages = $handler::getHandledMessages();
if (!\is_array($handledMessages)) {
$handledMessages = iterator_to_array($handledMessages);
}
if (!\in_array($className, $handledMessages, true)) {
continue;
}

// calls the __invoke() method of the abstract ScheduledTaskHandler
$handler($task);
}
$this->taskRunner->runSingleTask($scheduledTask->getName(), $context);

return new JsonResponse(null, Response::HTTP_NO_CONTENT);
}
Expand Down
3 changes: 2 additions & 1 deletion src/Controller/ShopwareFilesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
use Shopware\Core\System\User\UserCollection;
use Shopware\Core\System\User\UserEntity;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag;
use Symfony\Component\DependencyInjection\Attribute\Autowire;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;

#[AutoconfigureTag('monolog.logger', ['channel' => 'frosh-tools'])]
#[Route(path: '/api/_action/frosh-tools', defaults: ['_routeScope' => ['api'], '_acl' => ['frosh_tools:read']])]
class ShopwareFilesController extends AbstractController
{
Expand All @@ -41,7 +43,6 @@ public function __construct(
private readonly string $projectDir,
#[Autowire('%frosh_tools.file_checker.exclude_files%')]
private readonly array $projectExcludeFiles,
#[Autowire(service: 'frosh_tools.logger')]
private readonly LoggerInterface $froshToolsLogger,
private readonly EntityRepository $userRepository,
private readonly EntityRepository $integrationRepository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ Component.register('frosh-tools-tab-logs', {
rawData: true
}
];
}
},

date() {
return Shopware.Filter.getByName('date');
},
},

methods: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,15 @@
positionIdentifier="frosh-tools-tab-logs"
>
<template #toolbar>
<!-- @todo: Make the refresh button fancy -->
<sw-button variant="ghost" @click="refresh"><sw-icon :small="true" name="regular-undo"></sw-icon></sw-button>
<sw-single-select
:options="logFiles"
:isLoading="isLoading"
:placeholder="$tc('frosh-tools.tabs.logs.logFileSelect.placeholder')"
labelProperty="name"
valueProperty="name"
{% if VUE3 %}
v-model:value="selectedLogFile"
@update:value="onFileSelected"
{% else %}
v-model="selectedLogFile"
@change="onFileSelected"
{% endif %}
v-model:value="selectedLogFile"
@update:value="onFileSelected"
></sw-single-select>
</template>

Expand All @@ -31,7 +25,7 @@
:dataSource="logEntries"
:columns="columns">
<template #column-date="{ item }">
{{ item.date | date({hour: '2-digit', minute: '2-digit', second: '2-digit'}) }}
{{ date(item.date, {hour: '2-digit', minute: '2-digit', second: '2-digit'}) }}
</template>
<template #column-message="{ item }">
<a @click="showInfoModal(item)">{{ item.message }}</a>
Expand All @@ -56,7 +50,7 @@
</h4>

<h5 class="sw-modal__subtitle">
{{ displayedLog.date | date({hour: '2-digit', minute: '2-digit', second: '2-digit'}) }}
{{ date(displayedLog.date, {hour: '2-digit', minute: '2-digit', second: '2-digit'}) }}
</h5>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ Component.register('frosh-tools-tab-scheduled', {
rawData: true
}
];
}
},

date() {
return Shopware.Filter.getByName('date');
},
},

methods: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
:columns="columns">

<template #column-lastExecutionTime="{ item }">
{{ item.lastExecutionTime | date({hour: '2-digit', minute: '2-digit'}) }}
{{ date(item.lastExecutionTime, {hour: '2-digit', minute: '2-digit'}) }}
</template>
<template #column-nextExecutionTime="{ item, column, compact, isInlineEdit }">
<sw-data-grid-inline-edit
Expand All @@ -39,7 +39,7 @@
</sw-data-grid-inline-edit>

<span v-else>
{{ item.nextExecutionTime | date({hour: '2-digit', minute: '2-digit'}) }}
{{ date(item.nextExecutionTime, {hour: '2-digit', minute: '2-digit'}) }}
</span>
</template>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@
v-model="selectedStateMachine"
entity="state_machine"
:aside="true"
{% if VUE3 %}
@update:value="onStateMachineChange"
{% else %}
@change="onStateMachineChange"
{% endif %}
@update:value="onStateMachineChange"
:label="$tc('frosh-tools.tabs.state-machines.label')"
:placeholder="$tc('frosh-tools.chooseStateMachine')"
:helpText="$tc('frosh-tools.tabs.state-machines.helpText')"
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/config/routes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
xsi:schemaLocation="http://symfony.com/schema/routing
http://symfony.com/schema/routing/routing-1.0.xsd">

<import resource="../../Controller" type="annotation" />
<import resource="../../Controller" type="attribute" />
</routes>
5 changes: 0 additions & 5 deletions src/Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

<services>
<service id="frosh_tools.logger" class="Psr\Log\LoggerInterface">
<factory service="Shopware\Core\Framework\Log\LoggerFactory" method="createRotating"/>
<argument type="string">frosh-tools</argument>
</service>

<defaults autowire="true" autoconfigure="true" />
<prototype namespace="Frosh\Tools\" resource="../../" exclude="../../{DependencyInjection,Resources,FroshTools.php}" />
</services>
Expand Down

0 comments on commit cee454a

Please sign in to comment.