Skip to content

Commit

Permalink
Remove deprecated method
Browse files Browse the repository at this point in the history
  • Loading branch information
GSadee committed Nov 15, 2024
1 parent c8f0861 commit 28a839d
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 186 deletions.
176 changes: 4 additions & 172 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,177 +1,9 @@
### UPGRADE FROM 0.25.X TO 1.0.0
### UPGRADE FROM 0.25 TO 1.0

1. Support for Sylius 1.14 has been added, it is now the recommended Sylius version to use with InvoicingPlugin.

1. Support for Sylius 1.12 has been dropped, upgrade your application to [Sylius 1.13](https://github.com/Sylius/Sylius/blob/1.13/UPGRADE-1.13.md).
or [Sylius 1.14](https://github.com/Sylius/Sylius/blob/1.14/UPGRADE-1.14.md).

### UPGRADE FROM 0.24.X TO 0.25.0

1. Support for Sylius 1.13 has been added, it is now the recommended Sylius version to use with InvoicingPlugin.
2. Support for Sylius 1.11 has been dropped, upgrade your application to [Sylius 1.12](https://github.com/Sylius/Sylius/blob/master/UPGRADE-1.12.md).
or to [Sylius 1.13](https://github.com/Sylius/Sylius/blob/master/UPGRADE-1.13.md).
3. Support for PHP 8.0 has been dropped.

### UPGRADE FROM 0.23.1 TO 0.24.0

1. Support for Sylius 1.12 has been added, it is now the recommended Sylius version to use with InvoicingPlugin.
2. Support for Sylius 1.10 has been dropped, upgrade your application to [Sylius 1.11](https://github.com/Sylius/Sylius/blob/master/UPGRADE-1.11.md).
or to [Sylius 1.12](https://github.com/Sylius/Sylius/blob/master/UPGRADE-1.12.md).
3. Support for Symfony 6 has been added.
4. Support for Symfony 4.4 has been dropped.

### UPGRADE FROM 0.21.0 TO 0.22.0

1. `Sylius\InvoicingPlugin\Generator\InvoicePdfFileGenerator` takes `Sylius\InvoicingPlugin\Generator\TwigToPdfGeneratorInterface` as the first argument in place of `Twig\Environment`, `Knp\Snappy\GeneratorInterface` and `Sylius\InvoicingPlugin\Generator\PdfOptionsGeneratorInterface`.
2. `Sylius\InvoicingPlugin\Creator\InvoiceCreator` takes `%sylius_invoicing.pdf_generator.enabled%` as the sixth argument.
3. `Sylius\InvoicingPlugin\Ui\Action\DownloadInvoiceAction` takes `%sylius_invoicing.pdf_generator.enabled%` as the fourth argument.
4. `Sylius\InvoicingPlugin\Email\InvoiceEmailSender` takes `%sylius_invoicing.pdf_generator.enabled%` as the third argument.

### UPGRADE FROM 0.20.0 TO 0.21.0

1. `Sylius\InvoicingPlugin\Generator\InvoicePdfFileGenerator` takes `Sylius\InvoicingPlugin\Generator\PdfOptionsGeneratorInterface` as the third argument after `Knp\Snappy\GeneratorInterface`.

### UPGRADE FROM 0.19.0 TO 0.20.0

1. Since 0.20.0, the recommended Sylius version to use with InvoicingPlugin is `1.11.*`. If you would like to upgrade Sylius to v1.11.0,
please follow [Sylius's upgrade instructions](https://github.com/Sylius/Sylius/blob/master/UPGRADE-1.11.md)
and [Sylius API's upgrade instructions](https://github.com/Sylius/Sylius/blob/master/UPGRADE-API-1.11.md).

### UPGRADE FROM 0.18.0 TO 0.19.0

1. Support for Sylius 1.9 has been dropped, upgrade your application to [Sylius 1.10](https://github.com/Sylius/Sylius/blob/master/UPGRADE-1.10.md).
2. Support for Symfony 5.2 and 5.3 has been dropped.
3. Default channel color feature was removed in favour of `sylius/sylius` standard solution.
Override `src/Sylius/Bundle/AdminBundle/Resources/views/Common/_channel.html.twig` if custom default color is neccesasary.
- Class `Sylius\InvoicingPlugin\Provider\ChannelColorProvider` was removed.
- Interface `Sylius\InvoicingPlugin\Provider\ChannelColorProviderInterface` was removed.
- Class `Sylius\InvoicingPlugin\Twig\ChannelColorExtension` and twig filter `sylius_channel_color` were removed.
- Parameter `default_channel_color` was removed

### UPGRADE FROM 0.17.0 TO 0.18.0

1. The `Sylius\InvoicingPlugin\Converter\BillingDataConverter` has been removed in favor of `Sylius\InvoicingPlugin\Factory\BillingDataFactory->createFromAddress`.
2. The `Sylius\InvoicingPlugin\Converter\InvoiceShopBillingDataConverter` has been removed in favor of `Sylius\InvoicingPlugin\Factory\InvoiceShopBillingDataFactory->createFromChannel`.

Now on invoice admin and shop user can check if related order was paid before invoice generated.

1. `src/Entity/Invoice.php` model has new field (`paymentState`), and updated constructor arguments:

```dif
public function __construct(
string $id,
string $number,
OrderInterface $order,
\DateTimeInterface $issuedAt,
BillingDataInterface $billingData,
string $currencyCode,
string $localeCode,
int $total,
Collection $lineItems,
Collection $taxItems,
ChannelInterface $channel,
+ string $paymentState,
InvoiceShopBillingDataInterface $shopBillingData
) {
$this->id = $id;
$this->number = $number;
$this->order = $order;
$this->issuedAt = clone $issuedAt;
$this->billingData = $billingData;
$this->currencyCode = $currencyCode;
$this->localeCode = $localeCode;
$this->total = $total;
$this->lineItems = $lineItems;
$this->taxItems = $taxItems;
$this->channel = $channel;
+ $this->paymentState = $paymentState;
$this->shopBillingData = $shopBillingData;
```

2. New field on `src/Entity/Invoice.php` implies a database update

3. Method `createForData` from `src/Factory/InvoiceFactory.php` service was updated:

```dif
public function createForData(
string $id,
string $number,
OrderInterface $order,
\DateTimeInterface $issuedAt,
BillingDataInterface $billingData,
string $currencyCode,
string $localeCode,
int $total,
Collection $lineItems,
Collection $taxItems,
ChannelInterface $channel,
+ string $paymentState,
InvoiceShopBillingDataInterface $shopBillingData = null
): InvoiceInterface {
// ...
}
```
### UPGRADE FROM 0.16.1 TO 0.17.0
Invoices are now saved on the server during their generation (by default, when the order is paid).
1. `Sylius\InvoicingPlugin\Creator\InvoiceCreator` class has 2 more dependencies: `InvoicePdfFileGeneratorInterface $invoicePdfFileGenerator`
and `InvoiceFileManagerInterface $invoiceFileManager`
2. `Sylius\InvoicingPlugin\Email\InvoiceEmailSender` class 2nd dependency has been changed from `InvoicePdfFileGeneratorInterface $invoicePdfFileGenerator`
to `InvoiceFileProviderInterface $invoiceFileProvider`
3. `Sylius\InvoicingPlugin\Generator\InvoicePdfFileGenerator` class has additional `InvoiceFileNameGeneratorInterface $invoiceFileNameGenerator`
dependency, placed on 4th place, before `string $template`
4. `Sylius\InvoicingPlugin\Ui\Action\DownloadInvoiceAction` class 4th dependency has been changed from `InvoicePdfFileGeneratorInterface $invoicePdfFileGenerator`
to `InvoiceFileProviderInterface $invoiceFilePathProvider`
5. `Sylius\InvoicingPlugin\Converter\LineItemsConverter` class has additional `TaxRatePercentageProviderInterface $taxRatePercentageProvider`
dependency
6. `Sylius\InvoicingPlugin\Provider\TaxRateProvider` service has been changed to `Sylius\InvoicingPlugin\Provider\TaxRatePercentageProvider`
and its service definition from `sylius_invoicing_plugin.provider.tax_rate` to `sylius_invoicing_plugin.provider.tax_rate_percentage`
7. `Sylius\InvoicingPlugin\Converter\LineItemsConverter` service has been replaced by `Sylius\InvoicingPlugin\Converter\OrderItemUnitsToLineItemsConverter`
and `Sylius\InvoicingPlugin\Converter\ShippingAdjustmentsToLineItemsConverter`
8. `Sylius\InvoicingPlugin\Generator\InvoiceGenerator` class has 2 more dependencies: `LineItemsConverterInterface $orderItemUnitsToLineItemsConverter`
and `LineItemsConverterInterface $shippingAdjustmentsToLineItemsConverter` that replaced `LineItemsConverterInterface $lineItemsConverter`
9. The return type of `Sylius\InvoicingPlugin\Converter\LineItemsConverterInterface:convert` method has been changed
from `Collection` to `array`
10. `Sylius\InvoicingPlugin\Filesystem\TemporaryFilesystem` class has been removed
### UPGRADE FROM 0.15.0 TO 0.16.0
1. `orderNumber` field on `Sylius\InvoicingPlugin\Entity\Invoice` has been removed and replaced with relation to `Order` entity.
2. `Sylius\InvoicingPlugin\Entity\InvoiceInterface::orderNumber` function is left due to easier and smoother upgrades,
but is also deprecated and will be removed in the `v1.0.0` release. Use `Sylius\InvoicingPlugin\Entity\InvoiceInterface::order` instead.
3. `Sylius\InvoicingPlugin\Doctrine\ORM\InvoiceRepositoryInterface::findOneByOrderNumber` method has been replaced by
`Sylius\InvoicingPlugin\Doctrine\ORM\InvoiceRepositoryInterface::findOneByOrder`.
4. `Sylius\InvoicingPlugin\Factory\InvoiceFactoryInterface::createForData` takes `OrderInterface $order` as the 3rd argument instead
of `string $orderNumber`.
### UPGRADE FROM 0.14.0 TO 0.15.0
1. Command bus `sylius_invoicing_plugin.command_bus` has been replaced with `sylius.command_bus`.
2. Event bus `sylius_invoicing_plugin.event_bus` has been replaced with `sylius.event_bus`.
3. Support for Sylius 1.8 has been dropped, upgrade your application to [Sylius 1.9](https://github.com/Sylius/Sylius/blob/master/UPGRADE-1.9.md)
or [Sylius 1.10](https://github.com/Sylius/Sylius/blob/master/UPGRADE-1.10.md).
### UPGRADE FROM 0.11.0 TO 0.12.0
1. The custom repository has been removed:
- the repository class `Sylius\InvoicingPlugin\Repository\DoctrineInvoiceRepository` has been removed
and replaced by `Sylius\InvoicingPlugin\Doctrine\ORM\InvoiceRepository`.
- the related service `sylius_invoicing_plugin.custom_repository.invoice` has been removed,
use `sylius_invoicing_plugin.repository.invoice` instead
- the related interface `Sylius\InvoicingPlugin\Repository\InvoiceRepository` has been removed,
use `Sylius\InvoicingPlugin\Doctrine\ORM\InvoiceRepositoryInterface` instead.
### UPGRADE FROM 0.10.X TO 0.11.0
1. Upgrade your application to [Sylius 1.8](https://github.com/Sylius/Sylius/blob/master/UPGRADE-1.8.md).
2. Remove previously copied migration files (You may check migrations to remove [here](https://github.com/Sylius/InvoicingPlugin/pull/184)).
### UPGRADE FROM 0.9 TO 0.10.0
1. Removed `InvoicingChannel` and replaced by `Sylius\Component\Core\Model\ChannelInterface`.
2. Replaced `InvoiceShopBillingData` value object by entity with `InvoiceShopBillingDataInterface` interface.
1. The deprecated method `Sylius\InvoicingPlugin\Entity\InvoiceInterface::orderNumber()` has been removed,
use `Sylius\InvoicingPlugin\Entity\InvoiceInterface::order()` instead.
9 changes: 5 additions & 4 deletions spec/Security/Voter/InvoiceVoterSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,12 @@ function it_does_not_allow_accessing_an_invoice_if_user_has_not_placed_the_order
InvoiceInterface $invoice,
ShopUserInterface $shopUser,
CustomerInterface $customer,
OrderInterface $order,
): void {
$invoice->orderNumber()->willReturn('1337');
$invoice->order()->willReturn($order);
$order->getNumber()->willReturn('1337');

$token->getUser()->willReturn($shopUser);

$shopUser->getCustomer()->willReturn($customer);

$orderRepository->findOneByNumberAndCustomer('1337', $customer)->willReturn(null);
Expand All @@ -87,10 +88,10 @@ function it_allows_accessing_an_invoice_if_user_has_placed_the_order_related_to_
CustomerInterface $customer,
OrderInterface $order,
): void {
$invoice->orderNumber()->willReturn('1337');
$invoice->order()->willReturn($order);
$order->getNumber()->willReturn('1337');

$token->getUser()->willReturn($shopUser);

$shopUser->getCustomer()->willReturn($customer);

$orderRepository->findOneByNumberAndCustomer('1337', $customer)->willReturn($order);
Expand Down
5 changes: 0 additions & 5 deletions src/Entity/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,6 @@ public function order(): OrderInterface
return $this->order;
}

public function orderNumber(): string
{
return (string) $this->order->getNumber();
}

public function issuedAt(): \DateTimeInterface
{
return clone $this->issuedAt;
Expand Down
3 changes: 0 additions & 3 deletions src/Entity/InvoiceInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ public function number(): string;

public function order(): OrderInterface;

/** @deprecated this method is deprecated an will be remove in v1.0 - use InvoiceInterface::order() instead */
public function orderNumber(): string;

public function issuedAt(): \DateTimeInterface;

public function billingData(): BillingDataInterface;
Expand Down
2 changes: 1 addition & 1 deletion src/Security/Voter/InvoiceVoter.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private function canAccess(UserInterface $user, InvoiceInterface $invoice): bool

Assert::isInstanceOf($customer, CustomerInterface::class);

return null !== $this->orderRepository->findOneByNumberAndCustomer($invoice->orderNumber(), $customer);
return null !== $this->orderRepository->findOneByNumberAndCustomer($invoice->order()->getNumber(), $customer);
}

return false;
Expand Down
2 changes: 1 addition & 1 deletion src/Ui/Action/Admin/ResendInvoiceAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function __invoke(string $id): Response
Assert::notNull($invoice);

/** @var OrderInterface|null $order */
$order = $this->orderRepository->findOneBy(['number' => $invoice->orderNumber()]);
$order = $this->orderRepository->findOneBy(['number' => $invoice->order()->getNumber()]);
Assert::notNull($order);

/** @var CustomerInterface|null $customer */
Expand Down

0 comments on commit 28a839d

Please sign in to comment.