Merge branch '1.13' into 2.0

* 1.13:
  [API][Behat] Create a wrapper for iri conversion [API][Behat] Extract section aware iri conversion into a standalone service
  [API][Maintenance] Swap deprecated IriConverterInterface for the not deprecated one
This commit is contained in:
Grzegorz Sadowski 2023-10-06 14:01:12 +02:00
commit 698bbbdf79
No known key found for this signature in database
GPG key ID: EF87FF4E6E3BD364
55 changed files with 352 additions and 365 deletions

View file

@ -28,7 +28,6 @@ return static function (ECSConfig $config): void {
InlineDocCommentDeclarationSniff::class . '.NoAssignment',
VisibilityRequiredFixer::class => ['*Spec.php'],
'**/var/*',
'src/Sylius/Behat/Service/Converter/IriConverter.php',
]);
$config->ruleWithConfiguration(PhpdocSeparationFixer::class, ['groups' => [['Given', 'When', 'Then']]]);
$config->ruleWithConfiguration(

View file

@ -34,7 +34,6 @@
<DeprecatedClass>
<errorLevel type="info">
<referencedClass name="ApiPlatform\Core\Api\IriConverterInterface" /> <!-- deprecated in ApiPlatform 2.7 -->
<referencedClass name="ApiPlatform\Core\Metadata\Extractor\XmlExtractor" /> <!-- deprecated in ApiPlatform 2.7 -->
<referencedClass name="Http\Message\MessageFactory" /> <!-- deprecated in HttpMessage 1.1 -->
<referencedClass name="Payum\Core\Action\GatewayAwareAction" />
@ -60,7 +59,6 @@
<DeprecatedInterface>
<errorLevel type="info">
<referencedClass name="ApiPlatform\Core\Api\IriConverterInterface" /> <!-- deprecated in ApiPlatform 2.7 -->
<referencedClass name="Sylius\Bundle\ShopBundle\Calculator\OrderItemsSubtotalCalculatorInterface" />
<referencedClass name="Sylius\Component\User\Security\UserPasswordEncoderInterface" />
<referencedClass name="Symfony\Component\Messenger\Handler\MessageHandlerInterface" /> <!-- deprecated in Symfony 6.2 -->

View file

@ -13,7 +13,7 @@ declare(strict_types=1);
namespace Sylius\Behat\Context\Api\Admin;
use ApiPlatform\Core\Api\IriConverterInterface;
use ApiPlatform\Api\IriConverterInterface;
use Behat\Behat\Context\Context;
use Sylius\Behat\Client\ApiClientInterface;
use Sylius\Behat\Client\ResponseCheckerInterface;
@ -36,7 +36,7 @@ final class BrowsingCatalogPromotionProductVariantsContext implements Context
public function iBrowseVariantsAffectedByCatalogPromotion(CatalogPromotionInterface $catalogPromotion): void
{
$this->client->index(Resources::PRODUCT_VARIANTS);
$this->client->addFilter('catalogPromotion', $this->iriConverter->getIriFromItem($catalogPromotion));
$this->client->addFilter('catalogPromotion', $this->iriConverter->getIriFromResource($catalogPromotion));
$this->client->filter();
}

View file

@ -13,7 +13,7 @@ declare(strict_types=1);
namespace Sylius\Behat\Context\Api\Admin;
use ApiPlatform\Core\Api\IriConverterInterface;
use ApiPlatform\Api\IriConverterInterface;
use Behat\Behat\Context\Context;
use Sylius\Behat\Client\ApiClientInterface;
use Sylius\Behat\Client\RequestBuilder;
@ -147,7 +147,7 @@ final class ManagingAdministratorsContext implements Context
$builder->withHeader('CONTENT_TYPE', 'multipart/form-data');
$builder->withHeader('HTTP_ACCEPT', 'application/ld+json');
$builder->withHeader('HTTP_Authorization', 'Bearer ' . $this->sharedStorage->get('token'));
$builder->withParameter('owner', $this->iriConverter->getIriFromItem($administrator));
$builder->withParameter('owner', $this->iriConverter->getIriFromResource($administrator));
$builder->withFile('file', new UploadedFile($this->minkParameters['files_path'] . $avatar, basename($avatar)));
$response = $this->client->request($builder->build());

View file

@ -13,11 +13,12 @@ declare(strict_types=1);
namespace Sylius\Behat\Context\Api\Admin;
use ApiPlatform\Core\Api\IriConverterInterface;
use ApiPlatform\Api\IriConverterInterface;
use Behat\Behat\Context\Context;
use Sylius\Behat\Client\ApiClientInterface;
use Sylius\Behat\Client\ResponseCheckerInterface;
use Sylius\Behat\Context\Api\Resources;
use Sylius\Behat\Service\Converter\SectionAwareIriConverterInterface;
use Sylius\Behat\Service\SharedStorageInterface;
use Sylius\Bundle\CoreBundle\CatalogPromotion\Calculator\FixedDiscountPriceCalculator;
use Sylius\Bundle\CoreBundle\CatalogPromotion\Calculator\PercentageDiscountPriceCalculator;
@ -38,6 +39,7 @@ final class ManagingCatalogPromotionsContext implements Context
private ApiClientInterface $client,
private ResponseCheckerInterface $responseChecker,
private IriConverterInterface $iriConverter,
private SectionAwareIriConverterInterface $sectionAwareIriConverter,
private SharedStorageInterface $sharedStorage,
) {
}
@ -142,7 +144,7 @@ final class ManagingCatalogPromotionsContext implements Context
*/
public function iMakeItAvailableInChannel(ChannelInterface $channel): void
{
$this->client->addRequestData('channels', [$this->iriConverter->getIriFromItemInSection($channel, 'admin')]);
$this->client->addRequestData('channels', [$this->sectionAwareIriConverter->getIriFromResourceInSection($channel, 'admin')]);
}
/**
@ -152,7 +154,7 @@ final class ManagingCatalogPromotionsContext implements Context
{
$channels = $this->responseChecker->getValue($this->client->show(Resources::CATALOG_PROMOTIONS, $catalogPromotion->getCode()), 'channels');
foreach (array_keys($channels, $this->iriConverter->getIriFromItemInSection($channel, 'admin')) as $key) {
foreach (array_keys($channels, $this->sectionAwareIriConverter->getIriFromResourceInSection($channel, 'admin')) as $key) {
unset($channels[$key]);
}
@ -759,7 +761,7 @@ final class ManagingCatalogPromotionsContext implements Context
$this->client->buildUpdateRequest(Resources::CATALOG_PROMOTIONS, $catalogPromotionCode);
$content = $this->client->getContent();
foreach (array_keys($content['channels'], $this->iriConverter->getIriFromItem($channel)) as $key) {
foreach (array_keys($content['channels'], $this->iriConverter->getIriFromResource($channel)) as $key) {
unset($content['channels'][$key]);
}
@ -777,7 +779,7 @@ final class ManagingCatalogPromotionsContext implements Context
): void {
$this->client->buildUpdateRequest(Resources::CATALOG_PROMOTIONS, $catalogPromotion->getCode());
$content = $this->client->getContent();
$content['channels'][] = $this->iriConverter->getIriFromItem($channel);
$content['channels'][] = $this->iriConverter->getIriFromResource($channel);
$this->client->updateRequestData(['channels' => $content['channels']]);
$this->client->update();
}
@ -796,11 +798,11 @@ final class ManagingCatalogPromotionsContext implements Context
$this->client->buildUpdateRequest(Resources::CATALOG_PROMOTIONS, $catalogPromotionCode);
$content = $this->client->getContent();
foreach (array_keys($content['channels'], $this->iriConverter->getIriFromItem($removedChannel)) as $key) {
foreach (array_keys($content['channels'], $this->iriConverter->getIriFromResource($removedChannel)) as $key) {
unset($content['channels'][$key]);
}
$content['channels'][] = $this->iriConverter->getIriFromItem($addedChannel);
$content['channels'][] = $this->iriConverter->getIriFromResource($addedChannel);
$this->client->setRequestData($content);
$this->client->update();
}
@ -837,7 +839,7 @@ final class ManagingCatalogPromotionsContext implements Context
*/
public function iFilterByChannel(ChannelInterface $channel): void
{
$this->client->addFilter('channel', $this->iriConverter->getIriFromItem($channel));
$this->client->addFilter('channel', $this->iriConverter->getIriFromResource($channel));
$this->client->filter();
}
@ -1174,7 +1176,7 @@ final class ManagingCatalogPromotionsContext implements Context
$this->responseChecker->hasValueInCollection(
$this->client->show(Resources::CATALOG_PROMOTIONS, $catalogPromotion->getCode()),
'channels',
$this->iriConverter->getIriFromItemInSection($channel, 'admin'),
$this->sectionAwareIriConverter->getIriFromResourceInSection($channel, 'admin'),
),
sprintf('Catalog promotion is not assigned to %s channel', $channel->getName()),
);
@ -1193,7 +1195,7 @@ final class ManagingCatalogPromotionsContext implements Context
$this->responseChecker->hasValueInCollection(
$this->client->show(Resources::CATALOG_PROMOTIONS, $catalogPromotion->getCode()),
'channels',
$this->iriConverter->getIriFromItemInSection($channel, 'admin'),
$this->sectionAwareIriConverter->getIriFromResourceInSection($channel, 'admin'),
),
sprintf('Catalog promotion is assigned to %s channel', $channel->getName()),
);
@ -1656,7 +1658,7 @@ final class ManagingCatalogPromotionsContext implements Context
'name' => $name,
'priority' => $priority,
'enabled' => true,
'channels' => [$this->iriConverter->getIriFromItem($channel)],
'channels' => [$this->iriConverter->getIriFromResource($channel)],
'exclusive' => $exclusive,
'translations' => ['en_US' => [
'locale' => 'en_US',

View file

@ -13,11 +13,12 @@ declare(strict_types=1);
namespace Sylius\Behat\Context\Api\Admin;
use ApiPlatform\Core\Api\IriConverterInterface;
use ApiPlatform\Api\IriConverterInterface;
use Behat\Behat\Context\Context;
use Sylius\Behat\Client\ApiClientInterface;
use Sylius\Behat\Client\ResponseCheckerInterface;
use Sylius\Behat\Context\Api\Resources;
use Sylius\Behat\Service\Converter\SectionAwareIriConverterInterface;
use Sylius\Behat\Service\SharedStorageInterface;
use Sylius\Component\Core\Model\ChannelInterface;
use Sylius\Component\Core\Model\TaxonInterface;
@ -31,6 +32,7 @@ final class ManagingChannelPriceHistoryConfigsContext implements Context
private ApiClientInterface $client,
private ResponseCheckerInterface $responseChecker,
private IriConverterInterface $iriConverter,
private SectionAwareIriConverterInterface $sectionAwareIriConverter,
) {
}
@ -80,7 +82,7 @@ final class ManagingChannelPriceHistoryConfigsContext implements Context
{
$taxonsIris = [];
foreach ($taxons as $taxon) {
$taxonsIris[] = $this->iriConverter->getIriFromItem($taxon);
$taxonsIris[] = $this->iriConverter->getIriFromResource($taxon);
}
$this->client->addRequestData('taxonsExcludedFromShowingLowestPrice', $taxonsIris);
@ -205,7 +207,7 @@ final class ManagingChannelPriceHistoryConfigsContext implements Context
private function isResourceAdminIriInArray(ResourceInterface $resource, array $iris): bool
{
$iri = $this->iriConverter->getIriFromItemInSection($resource, 'admin');
$iri = $this->sectionAwareIriConverter->getIriFromResourceInSection($resource, 'admin');
return in_array($iri, $iris, true);
}

View file

@ -13,11 +13,12 @@ declare(strict_types=1);
namespace Sylius\Behat\Context\Api\Admin;
use ApiPlatform\Core\Api\IriConverterInterface;
use ApiPlatform\Api\IriConverterInterface;
use Behat\Behat\Context\Context;
use Sylius\Behat\Client\ApiClientInterface;
use Sylius\Behat\Client\ResponseCheckerInterface;
use Sylius\Behat\Context\Api\Resources;
use Sylius\Behat\Service\Converter\SectionAwareIriConverterInterface;
use Sylius\Component\Addressing\Model\CountryInterface;
use Sylius\Component\Core\Formatter\StringInflector;
use Sylius\Component\Core\Model\ChannelInterface;
@ -34,6 +35,7 @@ final class ManagingChannelsContext implements Context
private ApiClientInterface $client,
private ResponseCheckerInterface $responseChecker,
private IriConverterInterface $iriConverter,
private SectionAwareIriConverterInterface $sectionAwareIriConverter,
) {
}
@ -69,7 +71,7 @@ final class ManagingChannelsContext implements Context
*/
public function iChooseAsTheBaseCurrency(CurrencyInterface $currency): void
{
$this->client->addRequestData('baseCurrency', $this->iriConverter->getIriFromItemInSection($currency, 'admin'));
$this->client->addRequestData('baseCurrency', $this->sectionAwareIriConverter->getIriFromResourceInSection($currency, 'admin'));
}
/**
@ -77,7 +79,7 @@ final class ManagingChannelsContext implements Context
*/
public function iMakeItAvailableInLocale(LocaleInterface $locale): void
{
$this->client->addRequestData('locales', [$this->iriConverter->getIriFromItem($locale)]);
$this->client->addRequestData('locales', [$this->iriConverter->getIriFromResource($locale)]);
}
/**
@ -85,7 +87,7 @@ final class ManagingChannelsContext implements Context
*/
public function iChooseAsADefaultLocale(LocaleInterface $locale): void
{
$this->client->addRequestData('defaultLocale', $this->iriConverter->getIriFromItemInSection($locale, 'admin'));
$this->client->addRequestData('defaultLocale', $this->sectionAwareIriConverter->getIriFromResourceInSection($locale, 'admin'));
}
/**
@ -118,8 +120,8 @@ final class ManagingChannelsContext implements Context
public function iChooseAndAsOperatingCountries(CountryInterface $country, CountryInterface $otherCountry): void
{
$this->client->addRequestData('countries', [
$this->iriConverter->getIriFromItemInSection($country, 'admin'),
$this->iriConverter->getIriFromItemInSection($otherCountry, 'admin'),
$this->sectionAwareIriConverter->getIriFromResourceInSection($country, 'admin'),
$this->sectionAwareIriConverter->getIriFromResourceInSection($otherCountry, 'admin'),
]);
}
@ -144,7 +146,7 @@ final class ManagingChannelsContext implements Context
*/
public function iSpecifyMenuTaxonAs(TaxonInterface $taxon): void
{
$this->client->addRequestData('menuTaxon', $this->iriConverter->getIriFromItemInSection($taxon, 'admin'));
$this->client->addRequestData('menuTaxon', $this->sectionAwareIriConverter->getIriFromResourceInSection($taxon, 'admin'));
}
/**
@ -273,7 +275,7 @@ final class ManagingChannelsContext implements Context
{
Assert::same(
$this->responseChecker->getValue($this->client->show(Resources::CHANNELS, $channel->getCode()), 'menuTaxon'),
$this->iriConverter->getIriFromItemInSection($taxon, 'admin'),
$this->sectionAwareIriConverter->getIriFromResourceInSection($taxon, 'admin'),
sprintf('Channel %s does not have %s menu taxon', $channel->getName(), $taxon->getName()),
);
}

View file

@ -13,7 +13,7 @@ declare(strict_types=1);
namespace Sylius\Behat\Context\Api\Admin;
use ApiPlatform\Core\Api\IriConverterInterface;
use ApiPlatform\Api\IriConverterInterface;
use Behat\Behat\Context\Context;
use Sylius\Behat\Client\ApiClientInterface;
use Sylius\Behat\Client\ResponseCheckerInterface;
@ -365,7 +365,7 @@ final class ManagingCountriesContext implements Context
$countryFromResponse = $this->responseChecker->getResponseContent($response);
foreach ($countryFromResponse['provinces'] as $provinceFromResponse) {
yield $this->iriConverter->getItemFromIri($provinceFromResponse);
yield $this->iriConverter->getResourceFromIri($provinceFromResponse);
}
}
}

View file

@ -13,7 +13,7 @@ declare(strict_types=1);
namespace Sylius\Behat\Context\Api\Admin;
use ApiPlatform\Core\Api\IriConverterInterface;
use ApiPlatform\Api\IriConverterInterface;
use Behat\Behat\Context\Context;
use Sylius\Behat\Client\ApiClientInterface;
use Sylius\Behat\Client\ResponseCheckerInterface;
@ -111,7 +111,7 @@ final class ManagingOrdersContext implements Context
$this->responseChecker->hasItemWithValue(
$this->client->getLastResponse(),
'customer',
$this->iriConverter->getIriFromItem($customer),
$this->iriConverter->getIriFromResource($customer),
),
sprintf('There is no order for customer %s', $customer->getEmail()),
);

View file

@ -13,11 +13,11 @@ declare(strict_types=1);
namespace Sylius\Behat\Context\Api\Admin;
use ApiPlatform\Core\Api\IriConverterInterface;
use Behat\Behat\Context\Context;
use Sylius\Behat\Client\ApiClientInterface;
use Sylius\Behat\Client\ResponseCheckerInterface;
use Sylius\Behat\Context\Api\Resources;
use Sylius\Behat\Service\Converter\SectionAwareIriConverterInterface;
use Sylius\Component\Core\Formatter\StringInflector;
use Sylius\Component\Core\Model\ChannelInterface;
use Sylius\Component\Core\Model\CustomerInterface;
@ -30,7 +30,7 @@ final class ManagingPaymentsContext implements Context
public function __construct(
private ApiClientInterface $client,
private ResponseCheckerInterface $responseChecker,
private IriConverterInterface $iriConverter,
private SectionAwareIriConverterInterface $sectionAwareIriConverter,
private string $apiUrlPrefix,
) {
}
@ -169,7 +169,7 @@ final class ManagingPaymentsContext implements Context
Assert::true($this->responseChecker->hasItemWithValue(
$this->client->getLastResponse(),
'order',
$this->iriConverter->getIriFromItemInSection($order, 'admin'),
$this->sectionAwareIriConverter->getIriFromResourceInSection($order, 'admin'),
));
}
@ -181,7 +181,7 @@ final class ManagingPaymentsContext implements Context
Assert::false($this->responseChecker->hasItemWithValue(
$this->client->getLastResponse(),
'order',
$this->iriConverter->getIriFromItemInSection($order, 'admin'),
$this->sectionAwareIriConverter->getIriFromResourceInSection($order, 'admin'),
));
}
}

View file

@ -13,7 +13,7 @@ declare(strict_types=1);
namespace Sylius\Behat\Context\Api\Admin;
use ApiPlatform\Core\Api\IriConverterInterface;
use ApiPlatform\Api\IriConverterInterface;
use Behat\Behat\Context\Context;
use Sylius\Behat\Client\ApiClientInterface;
use Sylius\Behat\Context\Api\Resources;
@ -34,7 +34,7 @@ final class ManagingProductTaxonsContext implements Context
public function iChangeThatTheProductBelongsToTheTaxon(ProductInterface $product, TaxonInterface $taxon): void
{
$this->client->buildUpdateRequest(Resources::PRODUCT_TAXONS, (string) $product->getProductTaxons()->current()->getId());
$this->client->updateRequestData(['taxon' => $this->iriConverter->getIriFromItem($taxon)]);
$this->client->updateRequestData(['taxon' => $this->iriConverter->getIriFromResource($taxon)]);
$this->client->update();
}
@ -45,8 +45,8 @@ final class ManagingProductTaxonsContext implements Context
public function iAddTaxonToTheProduct(TaxonInterface $taxon, ProductInterface $product): void
{
$this->client->buildCreateRequest(Resources::PRODUCT_TAXONS);
$this->client->addRequestData('taxon', $this->iriConverter->getIriFromItem($taxon));
$this->client->addRequestData('product', $this->iriConverter->getIriFromItem($product));
$this->client->addRequestData('taxon', $this->iriConverter->getIriFromResource($taxon));
$this->client->addRequestData('product', $this->iriConverter->getIriFromResource($product));
$this->client->create();
}
@ -56,7 +56,7 @@ final class ManagingProductTaxonsContext implements Context
public function iTryToAssignAnEmptyTaxonToTheProduct(ProductInterface $product): void
{
$this->client->buildCreateRequest(Resources::PRODUCT_TAXONS);
$this->client->addRequestData('product', $this->iriConverter->getIriFromItem($product));
$this->client->addRequestData('product', $this->iriConverter->getIriFromResource($product));
$this->client->create();
}
@ -66,7 +66,7 @@ final class ManagingProductTaxonsContext implements Context
public function iTryToAssignAnEmptyProductToTheTaxon(TaxonInterface $taxon): void
{
$this->client->buildCreateRequest(Resources::PRODUCT_TAXONS);
$this->client->addRequestData('taxon', $this->iriConverter->getIriFromItem($taxon));
$this->client->addRequestData('taxon', $this->iriConverter->getIriFromResource($taxon));
$this->client->create();
}
@ -83,7 +83,7 @@ final class ManagingProductTaxonsContext implements Context
)->first();
$this->client->buildUpdateRequest(Resources::PRODUCTS, $product->getCode());
$this->client->addRequestData('productTaxons', [$this->iriConverter->getIriFromItem($productTaxon)]);
$this->client->addRequestData('productTaxons', [$this->iriConverter->getIriFromResource($productTaxon)]);
$this->client->update();
}

View file

@ -13,7 +13,7 @@ declare(strict_types=1);
namespace Sylius\Behat\Context\Api\Admin;
use ApiPlatform\Core\Api\IriConverterInterface;
use ApiPlatform\Api\IriConverterInterface;
use Behat\Behat\Context\Context;
use Sylius\Behat\Client\ApiClientInterface;
use Sylius\Behat\Client\ResponseCheckerInterface;
@ -41,7 +41,7 @@ final class ManagingProductVariantsContext implements Context
public function iWantToCreateANewProductVariant(ProductInterface $product): void
{
$this->client->buildCreateRequest(Resources::PRODUCT_VARIANTS);
$this->client->addRequestData('product', $this->iriConverter->getIriFromItem($product));
$this->client->addRequestData('product', $this->iriConverter->getIriFromResource($product));
}
/**
@ -262,7 +262,7 @@ final class ManagingProductVariantsContext implements Context
ChannelInterface $channel,
): void {
$this->client->buildCreateRequest(Resources::PRODUCT_VARIANTS);
$this->client->addRequestData('product', $this->iriConverter->getIriFromItem($product));
$this->client->addRequestData('product', $this->iriConverter->getIriFromResource($product));
$this->client->addRequestData('code', StringInflector::nameToCode($name));
$this->client->addRequestData('channelPricings', [

View file

@ -13,11 +13,11 @@ declare(strict_types=1);
namespace Sylius\Behat\Context\Api\Admin;
use ApiPlatform\Core\Api\IriConverterInterface;
use Behat\Behat\Context\Context;
use Sylius\Behat\Client\ApiClientInterface;
use Sylius\Behat\Client\ResponseCheckerInterface;
use Sylius\Behat\Context\Api\Resources;
use Sylius\Behat\Service\Converter\SectionAwareIriConverterInterface;
use Sylius\Behat\Service\SharedStorageInterface;
use Sylius\Component\Core\Model\AdminUserInterface;
use Sylius\Component\Core\Model\ProductInterface;
@ -34,7 +34,7 @@ final class ManagingProductsContext implements Context
public function __construct(
private ApiClientInterface $client,
private ResponseCheckerInterface $responseChecker,
private IriConverterInterface $iriConverter,
private SectionAwareIriConverterInterface $sectionAwareIriConverter,
private SharedStorageInterface $sharedStorage,
private string $apiUrlPrefix,
) {
@ -152,7 +152,7 @@ final class ManagingProductsContext implements Context
$productOptions = $this->responseChecker->getValue($this->client->show(Resources::PRODUCTS, $product->getCode()), 'options');
$productOptions[] = $this->iriConverter->getIriFromItemInSection($productOption, 'admin');
$productOptions[] = $this->sectionAwareIriConverter->getIriFromResourceInSection($productOption, 'admin');
$this->client->updateRequestData(['options' => $productOptions]);
}
@ -162,7 +162,7 @@ final class ManagingProductsContext implements Context
*/
public function iChooseMainTaxon(TaxonInterface $taxon): void
{
$this->client->updateRequestData(['mainTaxon' => $this->iriConverter->getIriFromItemInSection($taxon, 'admin')]);
$this->client->updateRequestData(['mainTaxon' => $this->sectionAwareIriConverter->getIriFromResourceInSection($taxon, 'admin')]);
}
/**
@ -411,7 +411,7 @@ final class ManagingProductsContext implements Context
$mainTaxon = $this->responseChecker->getValue($response, 'mainTaxon');
Assert::same($mainTaxon, $this->iriConverter->getIriFromItemInSection($taxon, 'admin'));
Assert::same($mainTaxon, $this->sectionAwareIriConverter->getIriFromResourceInSection($taxon, 'admin'));
}
/**
@ -464,7 +464,7 @@ final class ManagingProductsContext implements Context
$productFromResponse = $this->responseChecker->getResponseContent($response);
Assert::true(
in_array($this->iriConverter->getIriFromItemInSection($productOption, 'admin'), $productFromResponse['options'], true),
in_array($this->sectionAwareIriConverter->getIriFromResourceInSection($productOption, 'admin'), $productFromResponse['options'], true),
sprintf('Product with option %s does not exist', $productOption->getName()),
);
}
@ -506,7 +506,7 @@ final class ManagingProductsContext implements Context
$this->responseChecker->getCollectionItemsWithValue(
$response,
'reviewSubject',
$this->iriConverter->getIriFromItemInSection($product, 'admin'),
$this->sectionAwareIriConverter->getIriFromResourceInSection($product, 'admin'),
),
'Should be no reviews, but some exist',
);

View file

@ -13,11 +13,12 @@ declare(strict_types=1);
namespace Sylius\Behat\Context\Api\Admin;
use ApiPlatform\Core\Api\IriConverterInterface;
use ApiPlatform\Api\IriConverterInterface;
use Behat\Behat\Context\Context;
use Sylius\Behat\Client\ApiClientInterface;
use Sylius\Behat\Client\ResponseCheckerInterface;
use Sylius\Behat\Context\Api\Resources;
use Sylius\Behat\Service\Converter\SectionAwareIriConverterInterface;
use Sylius\Behat\Service\SharedStorageInterface;
use Sylius\Component\Channel\Model\ChannelInterface;
use Sylius\Component\Core\Formatter\StringInflector;
@ -36,6 +37,7 @@ final class ManagingShipmentsContext implements Context
private ApiClientInterface $client,
private ResponseCheckerInterface $responseChecker,
private IriConverterInterface $iriConverter,
private SectionAwareIriConverterInterface $sectionAwareIriConverter,
private SharedStorageInterface $sharedStorage,
private string $apiUrlPrefix,
) {
@ -162,7 +164,7 @@ final class ManagingShipmentsContext implements Context
{
Assert::true(
$this->responseChecker->hasItemWithValues($this->client->index(Resources::SHIPMENTS), [
'order' => $this->iriConverter->getIriFromItemInSection($order, 'admin'),
'order' => $this->sectionAwareIriConverter->getIriFromResourceInSection($order, 'admin'),
'state' => strtolower($shippingState),
]),
sprintf('Shipment for order %s with state %s does not exist', $order->getNumber(), $shippingState),
@ -179,7 +181,7 @@ final class ManagingShipmentsContext implements Context
$this->client->getLastResponse(),
--$position,
'order',
$this->iriConverter->getIriFromItem($order),
$this->iriConverter->getIriFromResource($order),
),
sprintf('On position %s there is no shipment for order %s', $position, $order->getNumber()),
);
@ -293,7 +295,7 @@ final class ManagingShipmentsContext implements Context
return $this->responseChecker->hasItemWithValue(
$this->client->getLastResponse(),
'order',
$this->iriConverter->getIriFromItemInSection($order, 'admin'),
$this->sectionAwareIriConverter->getIriFromResourceInSection($order, 'admin'),
);
}
}

View file

@ -13,11 +13,12 @@ declare(strict_types=1);
namespace Sylius\Behat\Context\Api\Admin;
use ApiPlatform\Core\Api\IriConverterInterface;
use ApiPlatform\Api\IriConverterInterface;
use Behat\Behat\Context\Context;
use Sylius\Behat\Client\ApiClientInterface;
use Sylius\Behat\Client\ResponseCheckerInterface;
use Sylius\Behat\Context\Api\Resources;
use Sylius\Behat\Service\Converter\SectionAwareIriConverterInterface;
use Sylius\Behat\Service\SharedStorageInterface;
use Sylius\Component\Addressing\Model\ZoneInterface;
use Sylius\Component\Core\Model\AdminUserInterface;
@ -34,6 +35,7 @@ final class ManagingShippingMethodsContext implements Context
private ApiClientInterface $client,
private ResponseCheckerInterface $responseChecker,
private IriConverterInterface $iriConverter,
private SectionAwareIriConverterInterface $sectionAwareIriConverter,
private SharedStorageInterface $sharedStorage,
) {
}
@ -115,7 +117,7 @@ final class ManagingShippingMethodsContext implements Context
'code' => 'FED_EX_CARRIER',
'position' => 0,
'translations' => ['en_US' => ['name' => 'FedEx Carrier', 'locale' => 'en_US']],
'zone' => $this->iriConverter->getIriFromItem($this->sharedStorage->get('zone')),
'zone' => $this->iriConverter->getIriFromResource($this->sharedStorage->get('zone')),
'calculator' => 'Flat rate per shipment',
'configuration' => [$this->sharedStorage->get('channel')->getCode() => ['amount' => 50]],
]);
@ -183,7 +185,7 @@ final class ManagingShippingMethodsContext implements Context
public function iDefineItForTheZone(ZoneInterface $zone = null): void
{
if (null !== $zone) {
$this->client->addRequestData('zone', $this->iriConverter->getIriFromItem($zone));
$this->client->addRequestData('zone', $this->iriConverter->getIriFromResource($zone));
}
}
@ -208,7 +210,7 @@ final class ManagingShippingMethodsContext implements Context
*/
public function iMakeItAvailableInChannel(ChannelInterface $channel): void
{
$this->client->addRequestData('channels', [$this->iriConverter->getIriFromItem($channel)]);
$this->client->addRequestData('channels', [$this->iriConverter->getIriFromResource($channel)]);
}
/**
@ -373,7 +375,7 @@ final class ManagingShippingMethodsContext implements Context
$this->responseChecker->hasValueInCollection(
$this->client->show(Resources::SHIPPING_METHODS, $shippingMethod->getCode()),
'channels',
$this->iriConverter->getIriFromItemInSection($channel, 'admin'),
$this->sectionAwareIriConverter->getIriFromResourceInSection($channel, 'admin'),
),
sprintf('Shipping method is not assigned to %s channel', $channel->getName()),
);

View file

@ -13,7 +13,7 @@ declare(strict_types=1);
namespace Sylius\Behat\Context\Api\Admin;
use ApiPlatform\Core\Api\IriConverterInterface;
use ApiPlatform\Api\IriConverterInterface;
use Behat\Behat\Context\Context;
use Sylius\Behat\Client\ApiClientInterface;
use Sylius\Behat\Client\ResponseCheckerInterface;
@ -72,7 +72,7 @@ class ManagingTaxRatesContext implements Context
return;
}
$this->client->addRequestData('zone', $this->iriConverter->getIriFromItem($zone));
$this->client->addRequestData('zone', $this->iriConverter->getIriFromResource($zone));
}
/**
@ -86,7 +86,7 @@ class ManagingTaxRatesContext implements Context
return;
}
$this->client->addRequestData('category', $this->iriConverter->getIriFromItem($taxCategory));
$this->client->addRequestData('category', $this->iriConverter->getIriFromResource($taxCategory));
}
/**
@ -448,7 +448,7 @@ class ManagingTaxRatesContext implements Context
public function thisTaxRateShouldBeApplicableForTheTaxCategory(TaxRateInterface $taxRate, TaxCategoryInterface $taxCategory): void
{
Assert::true(
$this->responseChecker->hasValue($this->client->show(Resources::TAX_RATES, (string) $taxRate->getCode()), 'category', $this->iriConverter->getIriFromItem($taxCategory)),
$this->responseChecker->hasValue($this->client->show(Resources::TAX_RATES, (string) $taxRate->getCode()), 'category', $this->iriConverter->getIriFromResource($taxCategory)),
sprintf('Tax rate is not applicable for %s tax category', $taxCategory),
);
}
@ -459,7 +459,7 @@ class ManagingTaxRatesContext implements Context
public function thisTaxRateShouldBeApplicableInZone(TaxRateInterface $taxRate, ZoneInterface $zone): void
{
Assert::true(
$this->responseChecker->hasValue($this->client->show(Resources::TAX_RATES, (string) $taxRate->getCode()), 'zone', $this->iriConverter->getIriFromItem($zone)),
$this->responseChecker->hasValue($this->client->show(Resources::TAX_RATES, (string) $taxRate->getCode()), 'zone', $this->iriConverter->getIriFromResource($zone)),
sprintf('Tax rate is not applicable for %s zone', $zone),
);
}

View file

@ -13,11 +13,11 @@ declare(strict_types=1);
namespace Sylius\Behat\Context\Api\Admin;
use ApiPlatform\Core\Api\IriConverterInterface;
use Behat\Behat\Context\Context;
use Sylius\Behat\Client\ApiClientInterface;
use Sylius\Behat\Client\ResponseCheckerInterface;
use Sylius\Behat\Context\Api\Resources;
use Sylius\Behat\Service\Converter\SectionAwareIriConverterInterface;
use Sylius\Behat\Service\SharedStorageInterface;
use Sylius\Component\Core\Formatter\StringInflector;
use Sylius\Component\Core\Model\ProductInterface;
@ -29,7 +29,7 @@ final class ManagingTaxonsContext implements Context
public function __construct(
private ApiClientInterface $client,
private ResponseCheckerInterface $responseChecker,
private IriConverterInterface $iriConverter,
private SectionAwareIriConverterInterface $sectionAwareIriConverter,
private SharedStorageInterface $sharedStorage,
) {
}
@ -122,7 +122,7 @@ final class ManagingTaxonsContext implements Context
*/
public function iSetItsParentTaxonTo(TaxonInterface $parentTaxon): void
{
$this->client->addRequestData('parent', $this->iriConverter->getIriFromItemInSection($parentTaxon, 'admin'));
$this->client->addRequestData('parent', $this->sectionAwareIriConverter->getIriFromResourceInSection($parentTaxon, 'admin'));
}
/**
@ -253,7 +253,7 @@ final class ManagingTaxonsContext implements Context
$this->client->getLastResponse(),
[
'code' => $taxon->getCode(),
'parent' => $this->iriConverter->getIriFromItemInSection($parentTaxon, 'admin'),
'parent' => $this->sectionAwareIriConverter->getIriFromResourceInSection($parentTaxon, 'admin'),
],
));
}

View file

@ -13,7 +13,7 @@ declare(strict_types=1);
namespace Sylius\Behat\Context\Api\Admin;
use ApiPlatform\Core\Api\IriConverterInterface;
use ApiPlatform\Api\IriConverterInterface;
use Behat\Behat\Context\Context;
use Sylius\Behat\Client\ApiClientInterface;
use Sylius\Behat\Client\ResponseCheckerInterface;

View file

@ -13,7 +13,7 @@ declare(strict_types=1);
namespace Sylius\Behat\Context\Api\Shop;
use ApiPlatform\Core\Api\IriConverterInterface;
use ApiPlatform\Api\IriConverterInterface;
use Behat\Behat\Context\Context;
use Sylius\Behat\Client\ApiClientInterface;
use Sylius\Behat\Client\ResponseCheckerInterface;
@ -266,7 +266,7 @@ final class AddressContext implements Context
*/
public function iTryToViewDetailsOfAddressBelongingTo(AddressInterface $address): void
{
$this->client->showByIri($this->iriConverter->getIriFromItem($address));
$this->client->showByIri($this->iriConverter->getIriFromResource($address));
}
/**

View file

@ -13,7 +13,7 @@ declare(strict_types=1);
namespace Sylius\Behat\Context\Api\Shop;
use ApiPlatform\Core\Api\IriConverterInterface;
use ApiPlatform\Api\IriConverterInterface;
use Behat\Behat\Context\Context;
use Sylius\Behat\Client\ApiClientInterface;
use Sylius\Behat\Client\RequestFactoryInterface;
@ -835,7 +835,7 @@ final class CartContext implements Context
'items',
);
$request->updateContent([
'productVariant' => $this->iriConverter->getIriFromItem($this->productVariantResolver->getVariant($product)),
'productVariant' => $this->iriConverter->getIriFromResource($this->productVariantResolver->getVariant($product)),
'quantity' => $quantity,
]);
@ -854,7 +854,7 @@ final class CartContext implements Context
'items',
);
$request->updateContent([
'productVariant' => $this->iriConverter->getIriFromItem($productVariant),
'productVariant' => $this->iriConverter->getIriFromResource($productVariant),
'quantity' => $quantity,
]);

View file

@ -13,7 +13,7 @@ declare(strict_types=1);
namespace Sylius\Behat\Context\Api\Shop;
use ApiPlatform\Core\Api\IriConverterInterface;
use ApiPlatform\Api\IriConverterInterface;
use Behat\Behat\Context\Context;
use Sylius\Behat\Client\ApiClientInterface;
use Sylius\Behat\Client\RequestFactoryInterface;
@ -492,7 +492,7 @@ final class CheckoutContext implements Context
HTTPRequest::METHOD_PATCH,
\sprintf('payments/%s', $this->getCart()['payments'][0]['id']),
);
$request->setContent(['paymentMethod' => $this->iriConverter->getIriFromItem($paymentMethod)]);
$request->setContent(['paymentMethod' => $this->iriConverter->getIriFromResource($paymentMethod)]);
$this->client->executeCustomRequest($request);
}
@ -578,7 +578,7 @@ final class CheckoutContext implements Context
$payments = $this->responseChecker->getValue($response, 'payments');
Assert::notEmpty($payments, 'No payments found in response.');
$paymentMethodIri = $this->iriConverter->getIriFromItem($paymentMethod);
$paymentMethodIri = $this->iriConverter->getIriFromResource($paymentMethod);
foreach ($payments as $payment) {
if ($payment['method'] !== $paymentMethodIri) {
continue;
@ -1502,7 +1502,7 @@ final class CheckoutContext implements Context
'items',
);
$request->setContent([
'productVariant' => $this->iriConverter->getIriFromItem($productVariant),
'productVariant' => $this->iriConverter->getIriFromResource($productVariant),
'quantity' => $quantity,
]);
@ -1585,7 +1585,7 @@ final class CheckoutContext implements Context
HTTPRequest::METHOD_PATCH,
sprintf('shipments/%s', $this->getCart()['shipments'][0]['id']),
);
$request->setContent(['shippingMethod' => $this->iriConverter->getIriFromItem($shippingMethod)]);
$request->setContent(['shippingMethod' => $this->iriConverter->getIriFromResource($shippingMethod)]);
return $this->client->executeCustomRequest($request);
}

View file

@ -13,7 +13,7 @@ declare(strict_types=1);
namespace Sylius\Behat\Context\Api\Shop;
use ApiPlatform\Core\Api\IriConverterInterface;
use ApiPlatform\Api\IriConverterInterface;
use Behat\Behat\Context\Context;
use Doctrine\Persistence\ObjectManager;
use Sylius\Behat\Client\ApiClientInterface;
@ -142,7 +142,7 @@ final class HomepageContext implements Context
$children = array_column($taxons, 'children');
foreach ($children[0] as $child) {
if (!empty($child)) {
array_push($menuItems, $this->iriConverter->getItemFromIri($child)->getName());
array_push($menuItems, $this->iriConverter->getResourceFromIri($child)->getName());
}
}

View file

@ -13,7 +13,7 @@ declare(strict_types=1);
namespace Sylius\Behat\Context\Api\Shop;
use ApiPlatform\Core\Api\IriConverterInterface;
use ApiPlatform\Api\IriConverterInterface;
use Behat\Behat\Context\Context;
use Sylius\Behat\Client\ApiClientInterface;
use Sylius\Behat\Client\ApiSecurityClientInterface;
@ -98,7 +98,7 @@ final class LoginContext implements Context
{
$this->iWantToResetPassword();
$this->iSpecifyTheEmail($email);
$this->addLocale($this->iriConverter->getIriFromItem($locale));
$this->addLocale($this->iriConverter->getIriFromResource($locale));
$this->iResetIt();
}
@ -271,7 +271,7 @@ final class LoginContext implements Context
$this->shopAuthenticationTokenClient->getResponse(),
'customer',
),
$this->iriConverter->getIriFromItem($customer),
$this->iriConverter->getIriFromResource($customer),
);
}

View file

@ -13,7 +13,7 @@ declare(strict_types=1);
namespace Sylius\Behat\Context\Api\Shop;
use ApiPlatform\Core\Api\IriConverterInterface;
use ApiPlatform\Api\IriConverterInterface;
use Behat\Behat\Context\Context;
use Sylius\Behat\Client\ApiClientInterface;
use Sylius\Behat\Client\RequestFactoryInterface;
@ -87,7 +87,7 @@ final class OrderContext implements Context
[],
$this->shopClient->getToken(),
);
$request->setContent(['paymentMethod' => $this->iriConverter->getIriFromItem($paymentMethod)]);
$request->setContent(['paymentMethod' => $this->iriConverter->getIriFromResource($paymentMethod)]);
$this->shopClient->executeCustomRequest($request);
}
@ -99,7 +99,7 @@ final class OrderContext implements Context
{
$request = $this->sharedStorage->get('payment_method_patch_request');
$request->setContent(['paymentMethod' => $this->iriConverter->getIriFromItem($paymentMethod)]);
$request->setContent(['paymentMethod' => $this->iriConverter->getIriFromResource($paymentMethod)]);
$this->shopClient->executeCustomRequest($request);
}
@ -208,7 +208,7 @@ final class OrderContext implements Context
): void {
$resources = $this->responseChecker->getValue($this->shopClient->getLastResponse(), $elementType . 's');
$resource = $this->iriConverter->getItemFromIri($resources[$position]['@id']);
$resource = $this->iriConverter->getResourceFromIri($resources[$position]['@id']);
Assert::same(ucfirst($resource->getState()), $elementStatus);
}
@ -340,7 +340,7 @@ final class OrderContext implements Context
->getValue($this->shopClient->show(Resources::ORDERS, $this->sharedStorage->get('cart_token')), 'payments')[0]
;
Assert::same($this->iriConverter->getIriFromItem($paymentMethod), $payment['method']);
Assert::same($this->iriConverter->getIriFromResource($paymentMethod), $payment['method']);
}
/**
@ -369,7 +369,7 @@ final class OrderContext implements Context
->getValue($this->shopClient->getLastResponse(), 'payments')[0]['method']['@id']
;
Assert::same($this->iriConverter->getItemFromIri($paymentMethodIri)->getCode(), $paymentMethod->getCode());
Assert::same($this->iriConverter->getResourceFromIri($paymentMethodIri)->getCode(), $paymentMethod->getCode());
}
/**

View file

@ -13,7 +13,7 @@ declare(strict_types=1);
namespace Sylius\Behat\Context\Api\Shop;
use ApiPlatform\Core\Api\IriConverterInterface;
use ApiPlatform\Api\IriConverterInterface;
use Behat\Behat\Context\Context;
use Doctrine\Common\Collections\ArrayCollection;
use Sylius\Behat\Client\ApiClientInterface;
@ -113,7 +113,7 @@ final class ProductContext implements Context
$this->client->index(Resources::PRODUCTS);
if ($taxon !== null) {
$this->client->addFilter('taxon', $this->iriConverter->getIriFromItem($taxon));
$this->client->addFilter('taxon', $this->iriConverter->getIriFromResource($taxon));
$this->client->filter();
}
}
@ -258,7 +258,7 @@ final class ProductContext implements Context
/** @var ProductVariantInterface $productVariant */
$productVariant = $this->sharedStorage->get('product_variant');
$variantResponse = $this->client->showByIri($this->iriConverter->getIriFromItem($productVariant));
$variantResponse = $this->client->showByIri($this->iriConverter->getIriFromResource($productVariant));
Assert::false($this->responseChecker->getValue($variantResponse, 'inStock'));
}
@ -282,7 +282,7 @@ final class ProductContext implements Context
{
/** @var ProductVariantInterface $checkedVariant */
$checkedVariant = $this->sharedStorage->get('product_variant');
$variant = $this->fetchItemByIri($this->iriConverter->getIriFromItem($checkedVariant));
$variant = $this->fetchItemByIri($this->iriConverter->getIriFromResource($checkedVariant));
Assert::same($variant['price'], $price);
Assert::same($variant['code'], $checkedVariant->getCode());
@ -656,7 +656,7 @@ final class ProductContext implements Context
*/
public function iShouldNotSeeTheProductAssociation(ProductAssociationTypeInterface $productAssociationType): void
{
$productAssociationTypeIri = $this->iriConverter->getIriFromItem($productAssociationType);
$productAssociationTypeIri = $this->iriConverter->getIriFromResource($productAssociationType);
/** @var ProductInterface $product */
$product = $this->sharedStorage->get('product');
@ -770,7 +770,7 @@ final class ProductContext implements Context
$productVariants = $this->responseChecker->getCollection(
$this->client->index(
Resources::PRODUCT_VARIANTS,
['product' => $this->iriConverter->getIriFromItem($this->sharedStorage->get('product'))],
['product' => $this->iriConverter->getIriFromResource($this->sharedStorage->get('product'))],
),
);
@ -845,7 +845,7 @@ final class ProductContext implements Context
private function isProductAssociated(ProductInterface $product, array $associatedProducts): bool
{
$productIri = $this->iriConverter->getIriFromItem($product);
$productIri = $this->iriConverter->getIriFromResource($product);
return in_array($productIri, $associatedProducts, true);
}

View file

@ -13,7 +13,7 @@ declare(strict_types=1);
namespace Sylius\Behat\Context\Api\Shop;
use ApiPlatform\Core\Api\IriConverterInterface;
use ApiPlatform\Api\IriConverterInterface;
use Behat\Behat\Context\Context;
use Sylius\Behat\Client\ApiClientInterface;
use Sylius\Behat\Client\ResponseCheckerInterface;
@ -42,7 +42,7 @@ final class ProductReviewContext implements Context
$product = $this->sharedStorage->get('product');
$this->client->index(Resources::PRODUCT_REVIEWS);
$this->client->addFilter('reviewSubject', $this->iriConverter->getIriFromItem($product));
$this->client->addFilter('reviewSubject', $this->iriConverter->getIriFromResource($product));
$this->client->filter();
}
@ -61,7 +61,7 @@ final class ProductReviewContext implements Context
public function iWantToReviewProduct(ProductInterface $product): void
{
$this->client->buildCreateRequest(Resources::PRODUCT_REVIEWS);
$this->client->addRequestData('product', $this->iriConverter->getIriFromItem($product));
$this->client->addRequestData('product', $this->iriConverter->getIriFromResource($product));
}
/**
@ -103,7 +103,7 @@ final class ProductReviewContext implements Context
$product = $this->sharedStorage->get('product');
$this->client->index(Resources::PRODUCT_REVIEWS);
$this->client->addFilter('reviewSubject', $this->iriConverter->getIriFromItem($product));
$this->client->addFilter('reviewSubject', $this->iriConverter->getIriFromResource($product));
$this->client->addFilter('itemsPerPage', 3);
$this->client->addFilter('order[createdAt]', 'desc');
$this->client->filter();

View file

@ -13,7 +13,7 @@ declare(strict_types=1);
namespace Sylius\Behat\Context\Api\Shop;
use ApiPlatform\Core\Api\IriConverterInterface;
use ApiPlatform\Api\IriConverterInterface;
use Behat\Behat\Context\Context;
use Sylius\Behat\Client\ApiClientInterface;
use Sylius\Behat\Client\ResponseCheckerInterface;
@ -69,7 +69,7 @@ final class ProductVariantContext implements Context
*/
public function iViewVariantsOfTheProduct(ProductInterface $product): void
{
$response = $this->client->index(Resources::PRODUCT_VARIANTS, ['product' => $this->iriConverter->getIriFromItem($product)]);
$response = $this->client->index(Resources::PRODUCT_VARIANTS, ['product' => $this->iriConverter->getIriFromResource($product)]);
$this->sharedStorage->set('product_variant_collection', $this->responseChecker->getCollection($response));
}
@ -79,7 +79,7 @@ final class ProductVariantContext implements Context
*/
public function iFilterVariantsByOption(ProductOptionValueInterface $optionValue): void
{
$this->client->addFilter('optionValues[]', $this->iriConverter->getIriFromItem($optionValue));
$this->client->addFilter('optionValues[]', $this->iriConverter->getIriFromResource($optionValue));
$response = $this->client->filter();
$this->sharedStorage->set('product_variant_collection', $this->responseChecker->getCollection($response));

View file

@ -13,7 +13,7 @@ declare(strict_types=1);
namespace Sylius\Behat\Context\Api\Shop;
use ApiPlatform\Core\Api\IriConverterInterface;
use ApiPlatform\Api\IriConverterInterface;
use Behat\Behat\Context\Context;
use Doctrine\Persistence\ObjectManager;
use Sylius\Behat\Client\ApiClientInterface;
@ -68,7 +68,7 @@ final class TaxonContext implements Context
private function isTaxonChildVisible(TaxonInterface $taxon): bool
{
$taxonIri = $this->iriConverter->getIriFromItem($taxon);
$taxonIri = $this->iriConverter->getIriFromResource($taxon);
$response = $this->client->getLastResponse();
$children = $this->responseChecker->getValue($response, 'children');

View file

@ -123,18 +123,20 @@
<service id="Psr\Clock\ClockInterface" alias="sylius.behat.clock" />
<service id="argument_resolver.datetime" alias="sylius.behat.clock" />
<service id="api_platform.iri_converter" class="Sylius\Behat\Service\Converter\IriConverter" public="false">
<argument type="service" id="api_platform.metadata.property.name_collection_factory" />
<argument type="service" id="api_platform.metadata.property.metadata_factory" />
<argument type="service" id="api_platform.item_data_provider" />
<service id="sylius.behat.section_iri_converter" class="Sylius\Behat\Service\Converter\SectionAwareIriConverter" public="false">
<argument type="service" id="api_platform.route_name_resolver" />
<argument type="service" id="api_platform.router" />
<argument type="service" id="api_platform.metadata.property.name_collection_factory" />
<argument type="service" id="api_platform.metadata.property.metadata_factory" />
<argument type="service" id="api_platform.property_accessor" />
<argument type="service" id="api_platform.identifiers_extractor.cached" />
<argument type="service" id="api_platform.subresource_data_provider" on-invalid="ignore" />
<argument type="service" id="api_platform.identifier.converter" on-invalid="ignore" />
<argument type="service" id="api_platform.resource_class_resolver" />
<argument type="service" id="api_platform.metadata.resource.metadata_factory" />
</service>
<service id="api_platform.iri_converter" class="Sylius\Behat\Service\Converter\IriConverter">
<argument type="service" id="api_platform.iri_converter.legacy" />
<argument type="service" id="api_platform.symfony.iri_converter" />
</service>
</services>
</container>

View file

@ -58,6 +58,7 @@
<argument type="service" id="sylius.behat.api_platform_client.admin" />
<argument type="service" id="Sylius\Behat\Client\ResponseCheckerInterface" />
<argument type="service" id="api_platform.iri_converter" />
<argument type="service" id="sylius.behat.section_iri_converter" />
</service>
<service id="sylius.behat.context.api.admin.managing_countries" class="Sylius\Behat\Context\Api\Admin\ManagingCountriesContext">
@ -105,7 +106,7 @@
<service id="sylius.behat.context.api.admin.managing_products" class="Sylius\Behat\Context\Api\Admin\ManagingProductsContext">
<argument type="service" id="sylius.behat.api_platform_client.admin" />
<argument type="service" id="Sylius\Behat\Client\ResponseCheckerInterface" />
<argument type="service" id="api_platform.iri_converter" />
<argument type="service" id="sylius.behat.section_iri_converter" />
<argument type="service" id="sylius.behat.shared_storage" />
<argument>%sylius.security.new_api_route%</argument>
</service>
@ -124,7 +125,7 @@
<service id="sylius.behat.context.api.admin.managing_taxons" class="Sylius\Behat\Context\Api\Admin\ManagingTaxonsContext">
<argument type="service" id="sylius.behat.api_platform_client.admin" />
<argument type="service" id="Sylius\Behat\Client\ResponseCheckerInterface" />
<argument type="service" id="api_platform.iri_converter" />
<argument type="service" id="sylius.behat.section_iri_converter" />
<argument type="service" id="sylius.behat.shared_storage" />
</service>
@ -137,6 +138,7 @@
<argument type="service" id="sylius.behat.api_platform_client.admin" />
<argument type="service" id="Sylius\Behat\Client\ResponseCheckerInterface" />
<argument type="service" id="api_platform.iri_converter" />
<argument type="service" id="sylius.behat.section_iri_converter" />
<argument type="service" id="sylius.behat.shared_storage" />
</service>
@ -154,7 +156,7 @@
<service id="sylius.behat.context.api.admin.managing_payments" class="Sylius\Behat\Context\Api\Admin\ManagingPaymentsContext">
<argument type="service" id="sylius.behat.api_platform_client.admin" />
<argument type="service" id="Sylius\Behat\Client\ResponseCheckerInterface" />
<argument type="service" id="api_platform.iri_converter" />
<argument type="service" id="sylius.behat.section_iri_converter" />
<argument>%sylius.security.new_api_route%</argument>
</service>
@ -162,6 +164,7 @@
<argument type="service" id="sylius.behat.api_platform_client.admin" />
<argument type="service" id="Sylius\Behat\Client\ResponseCheckerInterface" />
<argument type="service" id="api_platform.iri_converter" />
<argument type="service" id="sylius.behat.section_iri_converter" />
<argument type="service" id="sylius.behat.shared_storage" />
<argument>%sylius.security.new_api_route%</argument>
</service>
@ -202,6 +205,7 @@
<argument type="service" id="sylius.behat.api_platform_client.admin" />
<argument type="service" id="Sylius\Behat\Client\ResponseCheckerInterface" />
<argument type="service" id="api_platform.iri_converter" />
<argument type="service" id="sylius.behat.section_iri_converter" />
<argument type="service" id="sylius.behat.shared_storage" />
</service>
@ -230,6 +234,7 @@
<argument type="service" id="sylius.behat.api_platform_client.admin" />
<argument type="service" id="Sylius\Behat\Client\ResponseCheckerInterface" />
<argument type="service" id="api_platform.iri_converter" />
<argument type="service" id="sylius.behat.section_iri_converter" />
</service>
</services>
</container>

View file

@ -1,9 +1,9 @@
<?php
/*
* This file is part of the API Platform project.
* This file is part of the Sylius package.
*
* (c) Kévin Dunglas <dunglas@gmail.com>
* (c) Sylius Sp. z o.o.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@ -13,206 +13,71 @@ declare(strict_types=1);
namespace Sylius\Behat\Service\Converter;
use ApiPlatform\Core\Api\IdentifiersExtractor;
use ApiPlatform\Core\Api\IdentifiersExtractorInterface;
use ApiPlatform\Core\Api\IriConverterInterface;
use ApiPlatform\Core\Api\OperationType;
use ApiPlatform\Core\Api\ResourceClassResolverInterface;
use ApiPlatform\Core\Api\UrlGeneratorInterface;
use ApiPlatform\Core\Bridge\Symfony\Routing\RouteNameResolverInterface;
use ApiPlatform\Core\DataProvider\ItemDataProviderInterface;
use ApiPlatform\Core\DataProvider\OperationDataProviderTrait;
use ApiPlatform\Core\DataProvider\SubresourceDataProviderInterface;
use ApiPlatform\Core\Exception\InvalidArgumentException;
use ApiPlatform\Core\Exception\InvalidIdentifierException;
use ApiPlatform\Core\Exception\ItemNotFoundException;
use ApiPlatform\Core\Exception\RuntimeException;
use ApiPlatform\Core\Identifier\CompositeIdentifierParser;
use ApiPlatform\Core\Identifier\IdentifierConverterInterface;
use ApiPlatform\Core\Metadata\Property\Factory\PropertyMetadataFactoryInterface;
use ApiPlatform\Core\Metadata\Property\Factory\PropertyNameCollectionFactoryInterface;
use ApiPlatform\Core\Metadata\Resource\Factory\ResourceMetadataFactoryInterface;
use ApiPlatform\Core\Util\AttributesExtractor;
use ApiPlatform\Core\Util\ResourceClassInfoTrait;
use Symfony\Component\PropertyAccess\PropertyAccess;
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
use Symfony\Component\Routing\Exception\ExceptionInterface as RoutingExceptionInterface;
use Symfony\Component\Routing\RouterInterface;
use ApiPlatform\Api\IriConverterInterface;
use ApiPlatform\Api\UrlGeneratorInterface;
use ApiPlatform\Core\Api\IriConverterInterface as LegacyIriConverterInterface;
use ApiPlatform\Metadata\Operation;
/**
* Copied from src/Bridge/Symfony/Routing/IriConverter.php to add getIriFromItemInSection method
* Wrapper between the legacy iri converter and the new one
* @experimental
*/
final class IriConverter implements IriConverterInterface
final class IriConverter implements LegacyIriConverterInterface, IriConverterInterface
{
use OperationDataProviderTrait;
use ResourceClassInfoTrait;
private $routeNameResolver;
private $router;
private $identifiersExtractor;
public function __construct(
PropertyNameCollectionFactoryInterface $propertyNameCollectionFactory,
PropertyMetadataFactoryInterface $propertyMetadataFactory,
ItemDataProviderInterface $itemDataProvider,
RouteNameResolverInterface $routeNameResolver,
RouterInterface $router,
PropertyAccessorInterface $propertyAccessor = null,
IdentifiersExtractorInterface $identifiersExtractor = null,
SubresourceDataProviderInterface $subresourceDataProvider = null,
IdentifierConverterInterface $identifierConverter = null,
ResourceClassResolverInterface $resourceClassResolver = null,
ResourceMetadataFactoryInterface $resourceMetadataFactory = null
private LegacyIriConverterInterface $legacyIriConverter,
private IriConverterInterface $iriConverter,
) {
$this->itemDataProvider = $itemDataProvider;
$this->routeNameResolver = $routeNameResolver;
$this->router = $router;
$this->subresourceDataProvider = $subresourceDataProvider;
$this->identifierConverter = $identifierConverter;
$this->resourceClassResolver = $resourceClassResolver;
$this->identifiersExtractor = $identifiersExtractor ?: new IdentifiersExtractor($propertyNameCollectionFactory, $propertyMetadataFactory, $propertyAccessor ?? PropertyAccess::createPropertyAccessor());
$this->resourceMetadataFactory = $resourceMetadataFactory;
}
/**
* {@inheritdoc}
*
* @return object
*/
public function getItemFromIri(string $iri, array $context = [])
{
try {
$parameters = $this->router->match($iri);
} catch (RoutingExceptionInterface $e) {
throw new InvalidArgumentException(sprintf('No route matches "%s".', $iri), $e->getCode(), $e);
}
if (!isset($parameters['_api_resource_class'])) {
throw new InvalidArgumentException(sprintf('No resource associated to "%s".', $iri));
}
if (isset($parameters['_api_collection_operation_name'])) {
throw new InvalidArgumentException(sprintf('The iri "%s" references a collection not an item.', $iri));
}
$attributes = AttributesExtractor::extractAttributes($parameters);
try {
$identifiers = $this->extractIdentifiers($parameters, $attributes);
} catch (InvalidIdentifierException $e) {
throw new InvalidArgumentException($e->getMessage(), $e->getCode(), $e);
}
if ($this->identifierConverter) {
$context[IdentifierConverterInterface::HAS_IDENTIFIER_CONVERTER] = true;
}
if (isset($attributes['subresource_operation_name'])) {
if (($item = $this->getSubresourceData($identifiers, $attributes, $context)) && !\is_array($item)) {
return $item;
}
throw new ItemNotFoundException(sprintf('Item not found for "%s".', $iri));
}
if ($item = $this->getItemData($identifiers, $attributes, $context)) {
return $item;
}
throw new ItemNotFoundException(sprintf('Item not found for "%s".', $iri));
return $this->legacyIriConverter->getItemFromIri($iri, $context);
}
/**
* {@inheritdoc}
*/
public function getIriFromItem($item, int $referenceType = null): string
public function getIriFromItem($item, int $referenceType = UrlGeneratorInterface::ABS_PATH): string
{
$resourceClass = $this->getResourceClass($item, true);
return $this->legacyIriConverter->getIriFromItem($item, $referenceType);
}
try {
$identifiers = $this->identifiersExtractor->getIdentifiersFromItem($item);
} catch (RuntimeException $e) {
throw new InvalidArgumentException(sprintf('Unable to generate an IRI for the item of type "%s"', $resourceClass), $e->getCode(), $e);
}
public function getIriFromResourceClass(
string $resourceClass,
int $referenceType = UrlGeneratorInterface::ABS_PATH,
): string {
return $this->legacyIriConverter->getIriFromResourceClass($resourceClass, $referenceType);
}
return $this->getItemIriFromResourceClass(
public function getItemIriFromResourceClass(
string $resourceClass,
array $identifiers,
int $referenceType = UrlGeneratorInterface::ABS_PATH,
): string {
return $this->legacyIriConverter->getItemIriFromResourceClass($resourceClass, $identifiers, $referenceType);
}
public function getSubresourceIriFromResourceClass(
string $resourceClass,
array $identifiers,
int $referenceType = UrlGeneratorInterface::ABS_PATH,
): string {
return $this->legacyIriConverter->getSubresourceIriFromResourceClass(
$resourceClass,
$identifiers,
$this->getReferenceType($resourceClass, $referenceType)
$referenceType,
);
}
/**
* {@inheritdoc}
*/
public function getIriFromItemInSection($item, string $section, int $referenceType = null): string
public function getResourceFromIri(string $iri, array $context = [], ?Operation $operation = null): object
{
$resourceClass = $this->getResourceClass($item, true);
try {
$identifiers = $this->identifiersExtractor->getIdentifiersFromItem($item);
} catch (RuntimeException $e) {
throw new InvalidArgumentException(sprintf('Unable to generate an IRI for the item of type "%s"', $resourceClass), $e->getCode(), $e);
}
return $this->getItemIriFromResourceClass(
$resourceClass,
$identifiers,
$this->getReferenceType($resourceClass, $referenceType),
$section
);
return $this->iriConverter->getResourceFromIri($iri, $context, $operation);
}
/**
* {@inheritdoc}
*/
public function getIriFromResourceClass(string $resourceClass, int $referenceType = null): string
{
try {
return $this->router->generate($this->routeNameResolver->getRouteName($resourceClass, OperationType::COLLECTION), [], $this->getReferenceType($resourceClass, $referenceType));
} catch (RoutingExceptionInterface $e) {
throw new InvalidArgumentException(sprintf('Unable to generate an IRI for "%s".', $resourceClass), $e->getCode(), $e);
}
}
/**
* {@inheritdoc}
*/
public function getItemIriFromResourceClass(string $resourceClass, array $identifiers, int $referenceType = null, string $section = null): string
{
$routeName = $this->routeNameResolver->getRouteName($resourceClass, OperationType::ITEM, $section ? ['section' => $section] : []);
$metadata = $this->resourceMetadataFactory->create($resourceClass);
if (\count($identifiers) > 1 && true === $metadata->getAttribute('composite_identifier', true)) {
$identifiers = ['id' => CompositeIdentifierParser::stringify($identifiers)];
}
try {
return $this->router->generate($routeName, $identifiers, $this->getReferenceType($resourceClass, $referenceType));
} catch (RoutingExceptionInterface $e) {
throw new InvalidArgumentException(sprintf('Unable to generate an IRI for "%s".', $resourceClass), $e->getCode(), $e);
}
}
/**
* {@inheritdoc}
*/
public function getSubresourceIriFromResourceClass(string $resourceClass, array $context, int $referenceType = null): string
{
try {
return $this->router->generate($this->routeNameResolver->getRouteName($resourceClass, OperationType::SUBRESOURCE, $context), $context['subresource_identifiers'], $this->getReferenceType($resourceClass, $referenceType));
} catch (RoutingExceptionInterface $e) {
throw new InvalidArgumentException(sprintf('Unable to generate an IRI for "%s".', $resourceClass), $e->getCode(), $e);
}
}
private function getReferenceType(string $resourceClass, ?int $referenceType): ?int
{
if (null === $referenceType && null !== $this->resourceMetadataFactory) {
$metadata = $this->resourceMetadataFactory->create($resourceClass);
$referenceType = $metadata->getAttribute('url_generation_strategy');
}
return $referenceType ?? UrlGeneratorInterface::ABS_PATH;
public function getIriFromResource(
$resource,
int $referenceType = UrlGeneratorInterface::ABS_PATH,
?Operation $operation = null,
array $context = [],
): ?string {
return $this->iriConverter->getIriFromResource($resource, $referenceType, $operation, $context);
}
}

View file

@ -0,0 +1,89 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Sylius Sp. z o.o.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Sylius\Behat\Service\Converter;
use ApiPlatform\Api\UrlGeneratorInterface;
use ApiPlatform\Core\Api\IdentifiersExtractor;
use ApiPlatform\Core\Api\IdentifiersExtractorInterface;
use ApiPlatform\Core\Api\OperationType;
use ApiPlatform\Core\Api\ResourceClassResolverInterface;
use ApiPlatform\Core\Bridge\Symfony\Routing\RouteNameResolverInterface;
use ApiPlatform\Core\Exception\InvalidArgumentException;
use ApiPlatform\Core\Exception\RuntimeException;
use ApiPlatform\Core\Identifier\CompositeIdentifierParser;
use ApiPlatform\Core\Metadata\Property\Factory\PropertyMetadataFactoryInterface;
use ApiPlatform\Core\Metadata\Property\Factory\PropertyNameCollectionFactoryInterface;
use ApiPlatform\Core\Metadata\Resource\Factory\ResourceMetadataFactoryInterface;
use ApiPlatform\Core\Util\ResourceClassInfoTrait;
use Symfony\Component\PropertyAccess\PropertyAccess;
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
use Symfony\Component\Routing\Exception\ExceptionInterface as RoutingExceptionInterface;
use Symfony\Component\Routing\RouterInterface;
/** @experimental */
final class SectionAwareIriConverter implements SectionAwareIriConverterInterface
{
use ResourceClassInfoTrait;
private IdentifiersExtractorInterface $identifiersExtractor;
public function __construct(
private RouteNameResolverInterface $routeNameResolver,
private RouterInterface $router,
PropertyNameCollectionFactoryInterface $propertyNameCollectionFactory,
PropertyMetadataFactoryInterface $propertyMetadataFactory,
PropertyAccessorInterface $propertyAccessor = null,
IdentifiersExtractorInterface $identifiersExtractor = null,
ResourceClassResolverInterface $resourceClassResolver = null,
ResourceMetadataFactoryInterface $resourceMetadataFactory = null,
) {
$this->identifiersExtractor = $identifiersExtractor ?: new IdentifiersExtractor($propertyNameCollectionFactory, $propertyMetadataFactory, $propertyAccessor ?? PropertyAccess::createPropertyAccessor());
$this->resourceClassResolver = $resourceClassResolver;
$this->resourceMetadataFactory = $resourceMetadataFactory;
}
public function getIriFromResourceInSection(object $item, string $section, int $referenceType = null): string
{
$resourceClass = $this->getResourceClass($item, true);
try {
$identifiers = $this->identifiersExtractor->getIdentifiersFromItem($item);
} catch (RuntimeException $e) {
throw new InvalidArgumentException(sprintf('Unable to generate an IRI for the item of type "%s"', $resourceClass), $e->getCode(), $e);
}
$routeName = $this->routeNameResolver->getRouteName($resourceClass, OperationType::ITEM, $section ? ['section' => $section] : []);
$metadata = $this->resourceMetadataFactory->create($resourceClass);
if (\count($identifiers) > 1 && true === $metadata->getAttribute('composite_identifier', true)) {
$identifiers = ['id' => CompositeIdentifierParser::stringify($identifiers)];
}
try {
return $this->router->generate($routeName, $identifiers, $this->getReferenceType($resourceClass, $referenceType));
} catch (RoutingExceptionInterface $e) {
throw new InvalidArgumentException(sprintf('Unable to generate an IRI for "%s".', $resourceClass), $e->getCode(), $e);
}
}
private function getReferenceType(string $resourceClass, ?int $referenceType): ?int
{
if (null === $referenceType && null !== $this->resourceMetadataFactory) {
$metadata = $this->resourceMetadataFactory->create($resourceClass);
$referenceType = $metadata->getAttribute('url_generation_strategy');
}
return $referenceType ?? UrlGeneratorInterface::ABS_PATH;
}
}

View file

@ -0,0 +1,19 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Sylius Sp. z o.o.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Sylius\Behat\Service\Converter;
interface SectionAwareIriConverterInterface
{
public function getIriFromResourceInSection(object $item, string $section, int $referenceType = null): string;
}

View file

@ -13,7 +13,7 @@ declare(strict_types=1);
namespace Sylius\Bundle\ApiBundle\Controller;
use ApiPlatform\Core\Api\IriConverterInterface;
use ApiPlatform\Api\IriConverterInterface;
use Sylius\Component\Channel\Context\ChannelContextInterface;
use Sylius\Component\Core\Model\ChannelInterface;
use Sylius\Component\Core\Repository\ProductRepositoryInterface;
@ -47,7 +47,7 @@ final class GetProductBySlugAction
throw new NotFoundHttpException('Not Found');
}
$iri = $this->iriConverter->getIriFromItem($product);
$iri = $this->iriConverter->getIriFromResource($product);
$request = $this->requestStack->getCurrentRequest();

View file

@ -13,7 +13,7 @@ declare(strict_types=1);
namespace Sylius\Bundle\ApiBundle\Controller;
use ApiPlatform\Core\Api\IriConverterInterface;
use ApiPlatform\Api\IriConverterInterface;
use Sylius\Component\Core\Model\AdminUserInterface;
use Sylius\Component\Core\Model\ImageInterface;
use Sylius\Component\Core\Repository\AvatarImageRepositoryInterface;
@ -49,7 +49,7 @@ final class UploadAvatarImageAction
Assert::notEmpty($ownerIri);
/** @var ResourceInterface|AdminUserInterface $owner */
$owner = $this->iriConverter->getItemFromIri($ownerIri);
$owner = $this->iriConverter->getResourceFromIri($ownerIri);
Assert::isInstanceOf($owner, AdminUserInterface::class);
$oldImage = $owner->getImage();

View file

@ -13,7 +13,7 @@ declare(strict_types=1);
namespace Sylius\Bundle\ApiBundle\EventListener;
use ApiPlatform\Core\Api\IriConverterInterface;
use ApiPlatform\Api\IriConverterInterface;
use Lexik\Bundle\JWTAuthenticationBundle\Event\AuthenticationSuccessEvent;
use Sylius\Component\Core\Model\AdminUserInterface;
@ -32,7 +32,7 @@ final class AdminAuthenticationSuccessListener
return;
}
$data['adminUser'] = $this->iriConverter->getIriFromItem($adminUser);
$data['adminUser'] = $this->iriConverter->getIriFromResource($adminUser);
$event->setData($data);
}

View file

@ -13,7 +13,7 @@ declare(strict_types=1);
namespace Sylius\Bundle\ApiBundle\EventListener;
use ApiPlatform\Core\Api\IriConverterInterface;
use ApiPlatform\Api\IriConverterInterface;
use Lexik\Bundle\JWTAuthenticationBundle\Event\AuthenticationSuccessEvent;
use Sylius\Component\Core\Model\CustomerInterface;
use Sylius\Component\Core\Model\ShopUserInterface;
@ -36,7 +36,7 @@ final class AuthenticationSuccessListener
/** @var CustomerInterface $customer */
$customer = $user->getCustomer();
$data['customer'] = $this->iriConverter->getIriFromItem($customer);
$data['customer'] = $this->iriConverter->getIriFromResource($customer);
$event->setData($data);
}

View file

@ -13,7 +13,7 @@ declare(strict_types=1);
namespace Sylius\Bundle\ApiBundle\Filter\Doctrine;
use ApiPlatform\Core\Api\IriConverterInterface;
use ApiPlatform\Api\IriConverterInterface;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\AbstractContextAwareFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Util\QueryNameGeneratorInterface;
use Doctrine\ORM\QueryBuilder;
@ -48,7 +48,7 @@ final class CatalogPromotionChannelFilter extends AbstractContextAwareFilter
return;
}
$channel = $this->iriConverter->getItemFromIri($value);
$channel = $this->iriConverter->getResourceFromIri($value);
$parameterName = $queryNameGenerator->generateParameterName($property);
$rootAlias = $queryBuilder->getRootAliases()[0];
$queryBuilder

View file

@ -13,7 +13,7 @@ declare(strict_types=1);
namespace Sylius\Bundle\ApiBundle\Filter\Doctrine;
use ApiPlatform\Core\Api\IriConverterInterface;
use ApiPlatform\Api\IriConverterInterface;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\AbstractContextAwareFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Util\QueryNameGeneratorInterface;
use Doctrine\ORM\Query\Expr\Join;
@ -49,7 +49,7 @@ final class ProductVariantCatalogPromotionFilter extends AbstractContextAwareFil
return;
}
$catalogPromotion = $this->iriConverter->getItemFromIri($value);
$catalogPromotion = $this->iriConverter->getResourceFromIri($value);
$parameterName = $queryNameGenerator->generateParameterName($property);
$channelPricingJoinAlias = $queryNameGenerator->generateJoinAlias('channelPricing');

View file

@ -13,7 +13,7 @@ declare(strict_types=1);
namespace Sylius\Bundle\ApiBundle\Filter\Doctrine;
use ApiPlatform\Core\Api\IriConverterInterface;
use ApiPlatform\Api\IriConverterInterface;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\AbstractContextAwareFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Util\QueryNameGeneratorInterface;
use Doctrine\ORM\QueryBuilder;
@ -51,7 +51,7 @@ final class ProductVariantOptionValueFilter extends AbstractContextAwareFilter
$value = (array) $value;
foreach ($value as $optionValueIri) {
$optionValue = $this->iriConverter->getItemFromIri($optionValueIri);
$optionValue = $this->iriConverter->getResourceFromIri($optionValueIri);
$parameterName = $queryNameGenerator->generateParameterName($property);
$rootAlias = $queryBuilder->getRootAliases()[0];

View file

@ -13,7 +13,7 @@ declare(strict_types=1);
namespace Sylius\Bundle\ApiBundle\Filter\Doctrine;
use ApiPlatform\Core\Api\IriConverterInterface;
use ApiPlatform\Api\IriConverterInterface;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\AbstractContextAwareFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Util\QueryNameGeneratorInterface;
use ApiPlatform\Core\Exception\InvalidArgumentException;
@ -48,7 +48,7 @@ final class TaxonFilter extends AbstractContextAwareFilter
try {
/** @var TaxonInterface $taxon */
$taxon = $this->iriConverter->getItemFromIri($value);
$taxon = $this->iriConverter->getResourceFromIri($value);
$taxonRoot = $taxon->getRoot();
} catch (InvalidArgumentException|ItemNotFoundException $argumentException) {
$taxonRoot = null;

View file

@ -28,14 +28,14 @@
<argument type="service" id="sylius.factory.avatar_image" />
<argument type="service" id="sylius.repository.avatar_image" />
<argument type="service" id="sylius.image_uploader" />
<argument type="service" id="api_platform.iri_converter" />
<argument type="service" id="api_platform.symfony.iri_converter" />
</service>
<service id="Sylius\Bundle\ApiBundle\Controller\GetProductBySlugAction" public="true">
<argument type="service" id="sylius.context.channel" />
<argument type="service" id="sylius.context.locale" />
<argument type="service" id="sylius.repository.product" />
<argument type="service" id="api_platform.iri_converter" />
<argument type="service" id="api_platform.symfony.iri_converter" />
<argument type="service" id="request_stack" />
</service>
@ -122,7 +122,7 @@
</service>
<service id="sylius.listener.api_authentication_success_listener" class="Sylius\Bundle\ApiBundle\EventListener\AuthenticationSuccessListener">
<argument type="service" id="api_platform.iri_converter" />
<argument type="service" id="api_platform.symfony.iri_converter" />
<tag name="kernel.event_listener" event="lexik_jwt_authentication.on_authentication_success" method="onAuthenticationSuccessResponse" />
</service>
@ -173,7 +173,7 @@
</service>
<service id="sylius.listener.admin_api_authentication_success_listener" class="Sylius\Bundle\ApiBundle\EventListener\AdminAuthenticationSuccessListener">
<argument type="service" id="api_platform.iri_converter" />
<argument type="service" id="api_platform.symfony.iri_converter" />
<tag name="kernel.event_listener" event="lexik_jwt_authentication.on_authentication_success" method="onAuthenticationSuccessResponse" />
</service>

View file

@ -42,7 +42,7 @@
<service id="Sylius\Bundle\ApiBundle\Filter\Doctrine\TaxonFilter" public="true">
<argument type="service" id="doctrine" />
<argument type="service" id="api_platform.iri_converter" />
<argument type="service" id="api_platform.symfony.iri_converter" />
<tag name="api_platform.filter" />
</service>
@ -119,13 +119,13 @@
</service>
<service id="Sylius\Bundle\ApiBundle\Filter\Doctrine\ProductVariantOptionValueFilter" public="true">
<argument type="service" id="api_platform.iri_converter" />
<argument type="service" id="api_platform.symfony.iri_converter" />
<argument type="service" id="doctrine" />
<tag name="api_platform.filter" />
</service>
<service id="Sylius\Bundle\ApiBundle\Filter\Doctrine\ProductVariantCatalogPromotionFilter" public="true">
<argument type="service" id="api_platform.iri_converter" />
<argument type="service" id="api_platform.symfony.iri_converter" />
<argument type="service" id="doctrine" />
<tag name="api_platform.filter" />
</service>
@ -184,7 +184,7 @@
</service>
<service id="Sylius\Bundle\ApiBundle\Filter\Doctrine\CatalogPromotionChannelFilter" public="true">
<argument type="service" id="api_platform.iri_converter" />
<argument type="service" id="api_platform.symfony.iri_converter" />
<argument type="service" id="doctrine" />
<tag name="api_platform.filter" />
</service>

View file

@ -46,7 +46,7 @@
<service id="Sylius\Bundle\ApiBundle\Serializer\ProductNormalizer">
<argument type="service" id="Sylius\Component\Product\Resolver\ProductVariantResolverInterface" />
<argument type="service" id="api_platform.iri_converter" />
<argument type="service" id="api_platform.symfony.iri_converter" />
<tag name="serializer.normalizer" priority="64" />
</service>
@ -72,7 +72,7 @@
<argument type="service" id="sylius.calculator.product_variant_price" />
<argument type="service" id="sylius.availability_checker" />
<argument type="service" id="sylius.section_resolver.uri_based_section_resolver" />
<argument type="service" id="api_platform.iri_converter" />
<argument type="service" id="api_platform.symfony.iri_converter" />
<tag name="serializer.normalizer" priority="64" />
</service>
@ -92,7 +92,7 @@
</service>
<service id="Sylius\Bundle\ApiBundle\Serializer\ZoneDenormalizer">
<argument type="service" id="api_platform.iri_converter" />
<argument type="service" id="api_platform.symfony.iri_converter" />
<tag name="serializer.normalizer" priority="64" />
</service>
@ -104,7 +104,7 @@
</service>
<service id="Sylius\Bundle\ApiBundle\Serializer\ChannelPriceHistoryConfigDenormalizer">
<argument type="service" id="api_platform.iri_converter" />
<argument type="service" id="api_platform.symfony.iri_converter" />
<argument type="service" id="sylius.factory.channel_price_history_config" />
<argument type="service" id="Sylius\Bundle\ApiBundle\Validator\ResourceInputDataPropertiesValidatorInterface" />
<argument>%sylius.form.type.channel_price_history_config.validation_groups%</argument>

View file

@ -13,7 +13,7 @@ declare(strict_types=1);
namespace Sylius\Bundle\ApiBundle\Serializer;
use ApiPlatform\Core\Api\IriConverterInterface;
use ApiPlatform\Api\IriConverterInterface;
use Sylius\Bundle\ApiBundle\Validator\ResourceInputDataPropertiesValidatorInterface;
use Sylius\Component\Core\Model\ChannelPriceHistoryConfigInterface;
use Sylius\Component\Core\Model\TaxonInterface;
@ -60,7 +60,7 @@ final class ChannelPriceHistoryConfigDenormalizer implements ContextAwareDenorma
foreach ($data['taxonsExcludedFromShowingLowestPrice'] ?? [] as $excludedTaxonIri) {
/** @var TaxonInterface $taxon */
$taxon = $this->iriConverter->getItemFromIri($excludedTaxonIri);
$taxon = $this->iriConverter->getResourceFromIri($excludedTaxonIri);
$channelPriceHistoryConfig->addTaxonExcludedFromShowingLowestPrice($taxon);
}

View file

@ -13,7 +13,7 @@ declare(strict_types=1);
namespace Sylius\Bundle\ApiBundle\Serializer;
use ApiPlatform\Core\Api\IriConverterInterface;
use ApiPlatform\Api\IriConverterInterface;
use Sylius\Component\Core\Model\ProductInterface;
use Sylius\Component\Product\Model\ProductVariantInterface;
use Sylius\Component\Product\Resolver\ProductVariantResolverInterface;
@ -46,12 +46,12 @@ final class ProductNormalizer implements ContextAwareNormalizerInterface, Normal
$data['variants'] = $object
->getEnabledVariants()
->map(fn (ProductVariantInterface $variant): string => $this->iriConverter->getIriFromItem($variant))
->map(fn (ProductVariantInterface $variant): string => $this->iriConverter->getIriFromResource($variant))
->getValues()
;
$defaultVariant = $this->defaultProductVariantResolver->getVariant($object);
$data['defaultVariant'] = $defaultVariant === null ? null : $this->iriConverter->getIriFromItem($defaultVariant);
$data['defaultVariant'] = $defaultVariant === null ? null : $this->iriConverter->getIriFromResource($defaultVariant);
return $data;
}

View file

@ -13,7 +13,7 @@ declare(strict_types=1);
namespace Sylius\Bundle\ApiBundle\Serializer;
use ApiPlatform\Core\Api\IriConverterInterface;
use ApiPlatform\Api\IriConverterInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Sylius\Bundle\ApiBundle\SectionResolver\AdminApiSection;
use Sylius\Bundle\CoreBundle\SectionResolver\SectionProviderInterface;
@ -74,7 +74,7 @@ final class ProductVariantNormalizer implements ContextAwareNormalizerInterface,
$appliedPromotions = $object->getAppliedPromotionsForChannel($channel);
if (!$appliedPromotions->isEmpty()) {
$data['appliedPromotions'] = array_map(
fn (CatalogPromotionInterface $catalogPromotion) => $this->iriConverter->getIriFromItem($catalogPromotion),
fn (CatalogPromotionInterface $catalogPromotion) => $this->iriConverter->getIriFromResource($catalogPromotion),
$appliedPromotions->toArray(),
);
}

View file

@ -13,7 +13,7 @@ declare(strict_types=1);
namespace Sylius\Bundle\ApiBundle\Serializer;
use ApiPlatform\Core\Api\IriConverterInterface;
use ApiPlatform\Api\IriConverterInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Criteria;
use Doctrine\Common\Collections\Selectable;
@ -67,7 +67,7 @@ final class ZoneDenormalizer implements ContextAwareDenormalizerInterface, Denor
if (isset($member['code']) && in_array($member['code'], $membersCodes)) {
unset($data['members'][$key]);
$data['members'][$key] = $this->iriConverter->getIriFromItem(
$data['members'][$key] = $this->iriConverter->getIriFromResource(
$this->getZoneMemberByCode($members, $member['code']),
);
}

View file

@ -13,7 +13,7 @@ declare(strict_types=1);
namespace spec\Sylius\Bundle\ApiBundle\EventListener;
use ApiPlatform\Core\Api\IriConverterInterface;
use ApiPlatform\Api\IriConverterInterface;
use Lexik\Bundle\JWTAuthenticationBundle\Event\AuthenticationSuccessEvent;
use PhpSpec\ObjectBehavior;
use Sylius\Component\Core\Model\AdminUserInterface;
@ -32,7 +32,7 @@ final class AdminAuthenticationSuccessListenerSpec extends ObjectBehavior
AdminUserInterface $adminUser,
): void {
$event = new AuthenticationSuccessEvent([], $adminUser->getWrappedObject(), new Response());
$iriConverter->getIriFromItem($adminUser->getWrappedObject())->shouldBeCalled();
$iriConverter->getIriFromResource($adminUser->getWrappedObject())->shouldBeCalled();
$this->onAuthenticationSuccessResponse($event);
}
@ -44,7 +44,7 @@ final class AdminAuthenticationSuccessListenerSpec extends ObjectBehavior
): void {
$event = new AuthenticationSuccessEvent([], $shopUser->getWrappedObject(), new Response());
$iriConverter->getIriFromItem($adminUser->getWrappedObject())->shouldNotBeCalled();
$iriConverter->getIriFromResource($adminUser->getWrappedObject())->shouldNotBeCalled();
$this->onAuthenticationSuccessResponse($event);
}

View file

@ -13,7 +13,7 @@ declare(strict_types=1);
namespace spec\Sylius\Bundle\ApiBundle\EventListener;
use ApiPlatform\Core\Api\IriConverterInterface;
use ApiPlatform\Api\IriConverterInterface;
use Lexik\Bundle\JWTAuthenticationBundle\Event\AuthenticationSuccessEvent;
use PhpSpec\ObjectBehavior;
use Sylius\Component\Core\Model\AdminUserInterface;
@ -37,7 +37,7 @@ final class AuthenticationSuccessListenerSpec extends ObjectBehavior
$shopUser->getCustomer()->willReturn($customer->getWrappedObject());
$iriConverter->getIriFromItem($customer->getWrappedObject())->shouldBeCalled();
$iriConverter->getIriFromResource($customer->getWrappedObject())->shouldBeCalled();
$this->onAuthenticationSuccessResponse($event);
}
@ -49,7 +49,7 @@ final class AuthenticationSuccessListenerSpec extends ObjectBehavior
): void {
$event = new AuthenticationSuccessEvent([], $adminUser->getWrappedObject(), new Response());
$iriConverter->getIriFromItem($customer->getWrappedObject())->shouldNotBeCalled();
$iriConverter->getIriFromResource($customer->getWrappedObject())->shouldNotBeCalled();
$this->onAuthenticationSuccessResponse($event);
}

View file

@ -13,7 +13,7 @@ declare(strict_types=1);
namespace spec\Sylius\Bundle\ApiBundle\Filter\Doctrine;
use ApiPlatform\Core\Api\IriConverterInterface;
use ApiPlatform\Api\IriConverterInterface;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Util\QueryNameGeneratorInterface;
use ApiPlatform\Core\Exception\InvalidArgumentException;
use ApiPlatform\Core\Exception\ItemNotFoundException;
@ -36,7 +36,7 @@ final class TaxonFilterSpec extends ObjectBehavior
QueryBuilder $queryBuilder,
QueryNameGeneratorInterface $queryNameGenerator,
): void {
$iriConverter->getItemFromIri('api/taxon')->willReturn($taxon);
$iriConverter->getResourceFromIri('api/taxon')->willReturn($taxon);
$queryBuilder->getRootAliases()->willReturn(['o']);
$queryBuilder->distinct()->willReturn($queryBuilder);
@ -72,7 +72,7 @@ final class TaxonFilterSpec extends ObjectBehavior
QueryNameGeneratorInterface $queryNameGenerator,
): void {
$context['filters']['order'] = ['differentOrderParameter' => 'asc'];
$iriConverter->getItemFromIri('api/taxon')->willReturn($taxon);
$iriConverter->getResourceFromIri('api/taxon')->willReturn($taxon);
$queryBuilder->getRootAliases()->willReturn(['o']);
$queryBuilder->distinct()->willReturn($queryBuilder);
@ -103,7 +103,7 @@ final class TaxonFilterSpec extends ObjectBehavior
QueryBuilder $queryBuilder,
QueryNameGeneratorInterface $queryNameGenerator,
): void {
$iriConverter->getItemFromIri('api/taxon')->willThrow(ItemNotFoundException::class);
$iriConverter->getResourceFromIri('api/taxon')->willThrow(ItemNotFoundException::class);
$queryBuilder->getRootAliases()->willReturn(['o']);
$queryBuilder->distinct()->willReturn($queryBuilder);
@ -131,7 +131,7 @@ final class TaxonFilterSpec extends ObjectBehavior
QueryBuilder $queryBuilder,
QueryNameGeneratorInterface $queryNameGenerator,
): void {
$iriConverter->getItemFromIri('non-existing-taxon')->willThrow(InvalidArgumentException::class);
$iriConverter->getResourceFromIri('non-existing-taxon')->willThrow(InvalidArgumentException::class);
$queryBuilder->getRootAliases()->willReturn(['o']);
$queryBuilder->distinct()->willReturn($queryBuilder);

View file

@ -13,7 +13,7 @@ declare(strict_types=1);
namespace spec\Sylius\Bundle\ApiBundle\Serializer;
use ApiPlatform\Core\Api\IriConverterInterface;
use ApiPlatform\Api\IriConverterInterface;
use ApiPlatform\Symfony\Validator\Exception\ValidationException;
use Doctrine\Common\Collections\ArrayCollection;
use PhpSpec\ObjectBehavior;
@ -107,8 +107,8 @@ final class ChannelPriceHistoryConfigDenormalizerSpec extends ObjectBehavior
$config->clearTaxonsExcludedFromShowingLowestPrice()->shouldBeCalled();
$iriConverter->getItemFromIri('/api/v2/taxons/first-new-taxon')->shouldBeCalledTimes(1)->willReturn($firstTaxon);
$iriConverter->getItemFromIri('/api/v2/taxons/second-new-taxon')->shouldBeCalledTimes(1)->willReturn($secondTaxon);
$iriConverter->getResourceFromIri('/api/v2/taxons/first-new-taxon')->shouldBeCalledTimes(1)->willReturn($firstTaxon);
$iriConverter->getResourceFromIri('/api/v2/taxons/second-new-taxon')->shouldBeCalledTimes(1)->willReturn($secondTaxon);
$config->addTaxonExcludedFromShowingLowestPrice($firstTaxon)->shouldBeCalledTimes(1);
$config->addTaxonExcludedFromShowingLowestPrice($secondTaxon)->shouldBeCalledTimes(1);
@ -145,7 +145,7 @@ final class ChannelPriceHistoryConfigDenormalizerSpec extends ObjectBehavior
$config->clearTaxonsExcludedFromShowingLowestPrice()->shouldBeCalled();
$iriConverter->getItemFromIri(Argument::cetera())->shouldNotBeCalled();
$iriConverter->getResourceFromIri(Argument::cetera())->shouldNotBeCalled();
$config->addTaxonExcludedFromShowingLowestPrice(Argument::any())->shouldNotBeCalled();
@ -186,8 +186,8 @@ final class ChannelPriceHistoryConfigDenormalizerSpec extends ObjectBehavior
$config->clearTaxonsExcludedFromShowingLowestPrice()->shouldBeCalled();
$iriConverter->getItemFromIri('/api/v2/taxons/first-new-taxon')->shouldBeCalledTimes(1)->willReturn($firstNewTaxon);
$iriConverter->getItemFromIri('/api/v2/taxons/second-new-taxon')->shouldBeCalledTimes(1)->willReturn($secondNewTaxon);
$iriConverter->getResourceFromIri('/api/v2/taxons/first-new-taxon')->shouldBeCalledTimes(1)->willReturn($firstNewTaxon);
$iriConverter->getResourceFromIri('/api/v2/taxons/second-new-taxon')->shouldBeCalledTimes(1)->willReturn($secondNewTaxon);
$config->addTaxonExcludedFromShowingLowestPrice($firstNewTaxon)->shouldBeCalledTimes(1);
$config->addTaxonExcludedFromShowingLowestPrice($secondNewTaxon)->shouldBeCalledTimes(1);

View file

@ -13,7 +13,7 @@ declare(strict_types=1);
namespace spec\Sylius\Bundle\ApiBundle\Serializer;
use ApiPlatform\Core\Api\IriConverterInterface;
use ApiPlatform\Api\IriConverterInterface;
use Doctrine\Common\Collections\ArrayCollection;
use PhpSpec\ObjectBehavior;
use Sylius\Component\Core\Model\OrderInterface;
@ -80,7 +80,7 @@ final class ProductNormalizerSpec extends ObjectBehavior
$normalizer->normalize($product, null, ['sylius_product_normalizer_already_called' => true])->willReturn([]);
$product->getEnabledVariants()->willReturn(new ArrayCollection([$variant->getWrappedObject()]));
$defaultProductVariantResolver->getVariant($product)->willReturn($variant);
$iriConverter->getIriFromItem($variant)->willReturn('/api/v2/shop/product-variants/CODE');
$iriConverter->getIriFromResource($variant)->willReturn('/api/v2/shop/product-variants/CODE');
$this->normalize($product, null, [])->shouldReturn([
'variants' => ['/api/v2/shop/product-variants/CODE'],
@ -98,7 +98,7 @@ final class ProductNormalizerSpec extends ObjectBehavior
$this->setNormalizer($normalizer);
$normalizer->normalize($product, null, ['sylius_product_normalizer_already_called' => true])->willReturn([]);
$iriConverter->getIriFromItem($variant)->willReturn('/api/v2/shop/product-variants/CODE');
$iriConverter->getIriFromResource($variant)->willReturn('/api/v2/shop/product-variants/CODE');
$product->getEnabledVariants()->willReturn(new ArrayCollection([$variant->getWrappedObject()]));
$defaultProductVariantResolver->getVariant($product)->willReturn(null);

View file

@ -13,7 +13,7 @@ declare(strict_types=1);
namespace spec\Sylius\Bundle\ApiBundle\Serializer;
use ApiPlatform\Core\Api\IriConverterInterface;
use ApiPlatform\Api\IriConverterInterface;
use Doctrine\Common\Collections\ArrayCollection;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
@ -152,7 +152,7 @@ final class ProductVariantNormalizerSpec extends ObjectBehavior
$variant->getAppliedPromotionsForChannel($channel)->willReturn(new ArrayCollection([$catalogPromotion->getWrappedObject()]));
$availabilityChecker->isStockAvailable($variant)->willReturn(true);
$iriConverter->getIriFromItem($catalogPromotion)->willReturn('/api/v2/shop/catalog-promotions/winter_sale');
$iriConverter->getIriFromResource($catalogPromotion)->willReturn('/api/v2/shop/catalog-promotions/winter_sale');
$this
->normalize($variant, null, [ContextKeys::CHANNEL => $channel])

View file

@ -13,7 +13,7 @@ declare(strict_types=1);
namespace spec\Sylius\Bundle\ApiBundle\Serializer;
use ApiPlatform\Core\Api\IriConverterInterface;
use ApiPlatform\Api\IriConverterInterface;
use Doctrine\Common\Collections\ArrayCollection;
use PhpSpec\ObjectBehavior;
use Sylius\Bundle\ApiBundle\Serializer\ZoneDenormalizer;
@ -108,9 +108,9 @@ final class ZoneDenormalizerSpec extends ObjectBehavior
$franceZone->getWrappedObject(),
]));
$iriConverter->getIriFromItem($belgiumZone)->willReturn('iri/EU-BE');
$iriConverter->getIriFromItem($germanyZone)->willReturn('iri/EU-DE');
$iriConverter->getIriFromItem($franceZone)->willReturn('iri/EU-FR');
$iriConverter->getIriFromResource($belgiumZone)->willReturn('iri/EU-BE');
$iriConverter->getIriFromResource($germanyZone)->willReturn('iri/EU-DE');
$iriConverter->getIriFromResource($franceZone)->willReturn('iri/EU-FR');
$denormalizer->denormalize(
[
@ -163,9 +163,9 @@ final class ZoneDenormalizerSpec extends ObjectBehavior
$franceZone->getWrappedObject(),
]));
$iriConverter->getIriFromItem($belgiumZone)->shouldNotBeCalled();
$iriConverter->getIriFromItem($germanyZone)->shouldNotBeCalled();
$iriConverter->getIriFromItem($franceZone)->shouldNotBeCalled();
$iriConverter->getIriFromResource($belgiumZone)->shouldNotBeCalled();
$iriConverter->getIriFromResource($germanyZone)->shouldNotBeCalled();
$iriConverter->getIriFromResource($franceZone)->shouldNotBeCalled();
$denormalizer->denormalize(
[],