Skip to content

Commit

Permalink
Merge branch 'next-23988/theme-compiler-deprecations' into 'trunk'
Browse files Browse the repository at this point in the history
NEXT-23988 - Theme compiler deprecations

See merge request shopware/6/product/platform!9506
  • Loading branch information
Stefan Sluiter committed Dec 6, 2022
2 parents 056df37 + 8dbf00c commit 86a8370
Show file tree
Hide file tree
Showing 36 changed files with 487 additions and 567 deletions.
1 change: 0 additions & 1 deletion changelog/_unreleased/2021-12-30-save-theme-compilation.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
title: Save theme compilation
issue: NEXT-15381
flag: FEATURE_NEXT_15381
---

# Storefront
Expand Down
100 changes: 0 additions & 100 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -23972,36 +23972,6 @@ parameters:
count: 1
path: src/Storefront/Theme/Event/ThemeIndexerEvent.php

-
message: "#^Method Shopware\\\\Storefront\\\\Theme\\\\Exception\\\\ThemeAssignmentException\\:\\:__construct\\(\\) has parameter \\$childThemeSalesChannel with no value type specified in iterable type array\\.$#"
count: 1
path: src/Storefront/Theme/Exception/ThemeAssignmentException.php

-
message: "#^Method Shopware\\\\Storefront\\\\Theme\\\\Exception\\\\ThemeAssignmentException\\:\\:__construct\\(\\) has parameter \\$stillAssignedSalesChannels with no value type specified in iterable type array\\.$#"
count: 1
path: src/Storefront/Theme/Exception/ThemeAssignmentException.php

-
message: "#^Method Shopware\\\\Storefront\\\\Theme\\\\Exception\\\\ThemeAssignmentException\\:\\:__construct\\(\\) has parameter \\$themeSalesChannel with no value type specified in iterable type array\\.$#"
count: 1
path: src/Storefront/Theme/Exception/ThemeAssignmentException.php

-
message: "#^Method Shopware\\\\Storefront\\\\Theme\\\\Exception\\\\ThemeAssignmentException\\:\\:formatAssignments\\(\\) has parameter \\$assignmentMapping with no value type specified in iterable type array\\.$#"
count: 1
path: src/Storefront/Theme/Exception/ThemeAssignmentException.php

-
message: "#^Method Shopware\\\\Storefront\\\\Theme\\\\Exception\\\\ThemeAssignmentException\\:\\:getAssignedSalesChannels\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: src/Storefront/Theme/Exception/ThemeAssignmentException.php

-
message: "#^Property Shopware\\\\Storefront\\\\Theme\\\\Exception\\\\ThemeAssignmentException\\:\\:\\$stillAssignedSalesChannels type has no value type specified in iterable type array\\.$#"
count: 1
path: src/Storefront/Theme/Exception/ThemeAssignmentException.php

-
message: "#^Call to an undefined method Shopware\\\\Core\\\\Framework\\\\DataAbstractionLayer\\\\Entity\\:\\:getId\\(\\)\\.$#"
count: 2
Expand Down Expand Up @@ -24202,76 +24172,6 @@ parameters:
count: 1
path: src/Storefront/Theme/ThemeConfigFieldFactory.php

-
message: "#^Method Shopware\\\\Storefront\\\\Theme\\\\ThemeEntity\\:\\:getBaseConfig\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: src/Storefront/Theme/ThemeEntity.php

-
message: "#^Method Shopware\\\\Storefront\\\\Theme\\\\ThemeEntity\\:\\:getConfigValues\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: src/Storefront/Theme/ThemeEntity.php

-
message: "#^Method Shopware\\\\Storefront\\\\Theme\\\\ThemeEntity\\:\\:getHelpTexts\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: src/Storefront/Theme/ThemeEntity.php

-
message: "#^Method Shopware\\\\Storefront\\\\Theme\\\\ThemeEntity\\:\\:getLabels\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: src/Storefront/Theme/ThemeEntity.php

-
message: "#^Method Shopware\\\\Storefront\\\\Theme\\\\ThemeEntity\\:\\:setBaseConfig\\(\\) has parameter \\$baseConfig with no value type specified in iterable type array\\.$#"
count: 1
path: src/Storefront/Theme/ThemeEntity.php

-
message: "#^Method Shopware\\\\Storefront\\\\Theme\\\\ThemeEntity\\:\\:setConfigValues\\(\\) has parameter \\$configValues with no value type specified in iterable type array\\.$#"
count: 1
path: src/Storefront/Theme/ThemeEntity.php

-
message: "#^Method Shopware\\\\Storefront\\\\Theme\\\\ThemeEntity\\:\\:setHelpTexts\\(\\) has parameter \\$helpTexts with no value type specified in iterable type array\\.$#"
count: 1
path: src/Storefront/Theme/ThemeEntity.php

-
message: "#^Method Shopware\\\\Storefront\\\\Theme\\\\ThemeEntity\\:\\:setLabels\\(\\) has parameter \\$labels with no value type specified in iterable type array\\.$#"
count: 1
path: src/Storefront/Theme/ThemeEntity.php

-
message: "#^Property Shopware\\\\Storefront\\\\Theme\\\\ThemeEntity\\:\\:\\$baseConfig type has no value type specified in iterable type array\\.$#"
count: 1
path: src/Storefront/Theme/ThemeEntity.php

-
message: "#^Property Shopware\\\\Storefront\\\\Theme\\\\ThemeEntity\\:\\:\\$configValues type has no value type specified in iterable type array\\.$#"
count: 1
path: src/Storefront/Theme/ThemeEntity.php

-
message: "#^Property Shopware\\\\Storefront\\\\Theme\\\\ThemeEntity\\:\\:\\$helpTexts type has no value type specified in iterable type array\\.$#"
count: 1
path: src/Storefront/Theme/ThemeEntity.php

-
message: "#^Property Shopware\\\\Storefront\\\\Theme\\\\ThemeEntity\\:\\:\\$labels type has no value type specified in iterable type array\\.$#"
count: 1
path: src/Storefront/Theme/ThemeEntity.php

-
message: "#^Method Shopware\\\\Storefront\\\\Theme\\\\ThemeLifecycleHandler\\:\\:changeThemeActive\\(\\) has parameter \\$themeData with no value type specified in iterable type array\\.$#"
count: 1
path: src/Storefront/Theme/ThemeLifecycleHandler.php

-
message: "#^Method Shopware\\\\Storefront\\\\Theme\\\\ThemeLifecycleHandler\\:\\:getThemeDataByTechnicalName\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: src/Storefront/Theme/ThemeLifecycleHandler.php

-
message: "#^Method Shopware\\\\Storefront\\\\Theme\\\\Twig\\\\ThemeInheritanceBuilder\\:\\:build\\(\\) has parameter \\$bundles with no value type specified in iterable type array\\.$#"
count: 1
Expand Down
6 changes: 0 additions & 6 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,6 @@ parameters:
count: 1
path: src/Storefront/Framework/Cache/ReverseProxy/ReverseProxyCache.php

# Can be removed with 6.5 release (NEXT-20850)
-
message: "#^PHPDoc tag @param references unknown parameter\\: \\$context$#"
count: 1
path: src/Storefront/Theme/ThemeCompiler.php

# can be removed with 6.5
-
message: "#^Method Shopware\\\\Core\\\\HttpKernel\\:\\:handle\\(\\) has parameter \\$catch with no type specified\\.$#"
Expand Down
5 changes: 0 additions & 5 deletions src/Core/Framework/Resources/config/packages/feature.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,6 @@ shopware:
major: true
description: "Refactor `sw-simple-search-field` component to a transparent wrapper component"
# issue: NEXT-16271
- name: FEATURE_NEXT_15381
default: false
major: true
description: "Save theme compilation"
# issue: NEXT-15381
- name: FEATURE_NEXT_17275
default: false
major: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@

use PHPUnit\Framework\TestCase;
use Shopware\Core\Framework\Context;
use Shopware\Core\Framework\Feature;
use Shopware\Core\Framework\Migration\MigrationCollection;
use Shopware\Core\Framework\Plugin;
use Shopware\Core\Framework\Plugin\Context\ActivateContext;
use Shopware\Core\Framework\Plugin\Context\UpdateContext;
use Shopware\Core\Framework\Plugin\Event\PluginPostActivateEvent;
use Shopware\Core\Framework\Plugin\Event\PluginPreActivateEvent;
use Shopware\Core\Framework\Plugin\Event\PluginPreUpdateEvent;
use Shopware\Core\Framework\Plugin\PluginEntity;
use Shopware\Core\Framework\Plugin\PluginLifecycleService;
Expand Down Expand Up @@ -66,40 +64,6 @@ public function testThemeLifecycleIsNotCalledWhenDeactivatedUsingContextOnActiva
$subscriber->pluginPostActivate($event);
}

public function testPluginPreActivateEvent(): void
{
Feature::skipTestIfActive('v6.5.0.0', $this);
$context = Context::createDefaultContext();
$context->addState(PluginLifecycleService::STATE_SKIP_ASSET_BUILDING);
$event = new PluginPreActivateEvent(
$this->getPlugin(),
new ActivateContext(
$this->createMock(Plugin::class),
$context,
'6.1.0',
'1.0.0',
$this->createMock(MigrationCollection::class)
)
);

$eventOrg = clone $event;

$handler = $this->createMock(ThemeLifecycleHandler::class);
$handler->expects(static::never())->method('handleThemeInstallOrUpdate');

$subscriber = new PluginLifecycleSubscriber(
$this->createMock(StorefrontPluginRegistry::class),
__DIR__,
$this->createMock(AbstractStorefrontPluginConfigurationFactory::class),
$handler,
$this->createMock(ThemeLifecycleService::class)
);

$subscriber->pluginActivate($event);

static::assertEquals($eventOrg, $event);
}

public function testThemeLifecycleIsNotCalledWhenDeactivatedUsingContextOnUpdate(): void
{
$context = Context::createDefaultContext();
Expand Down
18 changes: 0 additions & 18 deletions src/Storefront/Test/Theme/ThemeAssetPackageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Shopware\Storefront\Test\Theme;

use PHPUnit\Framework\TestCase;
use Shopware\Core\Framework\Feature;
use Shopware\Core\PlatformRequest;
use Shopware\Core\SalesChannelRequest;
use Shopware\Storefront\Theme\MD5ThemePathBuilder;
Expand Down Expand Up @@ -59,21 +58,4 @@ public function testStorefrontAllConditionsMatching(): void

static::assertSame('http://localhost/theme/440ac85892ca43ad26d44c7ad9d47d3e/all.js', $asset->getUrl('/all.js'));
}

/**
* @deprecated tag:v6.5.0 - can be removed if we remove the covered code
*/
public function testStorefrontAllConditionsMatchingFallback(): void
{
Feature::skipTestIfActive('v6.5.0.0', $this);
$request = new Request();
$request->attributes->set(PlatformRequest::ATTRIBUTE_SALES_CHANNEL_ID, 'abc');
$request->attributes->set(SalesChannelRequest::ATTRIBUTE_THEME_ID, 'abc');
$stack = new RequestStack();
$stack->push($request);

$asset = new ThemeAssetPackage(['http://localhost'], new EmptyVersionStrategy(), $stack, new MD5ThemePathBuilder());

static::assertSame('http://localhost/bundles/foo/test.js', $asset->getUrl('/bundles/foo/test.js'));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

/**
* @deprecated tag:v6.5.0 - reason:becomes-internal - EventSubscribers will become internal in v6.5.0
* @internal
*/
class CachedResolvedConfigLoaderInvalidator implements EventSubscriberInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use const JSON_THROW_ON_ERROR;

/**
* @deprecated tag:v6.5.0 - reason:becomes-internal - EventSubscribers will become internal in v6.5.0
* @internal
*/
class StaticFileConfigDumper implements EventSubscriberInterface
{
Expand Down
36 changes: 16 additions & 20 deletions src/Storefront/Theme/Exception/ThemeAssignmentException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,29 @@

namespace Shopware\Storefront\Theme\Exception;

use Shopware\Core\Framework\Feature;
use Shopware\Core\Framework\ShopwareHttpException;
use Shopware\Core\System\SalesChannel\SalesChannelCollection;
use Symfony\Component\HttpFoundation\Response;

class ThemeAssignmentException extends ShopwareHttpException
{
private array $stillAssignedSalesChannels;
/**
* @var array<string, string>
*/
private array $assignedSalesChannels;

/**
* @deprecated tag:v6.5.0 parameter $stillAssignedSalesChannels will be required
* @param array<string, array<int, string>> $themeSalesChannel
* @param array<string, array<int, string>> $childThemeSalesChannel
* @param array<string, string> $assignedSalesChannels
*/
public function __construct(
string $themeName,
array $themeSalesChannel,
array $childThemeSalesChannel,
?array $stillAssignedSalesChannels = null,
array $assignedSalesChannels,
?\Throwable $e = null
) {
$this->stillAssignedSalesChannels = $stillAssignedSalesChannels ?? [];
$this->assignedSalesChannels = $assignedSalesChannels;

$parameters = ['themeName' => $themeName];
$message = 'Unable to deactivate or uninstall theme "{{ themeName }}".';
Expand Down Expand Up @@ -50,31 +53,24 @@ public function getStatusCode(): int
}

/**
* @deprecated tag:v6.5.0 - will be removed on v6.5.0 use `getAssignedSalesChannels` instead
* @return array<string, string>|null
*/
public function getStillAssignedSalesChannels(): SalesChannelCollection
{
Feature::triggerDeprecationOrThrow(
'v6.5.0.0',
Feature::deprecatedMethodMessage(__CLASS__, __METHOD__, 'v6.5.0.0', 'getAssignedSalesChannels()')
);

return new SalesChannelCollection();
}

public function getAssignedSalesChannels(): ?array
{
return $this->stillAssignedSalesChannels;
return $this->assignedSalesChannels;
}

/**
* @param array<string, array<int, string>> $assignmentMapping
*/
private function formatAssignments(array $assignmentMapping): string
{
$output = [];
foreach ($assignmentMapping as $themeName => $salesChannelIds) {
$salesChannelNames = [];
foreach ($salesChannelIds as $salesChannelId) {
if ($this->stillAssignedSalesChannels[$salesChannelId]) {
$salesChannel = $this->stillAssignedSalesChannels[$salesChannelId];
if ($this->assignedSalesChannels[$salesChannelId]) {
$salesChannel = $this->assignedSalesChannels[$salesChannelId];
} else {
$salesChannelNames[] = $salesChannelId;

Expand Down
51 changes: 51 additions & 0 deletions src/Storefront/Theme/Struct/ThemeDependencies.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php declare(strict_types=1);

namespace Shopware\Storefront\Theme\Struct;

use Shopware\Core\Framework\Struct\Struct;

class ThemeDependencies extends Struct
{
protected ?string $id;

/**
* @var array<int, string>
*/
protected array $dependentThemes = [];

public function __construct(?string $id = null)
{
$this->id = $id;
}

public function getId(): ?string
{
return $this->id;
}

public function setId(?string $id): void
{
$this->id = $id;
}

/**
* @return array<int, string>
*/
public function getDependentThemes(): array
{
return $this->dependentThemes;
}

/**
* @param array<int, string> $dependentThemes
*/
public function setDependentThemes(array $dependentThemes): void
{
$this->dependentThemes = $dependentThemes;
}

public function addDependentTheme(string $dependentThemeId): void
{
$this->dependentThemes[] = $dependentThemeId;
}
}
2 changes: 1 addition & 1 deletion src/Storefront/Theme/Subscriber/AppLifecycleSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

/**
* @deprecated tag:v6.5.0 - reason:becomes-internal - EventSubscribers will become internal in v6.5.0
* @internal
*/
class AppLifecycleSubscriber implements EventSubscriberInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

/**
* @deprecated tag:v6.5.0 - reason:becomes-internal - EventSubscribers will become internal in v6.5.0
* @internal
*/
class FirstRunWizardSubscriber implements EventSubscriberInterface
{
Expand Down
Loading

0 comments on commit 86a8370

Please sign in to comment.