Skip to content

Commit

Permalink
fix(dependencies): foundry compatibility above 1.38
Browse files Browse the repository at this point in the history
  • Loading branch information
vasilvestre committed Jul 30, 2024
1 parent ddb4ba8 commit 890fde4
Show file tree
Hide file tree
Showing 84 changed files with 298 additions and 282 deletions.
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

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
22 changes: 11 additions & 11 deletions src/Foundry/Factory/AddressFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
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>
Expand All @@ -33,7 +33,7 @@
* @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
8 changes: 4 additions & 4 deletions src/Foundry/Factory/AdminUserFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
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>
Expand All @@ -38,7 +38,7 @@
* @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
12 changes: 6 additions & 6 deletions src/Foundry/Factory/CatalogPromotionActionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
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>
Expand All @@ -30,7 +30,7 @@
* @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
22 changes: 11 additions & 11 deletions src/Foundry/Factory/CatalogPromotionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
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>
Expand All @@ -36,7 +36,7 @@
* @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
12 changes: 6 additions & 6 deletions src/Foundry/Factory/CatalogPromotionScopeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
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>
Expand All @@ -30,7 +30,7 @@
* @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

0 comments on commit 890fde4

Please sign in to comment.