Skip to content

Commit

Permalink
NEXT-25696 - Remove some internal flags of intended/already existing …
Browse files Browse the repository at this point in the history
…public api
  • Loading branch information
OliverSkroblin committed Mar 22, 2023
1 parent 3f79bf5 commit 0d89c71
Show file tree
Hide file tree
Showing 58 changed files with 468 additions and 143 deletions.
1 change: 1 addition & 0 deletions .bc-exclude.php
Expand Up @@ -34,5 +34,6 @@
'Shopware\\\\Core\\\\Framework\\\\Log\\\\Package was marked "@internal"',
'Shopware\\\\Core\\\\Content\\\\Mail\\\\MailerConfigurationCompilerPass was marked "@internal"',
'Shopware\\\\Core\\\\Checkout\\\\Cart\\\\TaxProvider\\\\Struct\\\\TaxProviderResult was marked "@internal"',
'Shopware\\\\Core\\\\Checkout\\\\Cart\\\\CachedRuleLoader was marked "@internal"'
],
];
20 changes: 20 additions & 0 deletions changelog/_unreleased/2023-03-09-final-storable-flow.md
@@ -0,0 +1,20 @@
---
title: Final storable flow
issue: NEXT-25696
author: Oliver Skroblin
author_email: o.skroblin@shopware.com
author_github: @OliverSkroblin
---
# Core
* Removed `StorableFlow` @internal flag and define the class as final
* Removed `FlowAction` @internal flag to allow external developers provide own flow actions
* Removed `DemodataGeneratorInterface` @internal flag to provide own demo data generators via extensions
* Changed `ContainerFacade` @internal flag to @final, due to the fact that apps already consum this service as public API
* Removed `AbstractRuleLoader` @internal flag to allow decorating
* Removed `AbstractFlowLoader` @internal flag to allow developers loading of flows by their own
* Removed @internal flag of `EntityIndexerRegistry` to allow developers to use the service (including BC promise)
* Removed @internal flag from `EntityIndexingMessage` DTO to allow developers to create entity indexing message by their own
* Changed @internal flag for demo data domain classes which are required to add own demo data as developer.
* Changed @internal flag for `EntityScoreQueryBuilder` to @final to allow developers to use the service (including BC promise)
* Changed @internal flag for `IncrementGatewayRegistry` to @final to allow developers to use the service (including BC promise)
* Added `\Shopware\Core\Framework\Util\Json` public api class for unified json encoding
4 changes: 2 additions & 2 deletions src/Administration/Controller/UserConfigController.php
Expand Up @@ -10,11 +10,11 @@
use Shopware\Core\Framework\Context;
use Shopware\Core\Framework\DataAbstractionLayer\Doctrine\MultiInsertQueryQueue;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
use Shopware\Core\Framework\DataAbstractionLayer\FieldSerializer\JsonFieldSerializer;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsAnyFilter;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter;
use Shopware\Core\Framework\Log\Package;
use Shopware\Core\Framework\Util\Json;
use Shopware\Core\Framework\Uuid\Uuid;
use Shopware\Core\System\User\Aggregate\UserConfig\UserConfigDefinition;
use Shopware\Core\System\User\Aggregate\UserConfig\UserConfigEntity;
Expand Down Expand Up @@ -104,7 +104,7 @@ private function massUpsert(Context $context, array $postUpdateConfigs): void
$queue = new MultiInsertQueryQueue($this->connection, 250, false, true);
foreach ($postUpdateConfigs as $key => $value) {
$data = [
'value' => JsonFieldSerializer::encodeJson($value),
'value' => Json::encode($value),
'user_id' => Uuid::fromHexToBytes($userId),
'key' => $key,
'id' => Uuid::randomBytes(),
Expand Down
3 changes: 0 additions & 3 deletions src/Core/Checkout/Cart/AbstractRuleLoader.php
Expand Up @@ -6,9 +6,6 @@
use Shopware\Core\Framework\Context;
use Shopware\Core\Framework\Log\Package;

/**
* @internal
*/
#[Package('checkout')]
abstract class AbstractRuleLoader
{
Expand Down
3 changes: 3 additions & 0 deletions src/Core/Checkout/Cart/CachedRuleLoader.php
Expand Up @@ -7,6 +7,9 @@
use Shopware\Core\Framework\Log\Package;
use Symfony\Contracts\Cache\CacheInterface;

/**
* @internal Depend on the AbstractRuleLoader which is the definition of public API for this scope
*/
#[Package('checkout')]
class CachedRuleLoader extends AbstractRuleLoader
{
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Checkout/Cart/Facade/ContainerFacade.php
Expand Up @@ -22,7 +22,7 @@
*
* @script-service cart_manipulation
*
* @internal
* @final
*/
#[Package('checkout')]
class ContainerFacade extends ItemFacade
Expand Down
6 changes: 3 additions & 3 deletions src/Core/Checkout/Cart/Order/Transformer/CartTransformer.php
Expand Up @@ -4,8 +4,8 @@

use Shopware\Core\Checkout\Cart\Cart;
use Shopware\Core\Defaults;
use Shopware\Core\Framework\DataAbstractionLayer\FieldSerializer\JsonFieldSerializer;
use Shopware\Core\Framework\Log\Package;
use Shopware\Core\Framework\Util\Json;
use Shopware\Core\Framework\Util\Random;
use Shopware\Core\System\SalesChannel\SalesChannelContext;

Expand Down Expand Up @@ -35,8 +35,8 @@ public static function transform(Cart $cart, SalesChannelContext $context, strin
$data['orderDateTime'] = (new \DateTimeImmutable())->format(Defaults::STORAGE_DATE_TIME_FORMAT);
}

$data['itemRounding'] = json_decode(JsonFieldSerializer::encodeJson($context->getItemRounding()), true, 512, \JSON_THROW_ON_ERROR);
$data['totalRounding'] = json_decode(JsonFieldSerializer::encodeJson($context->getTotalRounding()), true, 512, \JSON_THROW_ON_ERROR);
$data['itemRounding'] = json_decode(Json::encode($context->getItemRounding()), true, 512, \JSON_THROW_ON_ERROR);
$data['totalRounding'] = json_decode(Json::encode($context->getTotalRounding()), true, 512, \JSON_THROW_ON_ERROR);

return $data;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Checkout/Cart/RuleLoader.php
Expand Up @@ -13,7 +13,7 @@
use Shopware\Core\Framework\Plugin\Exception\DecorationPatternException;

/**
* @internal
* @internal Depend on the AbstractRuleLoader which is the definition of public API for this scope
*/
#[Package('checkout')]
class RuleLoader extends AbstractRuleLoader
Expand Down
9 changes: 6 additions & 3 deletions src/Core/Checkout/Document/Service/DocumentConfigLoader.php
Expand Up @@ -14,9 +14,6 @@
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Contracts\Service\ResetInterface;

/**
* @internal
*/
#[Package('customer-order')]
final class DocumentConfigLoader implements EventSubscriberInterface, ResetInterface
{
Expand All @@ -32,6 +29,9 @@ public function __construct(private readonly EntityRepository $documentConfigRep
{
}

/**
* @internal
*/
public static function getSubscribedEvents(): array
{
return [
Expand Down Expand Up @@ -65,6 +65,9 @@ public function load(string $documentType, string $salesChannelId, Context $cont
return $this->configs[$documentType][$salesChannelId] = $config;
}

/**
* @internal
*/
public function reset(): void
{
$this->configs = [];
Expand Down
Expand Up @@ -163,9 +163,6 @@ class OrderLineItemEntity extends Entity

protected ?OrderLineItemDownloadCollection $downloads = null;

/**
* @internal
*/
protected ?PromotionEntity $promotion = null;

/**
Expand Down Expand Up @@ -449,33 +446,21 @@ public function setOrderTransactionCaptureRefundPositions(OrderTransactionCaptur
$this->orderTransactionCaptureRefundPositions = $orderTransactionCaptureRefundPositions;
}

/**
* @internal
*/
public function getPromotionId(): ?string
{
return $this->promotionId;
}

/**
* @internal
*/
public function setPromotionId(?string $promotionId): void
{
$this->promotionId = $promotionId;
}

/**
* @internal
*/
public function getPromotion(): ?PromotionEntity
{
return $this->promotion;
}

/**
* @internal
*/
public function setPromotion(?PromotionEntity $promotion): void
{
$this->promotion = $promotion;
Expand Down
Expand Up @@ -8,9 +8,9 @@
use Shopware\Core\Framework\Adapter\Cache\CacheValueCompressor;
use Shopware\Core\Framework\DataAbstractionLayer\Cache\EntityCacheKeyGenerator;
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\RuleAreas;
use Shopware\Core\Framework\DataAbstractionLayer\FieldSerializer\JsonFieldSerializer;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\Framework\Log\Package;
use Shopware\Core\Framework\Util\Json;
use Shopware\Core\System\SalesChannel\SalesChannelContext;
use Shopware\Core\System\SalesChannel\StoreApiResponse;
use Symfony\Component\HttpFoundation\Request;
Expand Down Expand Up @@ -92,7 +92,7 @@ private function generateKey(Request $request, SalesChannelContext $context, Cri
return null;
}

return self::buildName($context->getSalesChannelId()) . '-' . md5(JsonFieldSerializer::encodeJson($event->getParts()));
return self::buildName($context->getSalesChannelId()) . '-' . md5(Json::encode($event->getParts()));
}

/**
Expand Down
Expand Up @@ -17,7 +17,7 @@
/**
* @internal
*/
#[Package('core')]
#[Package('checkout')]
class PromotionRedemptionUpdater implements EventSubscriberInterface
{
/**
Expand Down
Expand Up @@ -8,9 +8,9 @@
use Shopware\Core\Framework\Adapter\Cache\CacheValueCompressor;
use Shopware\Core\Framework\DataAbstractionLayer\Cache\EntityCacheKeyGenerator;
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\RuleAreas;
use Shopware\Core\Framework\DataAbstractionLayer\FieldSerializer\JsonFieldSerializer;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\Framework\Log\Package;
use Shopware\Core\Framework\Util\Json;
use Shopware\Core\System\SalesChannel\SalesChannelContext;
use Shopware\Core\System\SalesChannel\StoreApiResponse;
use Symfony\Component\HttpFoundation\Request;
Expand Down Expand Up @@ -92,7 +92,7 @@ private function generateKey(Request $request, SalesChannelContext $context, Cri
return null;
}

return self::buildName($context->getSalesChannelId()) . '-' . md5(JsonFieldSerializer::encodeJson($event->getParts()));
return self::buildName($context->getSalesChannelId()) . '-' . md5(Json::encode($event->getParts()));
}

/**
Expand Down
Expand Up @@ -11,8 +11,8 @@
use Shopware\Core\Framework\Adapter\Cache\CacheValueCompressor;
use Shopware\Core\Framework\DataAbstractionLayer\Cache\EntityCacheKeyGenerator;
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\RuleAreas;
use Shopware\Core\Framework\DataAbstractionLayer\FieldSerializer\JsonFieldSerializer;
use Shopware\Core\Framework\Log\Package;
use Shopware\Core\Framework\Util\Json;
use Shopware\Core\Profiling\Profiler;
use Shopware\Core\System\SalesChannel\SalesChannelContext;
use Symfony\Component\HttpFoundation\Request;
Expand Down Expand Up @@ -90,7 +90,7 @@ private function generateKey(string $navigationId, Request $request, SalesChanne
return null;
}

return self::buildName($navigationId) . '-' . md5(JsonFieldSerializer::encodeJson($event->getParts()));
return self::buildName($navigationId) . '-' . md5(Json::encode($event->getParts()));
}

/**
Expand Down
Expand Up @@ -10,9 +10,9 @@
use Shopware\Core\Framework\Adapter\Cache\CacheValueCompressor;
use Shopware\Core\Framework\DataAbstractionLayer\Cache\EntityCacheKeyGenerator;
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\RuleAreas;
use Shopware\Core\Framework\DataAbstractionLayer\FieldSerializer\JsonFieldSerializer;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\Framework\Log\Package;
use Shopware\Core\Framework\Util\Json;
use Shopware\Core\Profiling\Profiler;
use Shopware\Core\System\SalesChannel\SalesChannelContext;
use Shopware\Core\System\SalesChannel\StoreApiResponse;
Expand Down Expand Up @@ -149,7 +149,7 @@ private function generateKey(string $active, string $rootId, int $depth, Request
return null;
}

return self::buildName($active) . '-' . md5(JsonFieldSerializer::encodeJson($event->getParts()));
return self::buildName($active) . '-' . md5(Json::encode($event->getParts()));
}

/**
Expand Down
Expand Up @@ -10,6 +10,7 @@
use Shopware\Core\Framework\DataAbstractionLayer\Write\EntityExistence;
use Shopware\Core\Framework\DataAbstractionLayer\Write\WriteParameterBag;
use Shopware\Core\Framework\Log\Package;
use Shopware\Core\Framework\Util\Json;
use Shopware\Core\Framework\Validation\Constraint\Uuid;
use Symfony\Component\Validator\Constraints\Collection;
use Symfony\Component\Validator\Constraints\NotBlank;
Expand Down Expand Up @@ -57,7 +58,7 @@ public function encode(
'trueCase' => 0,
], $item), $sequences);

yield $field->getStorageName() => JsonFieldSerializer::encodeJson($value);
yield $field->getStorageName() => Json::encode($value);
}

protected function getConstraints(Field $field): array
Expand Down
2 changes: 0 additions & 2 deletions src/Core/Content/Flow/Dispatching/AbstractFlowLoader.php
Expand Up @@ -10,7 +10,5 @@
#[Package('business-ops')]
abstract class AbstractFlowLoader
{
abstract public function getDecorated(): AbstractFlowLoader;

abstract public function load(): array;
}
3 changes: 0 additions & 3 deletions src/Core/Content/Flow/Dispatching/Action/FlowAction.php
Expand Up @@ -5,9 +5,6 @@
use Shopware\Core\Content\Flow\Dispatching\StorableFlow;
use Shopware\Core\Framework\Log\Package;

/**
* @internal
*/
#[Package('business-ops')]
abstract class FlowAction
{
Expand Down
7 changes: 1 addition & 6 deletions src/Core/Content/Flow/Dispatching/CachedFlowLoader.php
Expand Up @@ -36,11 +36,6 @@ public static function getSubscribedEvents(): array
];
}

public function getDecorated(): AbstractFlowLoader
{
return $this->decorated;
}

public function load(): array
{
if (!empty($this->flows)) {
Expand All @@ -50,7 +45,7 @@ public function load(): array
$value = $this->cache->get(self::KEY, function (ItemInterface $item) {
$item->tag([self::KEY]);

return CacheValueCompressor::compress($this->getDecorated()->load());
return CacheValueCompressor::compress($this->decorated->load());
});

return $this->flows = CacheValueCompressor::uncompress($value);
Expand Down
6 changes: 0 additions & 6 deletions src/Core/Content/Flow/Dispatching/FlowLoader.php
Expand Up @@ -6,7 +6,6 @@
use Psr\Log\LoggerInterface;
use Shopware\Core\Framework\DataAbstractionLayer\Doctrine\FetchModeHelper;
use Shopware\Core\Framework\Log\Package;
use Shopware\Core\Framework\Plugin\Exception\DecorationPatternException;

/**
* @internal not intended for decoration or replacement
Expand All @@ -20,11 +19,6 @@ public function __construct(
) {
}

public function getDecorated(): AbstractFlowLoader
{
throw new DecorationPatternException(self::class);
}

public function load(): array
{
$flows = $this->connection->fetchAllAssociative(
Expand Down
8 changes: 5 additions & 3 deletions src/Core/Content/Flow/Dispatching/StorableFlow.php
Expand Up @@ -7,19 +7,21 @@
use Shopware\Core\Framework\Log\Package;

/**
* @internal
* @final
*/
#[Package('business-ops')]
class StorableFlow
{
protected ?FlowState $state = null;
private ?FlowState $state = null;

/**
* @var array<string, mixed>
*/
protected array $config = [];
private array $config = [];

/**
* @internal
*
* @param array<string, mixed> $store
* @param array<string, mixed> $data
*/
Expand Down
Expand Up @@ -11,8 +11,8 @@
use Shopware\Core\Framework\Adapter\Cache\CacheValueCompressor;
use Shopware\Core\Framework\DataAbstractionLayer\Cache\EntityCacheKeyGenerator;
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\RuleAreas;
use Shopware\Core\Framework\DataAbstractionLayer\FieldSerializer\JsonFieldSerializer;
use Shopware\Core\Framework\Log\Package;
use Shopware\Core\Framework\Util\Json;
use Shopware\Core\System\SalesChannel\SalesChannelContext;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
Expand Down Expand Up @@ -86,7 +86,7 @@ private function generateKey(string $landingPageId, Request $request, SalesChann
return null;
}

return self::buildName($landingPageId) . '-' . md5(JsonFieldSerializer::encodeJson($event->getParts()));
return self::buildName($landingPageId) . '-' . md5(Json::encode($event->getParts()));
}

/**
Expand Down

0 comments on commit 0d89c71

Please sign in to comment.