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

fix(dependencies): foundry compatibility above 1.38 #7

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@
# Symfony CLI https://symfony.com/doc/current/setup/symfony_server.html#different-php-settings-per-project
/.php-version
/php.ini

# Local web server files
supervisord.log

2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"php": "^8.0",
"doctrine/doctrine-fixtures-bundle": "^3.4",
"sylius/core-bundle": "^1.12",
"zenstruck/foundry": "^1.31"
"zenstruck/foundry": "^1.38"
},
"require-dev": {
"behat/behat": "^3.6.1",
Expand Down
6 changes: 3 additions & 3 deletions src/Foundry/Configurator/FactoryConfigurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use Akawakaweb\SyliusFixturesPlugin\Foundry\Factory\FactoryWithModelClassAwareInterface;
use Sylius\Component\Resource\Metadata\MetadataInterface;
use Sylius\Component\Resource\Metadata\RegistryInterface;
use Zenstruck\Foundry\ModelFactory;
use Zenstruck\Foundry\Persistence\PersistentProxyObjectFactory;

final class FactoryConfigurator
{
Expand All @@ -29,12 +29,12 @@ public function __construct(RegistryInterface $registry)

public function configure(FactoryWithModelClassAwareInterface $factory): void
{
if (!$factory instanceof ModelFactory) {
if (!$factory instanceof PersistentProxyObjectFactory) {
return;
}

/** @var class-string|null $modelClass */
$modelClass = $this->getModelClass($factory::getEntityClass());
$modelClass = $this->getModelClass($factory::class());

if (null === $modelClass) {
return;
Expand Down
2 changes: 1 addition & 1 deletion src/Foundry/DefaultValues/ChannelDefaultValues.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use Sylius\Component\Currency\Model\CurrencyInterface;
use Sylius\Component\Locale\Model\LocaleInterface;
use function Zenstruck\Foundry\lazy;
use Zenstruck\Foundry\Proxy;
use Zenstruck\Foundry\Persistence\Proxy;

final class ChannelDefaultValues implements DefaultValuesInterface
{
Expand Down
10 changes: 5 additions & 5 deletions src/Foundry/Factory/AbstractModelFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
use Akawakaweb\SyliusFixturesPlugin\Foundry\DefaultValues\DefaultValuesInterface;
use Akawakaweb\SyliusFixturesPlugin\Foundry\Initiator\InitiatorInterface;
use Akawakaweb\SyliusFixturesPlugin\Foundry\Transformer\TransformerInterface;
use Zenstruck\Foundry\ModelFactory;
use Zenstruck\Foundry\Persistence\PersistentProxyObjectFactory;

/**
* @template TModel of object
*
* @template-extends ModelFactory<TModel>
* @template-extends PersistentProxyObjectFactory<TModel>
*/
abstract class AbstractModelFactory extends ModelFactory
abstract class AbstractModelFactory extends PersistentProxyObjectFactory
{
public function __construct(
private DefaultValuesInterface $defaultValues,
Expand All @@ -33,12 +33,12 @@ public function __construct(
parent::__construct();
}

protected function getDefaults(): array
protected function defaults(): array
{
return ($this->defaultValues)(self::faker());
}

protected function initialize(): ModelFactory
protected function initialize(): PersistentProxyObjectFactory
{
return $this
->beforeInstantiate([$this->transformer, 'transform'])
Expand Down
24 changes: 12 additions & 12 deletions src/Foundry/Factory/AddressFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@
use Sylius\Bundle\CoreBundle\Doctrine\ORM\AddressRepository;
use Sylius\Component\Core\Model\Address;
use Sylius\Component\Core\Model\AddressInterface;
use Zenstruck\Foundry\Proxy;
use Zenstruck\Foundry\RepositoryProxy;
use Zenstruck\Foundry\Persistence\Proxy;
use Zenstruck\Foundry\Persistence\ProxyRepositoryDecorator;

/**
* @extends AbstractModelFactory<AddressInterface>
*
* @method AddressInterface|Proxy create(array|callable $attributes = [])
* @method AddressInterface|Proxy create(array|callable $attributes = [], bool $noProxy = false)
* @method static AddressInterface|Proxy createOne(array $attributes = [])
* @method static AddressInterface|Proxy find(object|array|mixed $criteria)
* @method static AddressInterface|Proxy findOrCreate(array $attributes)
* @method static AddressInterface|Proxy first(string $sortedField = 'id')
* @method static AddressInterface|Proxy last(string $sortedField = 'id')
* @method static AddressInterface|Proxy random(array $attributes = [])
* @method static AddressInterface|Proxy randomOrCreate(array $attributes = [])
* @method static AddressRepository|RepositoryProxy repository()
* @method static AddressRepository|ProxyRepositoryDecorator repository()
* @method static AddressInterface[]|Proxy[] all()
* @method static AddressInterface[]|Proxy[] createMany(int $number, array|callable $attributes = [])
* @method static AddressInterface[]|Proxy[] createSequence(iterable|callable $sequence)
Expand All @@ -50,40 +50,40 @@ final class AddressFactory extends AbstractModelFactory implements FactoryWithMo

public function withCompany(?string $company = null): self
{
return $this->addState(['company' => $company ?? self::faker()->company()]);
return $this->with(['company' => $company ?? self::faker()->company()]);
}

public function withStreet(string $street): self
{
return $this->addState(['street' => $street]);
return $this->with(['street' => $street]);
}

public function withCity(string $city): self
{
return $this->addState(['city' => $city]);
return $this->with(['city' => $city]);
}

public function withPostcode(string $postcode): self
{
return $this->addState(['postcode' => $postcode]);
return $this->with(['postcode' => $postcode]);
}

public function withCountryCode(string $countryCode): self
{
return $this->addState(['countryCode' => $countryCode]);
return $this->with(['countryCode' => $countryCode]);
}

public function withProvinceName(string $provinceName): self
{
return $this->addState(['provinceName' => $provinceName]);
return $this->with(['provinceName' => $provinceName]);
}

public function withProvinceCode(string $provinceCode): self
{
return $this->addState(['provinceCode' => $provinceCode]);
return $this->with(['provinceCode' => $provinceCode]);
}

protected static function getClass(): string
public static function class(): string
{
return self::$modelClass ?? Address::class;
}
Expand Down
10 changes: 5 additions & 5 deletions src/Foundry/Factory/AdminUserFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@
use Sylius\Bundle\UserBundle\Doctrine\ORM\UserRepository;
use Sylius\Component\Core\Model\AdminUser;
use Sylius\Component\Core\Model\AdminUserInterface;
use Zenstruck\Foundry\Proxy;
use Zenstruck\Foundry\RepositoryProxy;
use Zenstruck\Foundry\Persistence\Proxy;
use Zenstruck\Foundry\Persistence\ProxyRepositoryDecorator;

/**
* @extends AbstractModelFactory<AdminUserInterface>
*
* @method AdminUserInterface|Proxy create(array|callable $attributes = [])
* @method AdminUserInterface|Proxy create(array|callable $attributes = [], bool $noProxy = false, string ...$states)
* @method static AdminUserInterface|Proxy createOne(array $attributes = [])
* @method static AdminUserInterface|Proxy find(object|array|mixed $criteria)
* @method static AdminUserInterface|Proxy findOrCreate(array $attributes)
* @method static AdminUserInterface|Proxy first(string $sortedField = 'id')
* @method static AdminUserInterface|Proxy last(string $sortedField = 'id')
* @method static AdminUserInterface|Proxy random(array $attributes = [])
* @method static AdminUserInterface|Proxy randomOrCreate(array $attributes = [])
* @method static UserRepository|RepositoryProxy repository()
* @method static UserRepository|ProxyRepositoryDecorator repository()
* @method static AdminUserInterface[]|Proxy[] all()
* @method static AdminUserInterface[]|Proxy[] createMany(int $number, array|callable $attributes = [])
* @method static AdminUserInterface[]|Proxy[] createSequence(iterable|callable $sequence)
Expand All @@ -58,7 +58,7 @@ final class AdminUserFactory extends AbstractModelFactory implements FactoryWith
use WithLocaleCodeTrait;
use WithAvatarTrait;

protected static function getClass(): string
public static function class(): string
{
return self::$modelClass ?? AdminUser::class;
}
Expand Down
14 changes: 7 additions & 7 deletions src/Foundry/Factory/CatalogPromotionActionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@
use Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository;
use Sylius\Component\Promotion\Model\CatalogPromotionAction;
use Sylius\Component\Promotion\Model\CatalogPromotionActionInterface;
use Zenstruck\Foundry\Proxy;
use Zenstruck\Foundry\RepositoryProxy;
use Zenstruck\Foundry\Persistence\Proxy;
use Zenstruck\Foundry\Persistence\ProxyRepositoryDecorator;

/**
* @extends AbstractModelFactory<CatalogPromotionActionInterface>
*
* @method CatalogPromotionActionInterface|Proxy create(array|callable $attributes = [])
* @method CatalogPromotionActionInterface|Proxy create(array|callable $attributes = [], bool $noProxy = false)
* @method static CatalogPromotionActionInterface|Proxy createOne(array $attributes = [])
* @method static CatalogPromotionActionInterface|Proxy find(object|array|mixed $criteria)
* @method static CatalogPromotionActionInterface|Proxy findOrCreate(array $attributes)
* @method static CatalogPromotionActionInterface|Proxy first(string $sortedField = 'id')
* @method static CatalogPromotionActionInterface|Proxy last(string $sortedField = 'id')
* @method static CatalogPromotionActionInterface|Proxy random(array $attributes = [])
* @method static CatalogPromotionActionInterface|Proxy randomOrCreate(array $attributes = [])
* @method static EntityRepository|RepositoryProxy repository()
* @method static EntityRepository|ProxyRepositoryDecorator repository()
* @method static CatalogPromotionActionInterface[]|Proxy[] all()
* @method static CatalogPromotionActionInterface[]|Proxy[] createMany(int $number, array|callable $attributes = [])
* @method static CatalogPromotionActionInterface[]|Proxy[] createSequence(iterable|callable $sequence)
Expand All @@ -44,15 +44,15 @@ final class CatalogPromotionActionFactory extends AbstractModelFactory implement

public function withType(string $type): self
{
return $this->addState(['type' => $type]);
return $this->with(['type' => $type]);
}

public function withConfiguration(array $configuration): self
{
return $this->addState(['configuration' => $configuration]);
return $this->with(['configuration' => $configuration]);
}

protected static function getClass(): string
public static function class(): string
{
return self::$modelClass ?? CatalogPromotionAction::class;
}
Expand Down
24 changes: 12 additions & 12 deletions src/Foundry/Factory/CatalogPromotionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@
use Doctrine\ORM\EntityRepository;
use Sylius\Component\Core\Model\CatalogPromotion;
use Sylius\Component\Core\Model\CatalogPromotionInterface;
use Zenstruck\Foundry\Proxy;
use Zenstruck\Foundry\RepositoryProxy;
use Zenstruck\Foundry\Persistence\Proxy;
use Zenstruck\Foundry\Persistence\ProxyRepositoryDecorator;

/**
* @extends AbstractModelFactory<CatalogPromotionInterface>
*
* @method CatalogPromotionInterface|Proxy create(array|callable $attributes = [])
* @method CatalogPromotionInterface|Proxy create(array|callable $attributes = [], bool $noProxy = false)
* @method static CatalogPromotionInterface|Proxy createOne(array $attributes = [])
* @method static CatalogPromotionInterface|Proxy find(object|array|mixed $criteria)
* @method static CatalogPromotionInterface|Proxy findOrCreate(array $attributes)
* @method static CatalogPromotionInterface|Proxy first(string $sortedField = 'id')
* @method static CatalogPromotionInterface|Proxy last(string $sortedField = 'id')
* @method static CatalogPromotionInterface|Proxy random(array $attributes = [])
* @method static CatalogPromotionInterface|Proxy randomOrCreate(array $attributes = [])
* @method static EntityRepository|RepositoryProxy repository()
* @method static EntityRepository|ProxyRepositoryDecorator repository()
* @method static CatalogPromotionInterface[]|Proxy[] all()
* @method static CatalogPromotionInterface[]|Proxy[] createMany(int $number, array|callable $attributes = [])
* @method static CatalogPromotionInterface[]|Proxy[] createSequence(iterable|callable $sequence)
Expand All @@ -56,40 +56,40 @@ final class CatalogPromotionFactory extends AbstractModelFactory implements Fact

public function withLabel(string $label): self
{
return $this->addState(['label' => $label]);
return $this->with(['label' => $label]);
}

public function withScopes(array $scopes): self
{
return $this->addState(['scopes' => $scopes]);
return $this->with(['scopes' => $scopes]);
}

public function withActions(array $actions): self
{
return $this->addState(['actions' => $actions]);
return $this->with(['actions' => $actions]);
}

public function exclusive(): self
{
return $this->addState(['exclusive' => true]);
return $this->with(['exclusive' => true]);
}

public function notExclusive(): self
{
return $this->addState(['exclusive' => false]);
return $this->with(['exclusive' => false]);
}

public function withStartDate(\DateTimeInterface|string $startDate): self
{
return $this->addState(['startDate' => $startDate]);
return $this->with(['startDate' => $startDate]);
}

public function withEndDate(\DateTimeInterface|string $endDate): self
{
return $this->addState(['endDate' => $endDate]);
return $this->with(['endDate' => $endDate]);
}

protected static function getClass(): string
public static function class(): string
{
return self::$modelClass ?? CatalogPromotion::class;
}
Expand Down
14 changes: 7 additions & 7 deletions src/Foundry/Factory/CatalogPromotionScopeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@
use Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository;
use Sylius\Component\Core\Model\CatalogPromotionScope;
use Sylius\Component\Core\Model\CatalogPromotionScopeInterface;
use Zenstruck\Foundry\Proxy;
use Zenstruck\Foundry\RepositoryProxy;
use Zenstruck\Foundry\Persistence\Proxy;
use Zenstruck\Foundry\Persistence\ProxyRepositoryDecorator;

/**
* @extends AbstractModelFactory<CatalogPromotionScopeInterface>
*
* @method CatalogPromotionScopeInterface|Proxy create(array|callable $attributes = [])
* @method CatalogPromotionScopeInterface|Proxy create(array|callable $attributes = [], bool $noProxy = false)
* @method static CatalogPromotionScopeInterface|Proxy createOne(array $attributes = [])
* @method static CatalogPromotionScopeInterface|Proxy find(object|array|mixed $criteria)
* @method static CatalogPromotionScopeInterface|Proxy findOrCreate(array $attributes)
* @method static CatalogPromotionScopeInterface|Proxy first(string $sortedField = 'id')
* @method static CatalogPromotionScopeInterface|Proxy last(string $sortedField = 'id')
* @method static CatalogPromotionScopeInterface|Proxy random(array $attributes = [])
* @method static CatalogPromotionScopeInterface|Proxy randomOrCreate(array $attributes = [])
* @method static EntityRepository|RepositoryProxy repository()
* @method static EntityRepository|ProxyRepositoryDecorator repository()
* @method static CatalogPromotionScopeInterface[]|Proxy[] all()
* @method static CatalogPromotionScopeInterface[]|Proxy[] createMany(int $number, array|callable $attributes = [])
* @method static CatalogPromotionScopeInterface[]|Proxy[] createSequence(iterable|callable $sequence)
Expand All @@ -44,15 +44,15 @@ final class CatalogPromotionScopeFactory extends AbstractModelFactory implements

public function withType(string $type): self
{
return $this->addState(['type' => $type]);
return $this->with(['type' => $type]);
}

public function withConfiguration(array $configuration): self
{
return $this->addState(['configuration' => $configuration]);
return $this->with(['configuration' => $configuration]);
}

protected static function getClass(): string
public static function class(): string
{
return self::$modelClass ?? CatalogPromotionScope::class;
}
Expand Down
Loading
Loading