Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIXTURES] Use shopbillDataFactory in ChannelExampleFactory #12027

Merged
merged 2 commits into from
Nov 13, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
use Sylius\Component\Core\Formatter\StringInflector;
use Sylius\Component\Core\Model\ChannelInterface;
use Sylius\Component\Core\Model\Scope;
use Sylius\Component\Core\Model\ShopBillingData;
use Sylius\Component\Core\Model\TaxonInterface;
use Sylius\Component\Currency\Model\CurrencyInterface;
use Sylius\Component\Locale\Model\LocaleInterface;
use Sylius\Component\Resource\Factory\FactoryInterface;
use Sylius\Component\Resource\Repository\RepositoryInterface;
use Sylius\Component\Taxonomy\Repository\TaxonRepositoryInterface;
use Symfony\Component\OptionsResolver\Options;
Expand Down Expand Up @@ -52,12 +52,16 @@ class ChannelExampleFactory extends AbstractExampleFactory implements ExampleFac
/** @var TaxonRepositoryInterface|null */
private $taxonRepository;

/** @var FactoryInterface|null */
private $shopBillingDataFactory;

public function __construct(
ChannelFactoryInterface $channelFactory,
RepositoryInterface $localeRepository,
RepositoryInterface $currencyRepository,
RepositoryInterface $zoneRepository,
?TaxonRepositoryInterface $taxonRepository = null
?TaxonRepositoryInterface $taxonRepository = null,
?FactoryInterface $shopBillingDataFactory = null
) {
if (null === $taxonRepository) {
@trigger_error('Passing RouterInterface as the fourth argument is deprecated since 1.8 and will be prohibited in 2.0', \E_USER_DEPRECATED);
Expand All @@ -68,6 +72,7 @@ public function __construct(
$this->currencyRepository = $currencyRepository;
$this->zoneRepository = $zoneRepository;
$this->taxonRepository = $taxonRepository;
$this->shopBillingDataFactory = $shopBillingDataFactory;
lukomwro marked this conversation as resolved.
Show resolved Hide resolved

$this->faker = \Faker\Factory::create();
$this->optionsResolver = new OptionsResolver();
Expand Down Expand Up @@ -108,8 +113,8 @@ public function create(array $options = []): ChannelInterface
$channel->addCurrency($currency);
}

if (isset($options['shop_billing_data']) && null !== $options['shop_billing_data']) {
$shopBillingData = new ShopBillingData();
if (isset($options['shop_billing_data']) && null !== $options['shop_billing_data'] && null !== $this->shopBillingDataFactory) {
lukomwro marked this conversation as resolved.
Show resolved Hide resolved
$shopBillingData = $this->shopBillingDataFactory->createNew();
lukomwro marked this conversation as resolved.
Show resolved Hide resolved
$shopBillingData->setCompany($options['shop_billing_data']['company'] ?? null);
$shopBillingData->setTaxId($options['shop_billing_data']['tax_id'] ?? null);
$shopBillingData->setCountryCode($options['shop_billing_data']['country_code'] ?? null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<argument type="service" id="sylius.repository.currency" />
<argument type="service" id="sylius.repository.zone" />
<argument type="service" id="sylius.repository.taxon" />
<argument type="service" id="sylius.factory.shop_billing_data" />
</service>

<service id="sylius.fixture.example_factory.customer_group" class="Sylius\Bundle\CoreBundle\Fixture\Factory\CustomerGroupExampleFactory">
Expand Down