Skip to content

Commit

Permalink
made change without BC break
Browse files Browse the repository at this point in the history
  • Loading branch information
David Stritezsky committed Jul 2, 2020
1 parent c5af5e6 commit a667556
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
20 changes: 18 additions & 2 deletions packages/framework/src/Model/Product/ProductDataFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Shopsys\FrameworkBundle\Model\Product;

use BadMethodCallException;
use Shopsys\FrameworkBundle\Component\Domain\Domain;
use Shopsys\FrameworkBundle\Component\Image\ImageFacade;
use Shopsys\FrameworkBundle\Component\Plugin\PluginCrudExtensionFacade;
Expand Down Expand Up @@ -95,7 +96,7 @@ class ProductDataFactory implements ProductDataFactoryInterface
* @param \Shopsys\FrameworkBundle\Component\Plugin\PluginCrudExtensionFacade $pluginDataFormExtensionFacade
* @param \Shopsys\FrameworkBundle\Model\Product\Parameter\ProductParameterValueDataFactoryInterface $productParameterValueDataFactory
* @param \Shopsys\FrameworkBundle\Model\Pricing\Group\PricingGroupFacade $pricingGroupFacade
* @param \Shopsys\FrameworkBundle\Model\Product\Availability\AvailabilityFacade $availabilityFacade
* @param \Shopsys\FrameworkBundle\Model\Product\Availability\AvailabilityFacade|null $availabilityFacade
*/
public function __construct(
VatFacade $vatFacade,
Expand All @@ -110,7 +111,7 @@ public function __construct(
PluginCrudExtensionFacade $pluginDataFormExtensionFacade,
ProductParameterValueDataFactoryInterface $productParameterValueDataFactory,
PricingGroupFacade $pricingGroupFacade,
AvailabilityFacade $availabilityFacade
?AvailabilityFacade $availabilityFacade = null
) {
$this->vatFacade = $vatFacade;
$this->productInputPriceFacade = $productInputPriceFacade;
Expand All @@ -127,6 +128,21 @@ public function __construct(
$this->availabilityFacade = $availabilityFacade;
}

/**
* @required
* @internal This function will be replaced by constructor injection in next major
* @param \Shopsys\FrameworkBundle\Model\Product\Availability\AvailabilityFacade $availabilityFacade
*/
public function setAvailabilityFacade(AvailabilityFacade $availabilityFacade) {
if ($this->availabilityFacade !== null && $this->availabilityFacade !== $availabilityFacade) {
throw new BadMethodCallException(sprintf('Method "%s" has been already called and cannot be called multiple times.', __METHOD__));
}
if ($this->availabilityFacade === null) {
@trigger_error(sprintf('The %s() method is deprecated and will be removed in the next major. Use the constructor injection instead.', __METHOD__), E_USER_DEPRECATED);
$this->availabilityFacade = $availabilityFacade;
}
}

/**
* @return \Shopsys\FrameworkBundle\Model\Product\ProductData
*/
Expand Down
23 changes: 23 additions & 0 deletions upgrade/UPGRADE-v9.0.1-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,26 @@ There you can find links to upgrade notes for other versions too.

- fix wrong translations in CartCest ([#1582](https://github.com/shopsys/shopsys/pull/1582))
- see #project-base-diff to update your project

- set default availability for ProductData ([#1723](https://github.com/shopsys/shopsys/pull/1723))
- following constructor changed its interface:
- `ProductDataFactory::__construct()`

```diff
public function __construct(
VatFacade $vatFacade,
ProductInputPriceFacade $productInputPriceFacade,
UnitFacade $unitFacade,
Domain $domain,
ProductRepository $productRepository,
ParameterRepository $parameterRepository,
FriendlyUrlFacade $friendlyUrlFacade,
ProductAccessoryRepository $productAccessoryRepository,
ImageFacade $imageFacade,
PluginCrudExtensionFacade $pluginDataFormExtensionFacade,
ProductParameterValueDataFactoryInterface $productParameterValueDataFactory,
- PricingGroupFacade $pricingGroupFacade
+ PricingGroupFacade $pricingGroupFacade,
+ ?AvailabilityFacade $availabilityFacade = null
) {
```

0 comments on commit a667556

Please sign in to comment.