You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
70 lines
2.5 KiB
70 lines
2.5 KiB
<?php
|
|
|
|
namespace App\Factory;
|
|
|
|
use App\Entity\Dojo;
|
|
use Doctrine\ORM\EntityRepository;
|
|
use Zenstruck\Foundry\ModelFactory;
|
|
use Zenstruck\Foundry\Proxy;
|
|
use Zenstruck\Foundry\RepositoryProxy;
|
|
|
|
/**
|
|
* @extends ModelFactory<Dojo>
|
|
*
|
|
* @method Dojo|Proxy create(array|callable $attributes = [])
|
|
* @method static Dojo|Proxy createOne(array $attributes = [])
|
|
* @method static Dojo|Proxy find(object|array|mixed $criteria)
|
|
* @method static Dojo|Proxy findOrCreate(array $attributes)
|
|
* @method static Dojo|Proxy first(string $sortedField = 'id')
|
|
* @method static Dojo|Proxy last(string $sortedField = 'id')
|
|
* @method static Dojo|Proxy random(array $attributes = [])
|
|
* @method static Dojo|Proxy randomOrCreate(array $attributes = [])
|
|
* @method static EntityRepository|RepositoryProxy repository()
|
|
* @method static Dojo[]|Proxy[] all()
|
|
* @method static Dojo[]|Proxy[] createMany(int $number, array|callable $attributes = [])
|
|
* @method static Dojo[]|Proxy[] createSequence(iterable|callable $sequence)
|
|
* @method static Dojo[]|Proxy[] findBy(array $attributes)
|
|
* @method static Dojo[]|Proxy[] randomRange(int $min, int $max, array $attributes = [])
|
|
* @method static Dojo[]|Proxy[] randomSet(int $number, array $attributes = [])
|
|
*/
|
|
final class DojoFactory extends ModelFactory
|
|
{
|
|
/**
|
|
* @see https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#factories-as-services
|
|
*
|
|
* @todo inject services if required
|
|
*/
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
|
|
/**
|
|
* @see https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#model-factories
|
|
*
|
|
* @todo add your default values here
|
|
*/
|
|
protected function getDefaults(): array
|
|
{
|
|
return [
|
|
'name' => self::faker()->text(),
|
|
'owner' => UserFactory::new(),
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @see https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#initialization
|
|
*/
|
|
protected function initialize(): self
|
|
{
|
|
return $this
|
|
// ->afterInstantiate(function(Dojo $dojo): void {})
|
|
;
|
|
}
|
|
|
|
protected static function getClass(): string
|
|
{
|
|
return Dojo::class;
|
|
}
|
|
}
|