ソースを参照

Merge branch 'master' of ssh://gitea.spawntree.de:1122/spawntree/matsen-tool-be

master
Florian Eisenmenger 2年前
コミット
81de8b638d
100個のファイルの変更466行の追加62行の削除
  1. +0
    -57
      migrations/Version20240304164555.php
  2. +39
    -0
      migrations/Version20240305152901.php
  3. +69
    -0
      src/ApiResource/ProductApi.php
  4. +8
    -2
      src/DataFixtures/AppFixtures.php
  5. +17
    -0
      src/DataFixtures/FakeValues.php
  6. バイナリ
      src/DataFixtures/images/products/06e2aeec-08dc-4bb5-92d9-3cda1a83f7c9.jpg
  7. バイナリ
      src/DataFixtures/images/products/089-Ask-Bild1.jpg
  8. バイナリ
      src/DataFixtures/images/products/145454_pIhFN2Ugm.webp
  9. バイナリ
      src/DataFixtures/images/products/171651_1XE80u3Zy.webp
  10. バイナリ
      src/DataFixtures/images/products/179210247-chemikalien-in-reagenzgläsern-und-symbolen-die-im-labor-oder-in-der-industrie-verwendet-werden.jpg
  11. バイナリ
      src/DataFixtures/images/products/20230222_Fluorchemikalien-_adpic.jpg
  12. バイナリ
      src/DataFixtures/images/products/20368327-vektorsymbol-fur-chemikalien-vektor.jpg
  13. バイナリ
      src/DataFixtures/images/products/297744-reagenzglaser-mit-chemikalien-kostenlos-vektor.jpg
  14. バイナリ
      src/DataFixtures/images/products/36461009_Chemikalien_Schlierner_Header1-1220x610-1.jpg
  15. バイナリ
      src/DataFixtures/images/products/4954227.png
  16. バイナリ
      src/DataFixtures/images/products/615hboYBEVL._AC_UF894,1000_QL80_.jpg
  17. バイナリ
      src/DataFixtures/images/products/6364c360d3bb5_c-KGNqzCL.webp
  18. バイナリ
      src/DataFixtures/images/products/6581938872383176.webp
  19. バイナリ
      src/DataFixtures/images/products/71I8kTNrSsL._AC_UF1000,1000_QL80_.jpg
  20. バイナリ
      src/DataFixtures/images/products/94e44c75-cccb-474c-bd9c-1d821e6f368a.jpeg
  21. バイナリ
      src/DataFixtures/images/products/Akemi-Chemikaliensilicon.jpg
  22. バイナリ
      emikalien.png
  23. バイナリ
      src/DataFixtures/images/products/Bismuttrioxid.jpg
  24. バイナリ
      src/DataFixtures/images/products/Chamikalien_1g-2.webp
  25. バイナリ
      src/DataFixtures/images/products/Chemicals.png
  26. バイナリ
      src/DataFixtures/images/products/Chemikalien-freist__ScaleWidthWzgwMF0.png
  27. バイナリ
      src/DataFixtures/images/products/Chemikalien.jpg
  28. バイナリ
      src/DataFixtures/images/products/Chemikalien_Antoine2K.jpg
  29. バイナリ
      tzmittel
  30. バイナリ
      src/DataFixtures/images/products/IGB_6860.jpg
  31. バイナリ
      src/DataFixtures/images/products/Leitthema_Chemikalienrecycling_935674692_Fotograf-BlackJack3D_iStock.jpg
  32. バイナリ
      src/DataFixtures/images/products/Reagenzglas.jpg
  33. バイナリ
      sch_Reinigungsmittel_Polymerprodukte.jpg
  34. バイナリ
      src/DataFixtures/images/products/Wasser_Umwelt_AdobeStock_285345543_Natali-3000x1687-637x358.jpeg
  35. バイナリ
      src/DataFixtures/images/products/a34880.jpg
  36. バイナリ
      src/DataFixtures/images/products/a34885.jpg
  37. バイナリ
      src/DataFixtures/images/products/abfall_chemikalien.jpg
  38. バイナリ
      src/DataFixtures/images/products/adea669d-9924-4909-9d79-9143cb010eef_w960_r1.778_fpx63_fpy52.jpg
  39. バイナリ
      src/DataFixtures/images/products/adobestock_611392391_chemikalien.jpeg
  40. バイナリ
      src/DataFixtures/images/products/angetrieben-von-chemikalien.jpg
  41. バイナリ
      src/DataFixtures/images/products/becher-mit-den-reagenzgläsern-gefüllt-mit-chemikalien-58624587.webp
  42. バイナリ
      src/DataFixtures/images/products/bi2o3_chda_-2.jpg
  43. バイナリ
      src/DataFixtures/images/products/bunte-chemikalien-12777275.webp
  44. バイナリ
      src/DataFixtures/images/products/cg_chemikalien_group_rexx_systems-1024x538.jpg
  45. バイナリ
      src/DataFixtures/images/products/chemikalien-1.jpg
  46. バイナリ
      src/DataFixtures/images/products/chemikalien-artikel2.jpeg
  47. バイナリ
      src/DataFixtures/images/products/chemikalien-im-labor-700-119730440.jpg
  48. バイナリ
      src/DataFixtures/images/products/chemikalien-im-wasser.jpg
  49. バイナリ
      src/DataFixtures/images/products/chemikalien.webp
  50. バイナリ
      src/DataFixtures/images/products/chemikalien_AdobeStock_116776874.webp
  51. バイナリ
      src/DataFixtures/images/products/csm_Fotolia_21280019_M_Gefahrstoffe_d82c07547d.jpg
  52. バイナリ
      src/DataFixtures/images/products/csm_KI_Becherglas_bunt_84e57f1426.jpg
  53. バイナリ
      src/DataFixtures/images/products/enghals-chemikalien-flaschen_00018802.webp
  54. バイナリ
      src/DataFixtures/images/products/enghals-chemikalien-flaschen_00026892.webp
  55. バイナリ
      src/DataFixtures/images/products/gefahrstoffe_a_bruno_fotolia_24886834_m.jpg
  56. バイナリ
      src/DataFixtures/images/products/greenpeace.avif
  57. バイナリ
      src/DataFixtures/images/products/images.jpg
  58. バイナリ
      src/DataFixtures/images/products/impact-story-Chemicals-cover.webp
  59. バイナリ
      src/DataFixtures/images/products/istock-1355779437.jpg
  60. バイナリ
      src/DataFixtures/images/products/justrite-notfall-set-chemikalien--1032976--470x470--p.jpg
  61. バイナリ
      src/DataFixtures/images/products/labor-120~_v-varm_88873b.jpg
  62. バイナリ
      src/DataFixtures/images/products/leadImage.jpg
  63. バイナリ
      src/DataFixtures/images/products/pipettieren-einer-oelprobe-zur-erforschung-von-medizin-und-chemikalien-CAVF95337.jpg
  64. バイナリ
      src/DataFixtures/images/products/pngtree-chemicals-icon-in-trendy-style-isolated-background-png-image_1554545.jpg
  65. バイナリ
      src/DataFixtures/images/products/shutterstock_1561135202-800x450.jpg
  66. バイナリ
      src/DataFixtures/images/products/spicytruffel-AdobeStock_316542333-Konvertiert.jpg
  67. バイナリ
      src/DataFixtures/images/products/streitfall-chemikalien-wer.webp
  68. バイナリ
      src/DataFixtures/images/products/symbol-fuer-die-linie-der-flasche-mit-chemikalien_116137-5518.avif
  69. バイナリ
      src/DataFixtures/images/products/teaserbox_2419937771.jpg
  70. バイナリ
      src/DataFixtures/images/products/teaserbox_2446472365.jpg
  71. バイナリ
      src/DataFixtures/images/products/teaserbox_2449303018.jpg
  72. バイナリ
      src/DataFixtures/images/products/teaserbox_2450499236.jpg
  73. バイナリ
      src/DataFixtures/images/products/teaserbox_2462792495.jpg
  74. バイナリ
      src/DataFixtures/images/products/teaserbox_2462830751.JPG
  75. バイナリ
      src/DataFixtures/images/products/teaserbox_2473428103.JPG
  76. バイナリ
      src/DataFixtures/images/products/urinprobe_bildquelle_joergbeuge_fotolia_27589149_m.jpg
  77. バイナリ
      src/DataFixtures/images/products/weithals-chemikalien-flaschen_00018762.webp
  78. バイナリ
      src/DataFixtures/images/users/4798951-smurfs_color_pictures_poet_smurf.jpg
  79. バイナリ
      src/DataFixtures/images/users/4798991-schtroumpf-paresseux.jpg
  80. バイナリ
      src/DataFixtures/images/users/5e354e4c73be4d0ef14e6b761b27e25e.png
  81. バイナリ
      src/DataFixtures/images/users/819027-brainy.jpg
  82. バイナリ
      src/DataFixtures/images/users/Gizmo_Smurf_Vic_George.webp
  83. バイナリ
      src/DataFixtures/images/users/Handy_Comic_Book.webp
  84. バイナリ
      src/DataFixtures/images/users/SmurfCovidCartoonCharacter.SMjpg.webp
  85. バイナリ
      src/DataFixtures/images/users/c2c97f0614837c506b5d25820988f6dc.jpg
  86. バイナリ
      src/DataFixtures/images/users/e5f648d978973e3db259226929789f1d.jpg
  87. バイナリ
      src/DataFixtures/images/users/images.jpg
  88. バイナリ
      src/DataFixtures/images/users/images.png
  89. バイナリ
      src/DataFixtures/images/users/slouchy-smurfling-tv-characters-photo-u1.jpg
  90. バイナリ
      src/DataFixtures/images/users/tailor-smurf-tv-characters-photo-u1.jpg
  91. バイナリ
      src/DataFixtures/images/users/the-king-tv-characters-photo-u1.jpg
  92. バイナリ
      src/DataFixtures/images/users/the-smurfette-brainy-smurf-papa-smurf-the-smurfs-blonde-hair-cartoon-characters.jpg
  93. +2
    -1
      src/Entity/MediaObject.php
  94. +79
    -0
      src/Entity/Product.php
  95. +13
    -0
      src/Entity/User.php
  96. +1
    -1
      src/Factory/ContactFactory.php
  97. +1
    -1
      src/Factory/MediaObjectContactFactory.php
  98. +83
    -0
      src/Factory/MediaObjectProductFactory.php
  99. +83
    -0
      src/Factory/MediaObjectUserFactory.php
  100. +71
    -0
      src/Factory/ProductFactory.php

+ 0
- 57
migrations/Version20240304164555.php ファイルの表示

@@ -1,57 +0,0 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240304164555 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}

public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE comment (id INT AUTO_INCREMENT NOT NULL, owner_id INT NOT NULL, posting_id INT NOT NULL, message LONGTEXT NOT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_9474526C7E3C61F9 (owner_id), INDEX IDX_9474526C9AE985F6 (posting_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE contact (id INT AUTO_INCREMENT NOT NULL, partner_id INT NOT NULL, image_id INT DEFAULT NULL, first_name VARCHAR(255) NOT NULL, last_name VARCHAR(255) NOT NULL, birthday DATE DEFAULT NULL, position VARCHAR(255) DEFAULT NULL, phone VARCHAR(255) DEFAULT NULL, email VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_4C62E6389393F8FE (partner_id), INDEX IDX_4C62E6383DA5256D (image_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE media_object (id INT AUTO_INCREMENT NOT NULL, file_path VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE partner (id INT AUTO_INCREMENT NOT NULL, logo_id INT DEFAULT NULL, name VARCHAR(255) NOT NULL, type VARCHAR(255) NOT NULL, street VARCHAR(255) DEFAULT NULL, street_no VARCHAR(255) DEFAULT NULL, zip VARCHAR(255) DEFAULT NULL, city VARCHAR(255) DEFAULT NULL, country VARCHAR(255) DEFAULT NULL, website VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_312B3E16F98F144A (logo_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE posting (id INT AUTO_INCREMENT NOT NULL, owner_id INT NOT NULL, partner_id INT NOT NULL, contact_id INT DEFAULT NULL, headline VARCHAR(255) NOT NULL, message LONGTEXT NOT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_BD275D737E3C61F9 (owner_id), INDEX IDX_BD275D739393F8FE (partner_id), INDEX IDX_BD275D73E7A1254A (contact_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE `user` (id INT AUTO_INCREMENT NOT NULL, email VARCHAR(180) NOT NULL, first_name VARCHAR(255) NOT NULL, last_name VARCHAR(255) NOT NULL, roles JSON NOT NULL COMMENT \'(DC2Type:json)\', password VARCHAR(255) NOT NULL, active TINYINT(1) NOT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', UNIQUE INDEX UNIQ_8D93D649E7927C74 (email), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE comment ADD CONSTRAINT FK_9474526C7E3C61F9 FOREIGN KEY (owner_id) REFERENCES `user` (id)');
$this->addSql('ALTER TABLE comment ADD CONSTRAINT FK_9474526C9AE985F6 FOREIGN KEY (posting_id) REFERENCES posting (id)');
$this->addSql('ALTER TABLE contact ADD CONSTRAINT FK_4C62E6389393F8FE FOREIGN KEY (partner_id) REFERENCES partner (id)');
$this->addSql('ALTER TABLE contact ADD CONSTRAINT FK_4C62E6383DA5256D FOREIGN KEY (image_id) REFERENCES media_object (id) ON DELETE SET NULL');
$this->addSql('ALTER TABLE partner ADD CONSTRAINT FK_312B3E16F98F144A FOREIGN KEY (logo_id) REFERENCES media_object (id) ON DELETE SET NULL');
$this->addSql('ALTER TABLE posting ADD CONSTRAINT FK_BD275D737E3C61F9 FOREIGN KEY (owner_id) REFERENCES `user` (id)');
$this->addSql('ALTER TABLE posting ADD CONSTRAINT FK_BD275D739393F8FE FOREIGN KEY (partner_id) REFERENCES partner (id)');
$this->addSql('ALTER TABLE posting ADD CONSTRAINT FK_BD275D73E7A1254A FOREIGN KEY (contact_id) REFERENCES contact (id)');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE comment DROP FOREIGN KEY FK_9474526C7E3C61F9');
$this->addSql('ALTER TABLE comment DROP FOREIGN KEY FK_9474526C9AE985F6');
$this->addSql('ALTER TABLE contact DROP FOREIGN KEY FK_4C62E6389393F8FE');
$this->addSql('ALTER TABLE contact DROP FOREIGN KEY FK_4C62E6383DA5256D');
$this->addSql('ALTER TABLE partner DROP FOREIGN KEY FK_312B3E16F98F144A');
$this->addSql('ALTER TABLE posting DROP FOREIGN KEY FK_BD275D737E3C61F9');
$this->addSql('ALTER TABLE posting DROP FOREIGN KEY FK_BD275D739393F8FE');
$this->addSql('ALTER TABLE posting DROP FOREIGN KEY FK_BD275D73E7A1254A');
$this->addSql('DROP TABLE comment');
$this->addSql('DROP TABLE contact');
$this->addSql('DROP TABLE media_object');
$this->addSql('DROP TABLE partner');
$this->addSql('DROP TABLE posting');
$this->addSql('DROP TABLE `user`');
}
}

+ 39
- 0
migrations/Version20240305152901.php ファイルの表示

@@ -0,0 +1,39 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240305152901 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}

public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE product (id INT AUTO_INCREMENT NOT NULL, image_id INT DEFAULT NULL, name VARCHAR(255) NOT NULL, description LONGTEXT DEFAULT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_D34A04AD3DA5256D (image_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE product ADD CONSTRAINT FK_D34A04AD3DA5256D FOREIGN KEY (image_id) REFERENCES media_object (id)');
$this->addSql('ALTER TABLE user ADD image_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE user ADD CONSTRAINT FK_8D93D6493DA5256D FOREIGN KEY (image_id) REFERENCES media_object (id)');
$this->addSql('CREATE INDEX IDX_8D93D6493DA5256D ON user (image_id)');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE product DROP FOREIGN KEY FK_D34A04AD3DA5256D');
$this->addSql('DROP TABLE product');
$this->addSql('ALTER TABLE `user` DROP FOREIGN KEY FK_8D93D6493DA5256D');
$this->addSql('DROP INDEX IDX_8D93D6493DA5256D ON `user`');
$this->addSql('ALTER TABLE `user` DROP image_id');
}
}

+ 69
- 0
src/ApiResource/ProductApi.php ファイルの表示

@@ -0,0 +1,69 @@
<?php
/**
* @author Daniel Knudsen <d.knudsen@spawntree.de>
* @date 12.12.23
*/


namespace App\ApiResource;


use ApiPlatform\Doctrine\Orm\Filter\OrderFilter;
use ApiPlatform\Doctrine\Orm\State\Options;
use ApiPlatform\Metadata\ApiFilter;
use ApiPlatform\Metadata\ApiProperty;
use ApiPlatform\Metadata\ApiResource;
use App\Entity\MediaObject;
use App\Entity\Product;
use App\State\EntityClassDtoStateProcessor;
use App\State\EntityToDtoStateProvider;
use ApiPlatform\Metadata\Delete;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Patch;
use ApiPlatform\Metadata\Post;
use Symfony\Component\Validator\Constraints\NotBlank;

#[ApiResource(
shortName: 'Product',
operations: [
new Get(
security: 'is_granted("ROLE_USER")'
),
new GetCollection(),
new Post(
security: 'is_granted("ROLE_USER")',
),
new Patch(
security: 'is_granted("ROLE_USER")',
),
new Delete(
security: 'is_granted("ROLE_ADMIN")',
)
],
order: ['name' => 'ASC'],
security: 'is_granted("ROLE_USER")',
provider: EntityToDtoStateProvider::class,
processor: EntityClassDtoStateProcessor::class,
stateOptions: new Options(entityClass: Product::class)
)]

#[ApiFilter(OrderFilter::class, properties: ['name'], arguments: ['orderParameterName' => 'order'])]
class ProductApi
{
#[ApiProperty(readable: false, writable: false, identifier: true)]
public ?int $id = null;

#[NotBlank]
public string $name;

public ?string $description = null;

public ?MediaObject $image = null;

#[ApiProperty(writable: false)]
public ?string $imageUrl = null;

public ?\DateTimeImmutable $createdAt = null;

}

+ 8
- 2
src/DataFixtures/AppFixtures.php ファイルの表示

@@ -5,9 +5,12 @@ namespace App\DataFixtures;
use App\Factory\CommentFactory;
use App\Factory\ContactFactory;
use App\Factory\MediaObjectLogoFactory;
use App\Factory\MediaObjectProfileFactory;
use App\Factory\MediaObjectProductFactory;
use App\Factory\MediaObjectContactFactory;
use App\Factory\MediaObjectUserFactory;
use App\Factory\PartnerFactory;
use App\Factory\PostingFactory;
use App\Factory\ProductFactory;
use App\Factory\UserFactory;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Persistence\ObjectManager;
@@ -34,6 +37,7 @@ class AppFixtures extends Fixture
}
}

MediaObjectUserFactory::createMany(20);
$adminD = UserFactory::createOne(
[
'email' => 'd.knudsen@spawntree.de',
@@ -57,9 +61,11 @@ class AppFixtures extends Fixture
UserFactory::createMany(10);
MediaObjectLogoFactory::createMany(50);
PartnerFactory::createMany(100);
MediaObjectProfileFactory::createMany(50);
MediaObjectContactFactory::createMany(50);
ContactFactory::createMany(200);
PostingFactory::createMany(200);
CommentFactory::createMany(300);
MediaObjectProductFactory::createMany(50);
ProductFactory::createMany(100);
}
}

+ 17
- 0
src/DataFixtures/FakeValues.php ファイルの表示

@@ -187,4 +187,21 @@ class FakeValues
"Systemadministrator", "Vertriebsingenieur", "Produktionsplaner", "Personalbeschaffer",
"Content Creator", "Bürokoordinator"
];

const PRODUCTS = [
'Oxidanol-X', 'Quantum Acidite', 'NeuroSolvent', 'HydroMystique', 'Luminaflux', 'Nanoglow Serum', 'Etherium Catalyst', 'BioSol ExoBlend',
'CryoSynth Elixir', 'NebulaVapour', 'Magnaflux Solvent', 'SynthoQuanta', 'QuantumSolve-X', 'PlasmaFusion Serum', 'ElectroLyte-X', 'SynthoBlast Acid',
'MegaMelt Radiant', 'Ionic Infusion X', 'QuantumBond Solvent', 'Molecular Surge', 'Etherium Enhancer', 'BioCryo Synthase', 'MagmaMyst Serum',
'HydroMyst Elixir', 'NeuroQuell Acid', 'PlasmaGlow Catalyst', 'NanoSizzle Blend', 'QuantumVortex X', 'VitaSynth Serum', 'CryoFusion Acid',
'RadiantQuanta Elixir', 'QuantumSurge Acid', 'NebulaRadiance Blend', 'Luminex Catalyst', 'ElectroPulse-X', 'CryoWave Serum', 'SynthoFlare Acid',
'Nanoglow Elixir', 'QuantumSpark Blend', 'MagnaFusion Catalyst', 'ElectroQuanta Acid', 'LuminarX Serum', 'NeuroWave-X', 'CryoSpark Acid',
'PlasmaQuanta Elixir', 'MegaCryo Catalyst', 'IonicQuell Blend', 'QuantumSizzle-X', 'NeuroRadiance Acid', 'NebulaFusion Serum', 'HydroQuanta X',
'RadiantFlare Blend', 'BioMyst Acid', 'SynthoVortex Serum', 'QuantumSurge-X', 'PlasmaQuell Blend', 'MolecularGlow Catalyst', 'Luminex Serum',
'ElectroWave Acid', 'CryoMyst Elixir', 'NeuroFusion Blend', 'NanoSizzle Acid', 'QuantumPulse Serum', 'MegaFlare-X', 'PlasmaRadiance Acid',
'SynthoQuanta Elixir', 'NebulaCryo Blend', 'HydroQuell Acid', 'RadiantFusion Serum', 'ElectroCryo-X', 'MolecularQuanta Acid', 'BioSpark Elixir',
'QuantumRadiance Blend', 'NanoFlare Acid', 'MagnaQuanta Serum', 'Luminex Catalyst-X', 'CryoFusion Elixir', 'NeuroQuell Blend', 'PlasmaMyst Acid',
'SynthoRadiance Serum', 'QuantumVortex-X', 'NebulaSpark Blend', 'HydroGlow Catalyst', 'RadiantQuanta Acid', 'ElectroMyst Elixir', 'MegaQuell Serum',
'CryoVortex Acid', 'NanoRadiance Blend', 'QuantumFusion Serum', 'SynthoFlare-X', 'PlasmaQuell Acid', 'MolecularGlow Blend', 'Luminex Catalyst-X',
'ElectroWave Serum', 'CryoMyst Acid', 'NeuroFusion Elixir', 'NanoSizzle Blend-X', 'QuantumPulse Acid', 'RadiantFlare Serum', 'BioQuanta Catalyst',
];
}

バイナリ
src/DataFixtures/images/products/06e2aeec-08dc-4bb5-92d9-3cda1a83f7c9.jpg ファイルの表示

変更前 変更後
幅: 750  |  高さ: 500  |  サイズ: 40 KiB

バイナリ
src/DataFixtures/images/products/089-Ask-Bild1.jpg ファイルの表示

変更前 変更後
幅: 646  |  高さ: 441  |  サイズ: 72 KiB

バイナリ
src/DataFixtures/images/products/145454_pIhFN2Ugm.webp ファイルの表示

変更前 変更後

バイナリ
src/DataFixtures/images/products/171651_1XE80u3Zy.webp ファイルの表示

変更前 変更後

バイナリ
src/DataFixtures/images/products/179210247-chemikalien-in-reagenzgläsern-und-symbolen-die-im-labor-oder-in-der-industrie-verwendet-werden.jpg ファイルの表示

変更前 変更後
幅: 450  |  高さ: 300  |  サイズ: 24 KiB

バイナリ
src/DataFixtures/images/products/20230222_Fluorchemikalien-_adpic.jpg ファイルの表示

変更前 変更後
幅: 1080  |  高さ: 721  |  サイズ: 93 KiB

バイナリ
src/DataFixtures/images/products/20368327-vektorsymbol-fur-chemikalien-vektor.jpg ファイルの表示

変更前 変更後
幅: 661  |  高さ: 980  |  サイズ: 50 KiB

バイナリ
src/DataFixtures/images/products/297744-reagenzglaser-mit-chemikalien-kostenlos-vektor.jpg ファイルの表示

変更前 変更後
幅: 556  |  高さ: 490  |  サイズ: 30 KiB

バイナリ
src/DataFixtures/images/products/36461009_Chemikalien_Schlierner_Header1-1220x610-1.jpg ファイルの表示

変更前 変更後
幅: 1220  |  高さ: 610  |  サイズ: 115 KiB

バイナリ
src/DataFixtures/images/products/4954227.png ファイルの表示

変更前 変更後
幅: 512  |  高さ: 512  |  サイズ: 24 KiB

バイナリ
src/DataFixtures/images/products/615hboYBEVL._AC_UF894,1000_QL80_.jpg ファイルの表示

変更前 変更後
幅: 894  |  高さ: 877  |  サイズ: 43 KiB

バイナリ
src/DataFixtures/images/products/6364c360d3bb5_c-KGNqzCL.webp ファイルの表示

変更前 変更後

バイナリ
src/DataFixtures/images/products/6581938872383176.webp ファイルの表示

変更前 変更後

バイナリ
src/DataFixtures/images/products/71I8kTNrSsL._AC_UF1000,1000_QL80_.jpg ファイルの表示

変更前 変更後
幅: 761  |  高さ: 1000  |  サイズ: 57 KiB

バイナリ
src/DataFixtures/images/products/94e44c75-cccb-474c-bd9c-1d821e6f368a.jpeg ファイルの表示

変更前 変更後
幅: 525  |  高さ: 525  |  サイズ: 60 KiB

バイナリ
src/DataFixtures/images/products/Akemi-Chemikaliensilicon.jpg ファイルの表示

変更前 変更後
幅: 660  |  高さ: 660  |  サイズ: 78 KiB

バイナリ
src/DataFixtures/images/products/Bild → emikalien.png ファイルの表示


バイナリ
src/DataFixtures/images/products/Bismuttrioxid.jpg ファイルの表示

変更前 変更後
幅: 650  |  高さ: 500  |  サイズ: 98 KiB

バイナリ
src/DataFixtures/images/products/Chamikalien_1g-2.webp ファイルの表示

変更前 変更後

バイナリ
src/DataFixtures/images/products/Chemicals.png ファイルの表示

変更前 変更後
幅: 610  |  高さ: 350  |  サイズ: 26 KiB

バイナリ
src/DataFixtures/images/products/Chemikalien-freist__ScaleWidthWzgwMF0.png ファイルの表示

変更前 変更後
幅: 800  |  高さ: 800  |  サイズ: 240 KiB

バイナリ
src/DataFixtures/images/products/Chemikalien.jpg ファイルの表示

変更前 変更後
幅: 360  |  高さ: 477  |  サイズ: 8.0 KiB

バイナリ
src/DataFixtures/images/products/Chemikalien_Antoine2K.jpg ファイルの表示

変更前 変更後
幅: 770  |  高さ: 420  |  サイズ: 32 KiB

バイナリ
src/DataFixtures/images/products/Haushaltsreiniger → tzmittel ファイルの表示


バイナリ
src/DataFixtures/images/products/IGB_6860.jpg ファイルの表示

変更前 変更後
幅: 1000  |  高さ: 563  |  サイズ: 65 KiB

バイナリ
src/DataFixtures/images/products/Leitthema_Chemikalienrecycling_935674692_Fotograf-BlackJack3D_iStock.jpg ファイルの表示

変更前 変更後
幅: 1200  |  高さ: 600  |  サイズ: 88 KiB

バイナリ
src/DataFixtures/images/products/Reagenzglas.jpg ファイルの表示

変更前 変更後
幅: 895  |  高さ: 502  |  サイズ: 130 KiB

バイナリ
src/DataFixtures/images/products/Unternehmen_Umweltauflagen_Bezug_Metallvearbeitungflüssigkeiten, → sch_Reinigungsmittel_Polymerprodukte.jpg ファイルの表示


バイナリ
src/DataFixtures/images/products/Wasser_Umwelt_AdobeStock_285345543_Natali-3000x1687-637x358.jpeg ファイルの表示

変更前 変更後
幅: 637  |  高さ: 358  |  サイズ: 179 KiB

バイナリ
src/DataFixtures/images/products/a34880.jpg ファイルの表示

変更前 変更後
幅: 800  |  高さ: 800  |  サイズ: 33 KiB

バイナリ
src/DataFixtures/images/products/a34885.jpg ファイルの表示

変更前 変更後
幅: 800  |  高さ: 800  |  サイズ: 41 KiB

バイナリ
src/DataFixtures/images/products/abfall_chemikalien.jpg ファイルの表示

変更前 変更後
幅: 900  |  高さ: 300  |  サイズ: 121 KiB

バイナリ
src/DataFixtures/images/products/adea669d-9924-4909-9d79-9143cb010eef_w960_r1.778_fpx63_fpy52.jpg ファイルの表示

変更前 変更後
幅: 960  |  高さ: 540  |  サイズ: 61 KiB

バイナリ
src/DataFixtures/images/products/adobestock_611392391_chemikalien.jpeg ファイルの表示

変更前 変更後
幅: 960  |  高さ: 540  |  サイズ: 50 KiB

バイナリ
src/DataFixtures/images/products/angetrieben-von-chemikalien.jpg ファイルの表示

変更前 変更後
幅: 378  |  高さ: 378  |  サイズ: 11 KiB

バイナリ
src/DataFixtures/images/products/becher-mit-den-reagenzgläsern-gefüllt-mit-chemikalien-58624587.webp ファイルの表示

変更前 変更後

バイナリ
src/DataFixtures/images/products/bi2o3_chda_-2.jpg ファイルの表示

変更前 変更後
幅: 1920  |  高さ: 1280  |  サイズ: 1.7 MiB

バイナリ
src/DataFixtures/images/products/bunte-chemikalien-12777275.webp ファイルの表示

変更前 変更後

バイナリ
src/DataFixtures/images/products/cg_chemikalien_group_rexx_systems-1024x538.jpg ファイルの表示

変更前 変更後
幅: 1024  |  高さ: 538  |  サイズ: 56 KiB

バイナリ
src/DataFixtures/images/products/chemikalien-1.jpg ファイルの表示

変更前 変更後
幅: 533  |  高さ: 400  |  サイズ: 17 KiB

バイナリ
src/DataFixtures/images/products/chemikalien-artikel2.jpeg ファイルの表示

変更前 変更後
幅: 987  |  高さ: 392  |  サイズ: 43 KiB

バイナリ
src/DataFixtures/images/products/chemikalien-im-labor-700-119730440.jpg ファイルの表示

変更前 変更後
幅: 700  |  高さ: 467  |  サイズ: 66 KiB

バイナリ
src/DataFixtures/images/products/chemikalien-im-wasser.jpg ファイルの表示

変更前 変更後
幅: 640  |  高さ: 360  |  サイズ: 46 KiB

バイナリ
src/DataFixtures/images/products/chemikalien.webp ファイルの表示

変更前 変更後

バイナリ
src/DataFixtures/images/products/chemikalien_AdobeStock_116776874.webp ファイルの表示

変更前 変更後

バイナリ
src/DataFixtures/images/products/csm_Fotolia_21280019_M_Gefahrstoffe_d82c07547d.jpg ファイルの表示

変更前 変更後
幅: 727  |  高さ: 545  |  サイズ: 53 KiB

バイナリ
src/DataFixtures/images/products/csm_KI_Becherglas_bunt_84e57f1426.jpg ファイルの表示

変更前 変更後
幅: 828  |  高さ: 621  |  サイズ: 65 KiB

バイナリ
src/DataFixtures/images/products/enghals-chemikalien-flaschen_00018802.webp ファイルの表示

変更前 変更後

バイナリ
src/DataFixtures/images/products/enghals-chemikalien-flaschen_00026892.webp ファイルの表示

変更前 変更後

バイナリ
src/DataFixtures/images/products/gefahrstoffe_a_bruno_fotolia_24886834_m.jpg ファイルの表示

変更前 変更後
幅: 800  |  高さ: 400  |  サイズ: 86 KiB

バイナリ
src/DataFixtures/images/products/greenpeace.avif ファイルの表示


バイナリ
src/DataFixtures/images/products/images.jpg ファイルの表示

変更前 変更後
幅: 299  |  高さ: 168  |  サイズ: 5.4 KiB

バイナリ
src/DataFixtures/images/products/impact-story-Chemicals-cover.webp ファイルの表示

変更前 変更後

バイナリ
src/DataFixtures/images/products/istock-1355779437.jpg ファイルの表示

変更前 変更後
幅: 730  |  高さ: 460  |  サイズ: 56 KiB

バイナリ
src/DataFixtures/images/products/justrite-notfall-set-chemikalien--1032976--470x470--p.jpg ファイルの表示

変更前 変更後
幅: 470  |  高さ: 470  |  サイズ: 30 KiB

バイナリ
src/DataFixtures/images/products/labor-120~_v-varm_88873b.jpg ファイルの表示

変更前 変更後
幅: 512  |  高さ: 288  |  サイズ: 21 KiB

バイナリ
src/DataFixtures/images/products/leadImage.jpg ファイルの表示

変更前 変更後
幅: 800  |  高さ: 450  |  サイズ: 50 KiB

バイナリ
src/DataFixtures/images/products/pipettieren-einer-oelprobe-zur-erforschung-von-medizin-und-chemikalien-CAVF95337.jpg ファイルの表示

変更前 変更後
幅: 480  |  高さ: 360  |  サイズ: 28 KiB

バイナリ
src/DataFixtures/images/products/pngtree-chemicals-icon-in-trendy-style-isolated-background-png-image_1554545.jpg ファイルの表示

変更前 変更後
幅: 360  |  高さ: 360  |  サイズ: 6.8 KiB

バイナリ
src/DataFixtures/images/products/shutterstock_1561135202-800x450.jpg ファイルの表示

変更前 変更後
幅: 800  |  高さ: 450  |  サイズ: 34 KiB

バイナリ
src/DataFixtures/images/products/spicytruffel-AdobeStock_316542333-Konvertiert.jpg ファイルの表示

変更前 変更後
幅: 960  |  高さ: 600  |  サイズ: 206 KiB

バイナリ
src/DataFixtures/images/products/streitfall-chemikalien-wer.webp ファイルの表示

変更前 変更後

バイナリ
src/DataFixtures/images/products/symbol-fuer-die-linie-der-flasche-mit-chemikalien_116137-5518.avif ファイルの表示


バイナリ
src/DataFixtures/images/products/teaserbox_2419937771.jpg ファイルの表示

変更前 変更後
幅: 900  |  高さ: 617  |  サイズ: 123 KiB

バイナリ
src/DataFixtures/images/products/teaserbox_2446472365.jpg ファイルの表示

変更前 変更後
幅: 781  |  高さ: 554  |  サイズ: 189 KiB

バイナリ
src/DataFixtures/images/products/teaserbox_2449303018.jpg ファイルの表示

変更前 変更後
幅: 900  |  高さ: 563  |  サイズ: 260 KiB

バイナリ
src/DataFixtures/images/products/teaserbox_2450499236.jpg ファイルの表示

変更前 変更後
幅: 800  |  高さ: 585  |  サイズ: 181 KiB

バイナリ
src/DataFixtures/images/products/teaserbox_2462792495.jpg ファイルの表示

変更前 変更後
幅: 900  |  高さ: 675  |  サイズ: 178 KiB

バイナリ
src/DataFixtures/images/products/teaserbox_2462830751.JPG ファイルの表示

変更前 変更後
幅: 900  |  高さ: 620  |  サイズ: 273 KiB

バイナリ
src/DataFixtures/images/products/teaserbox_2473428103.JPG ファイルの表示

変更前 変更後
幅: 900  |  高さ: 672  |  サイズ: 86 KiB

バイナリ
src/DataFixtures/images/products/urinprobe_bildquelle_joergbeuge_fotolia_27589149_m.jpg ファイルの表示

変更前 変更後
幅: 800  |  高さ: 550  |  サイズ: 81 KiB

バイナリ
src/DataFixtures/images/products/weithals-chemikalien-flaschen_00018762.webp ファイルの表示

変更前 変更後

バイナリ
src/DataFixtures/images/users/4798951-smurfs_color_pictures_poet_smurf.jpg ファイルの表示

変更前 変更後
幅: 320  |  高さ: 320  |  サイズ: 25 KiB

バイナリ
src/DataFixtures/images/users/4798991-schtroumpf-paresseux.jpg ファイルの表示

変更前 変更後
幅: 320  |  高さ: 320  |  サイズ: 24 KiB

バイナリ
src/DataFixtures/images/users/5e354e4c73be4d0ef14e6b761b27e25e.png ファイルの表示

変更前 変更後
幅: 792  |  高さ: 752  |  サイズ: 22 KiB

バイナリ
src/DataFixtures/images/users/819027-brainy.jpg ファイルの表示

変更前 変更後
幅: 320  |  高さ: 320  |  サイズ: 8.9 KiB

バイナリ
src/DataFixtures/images/users/Gizmo_Smurf_Vic_George.webp ファイルの表示

変更前 変更後

バイナリ
src/DataFixtures/images/users/Handy_Comic_Book.webp ファイルの表示

変更前 変更後

バイナリ
src/DataFixtures/images/users/SmurfCovidCartoonCharacter.SMjpg.webp ファイルの表示

変更前 変更後

バイナリ
src/DataFixtures/images/users/c2c97f0614837c506b5d25820988f6dc.jpg ファイルの表示

変更前 変更後
幅: 564  |  高さ: 800  |  サイズ: 50 KiB

バイナリ
src/DataFixtures/images/users/e5f648d978973e3db259226929789f1d.jpg ファイルの表示

変更前 変更後
幅: 340  |  高さ: 406  |  サイズ: 21 KiB

バイナリ
src/DataFixtures/images/users/images.jpg ファイルの表示

変更前 変更後
幅: 246  |  高さ: 205  |  サイズ: 11 KiB

バイナリ
src/DataFixtures/images/users/images.png ファイルの表示

変更前 変更後
幅: 221  |  高さ: 228  |  サイズ: 9.6 KiB

バイナリ
src/DataFixtures/images/users/slouchy-smurfling-tv-characters-photo-u1.jpg ファイルの表示

変更前 変更後
幅: 250  |  高さ: 250  |  サイズ: 5.5 KiB

バイナリ
src/DataFixtures/images/users/tailor-smurf-tv-characters-photo-u1.jpg ファイルの表示

変更前 変更後
幅: 250  |  高さ: 250  |  サイズ: 5.6 KiB

バイナリ
src/DataFixtures/images/users/the-king-tv-characters-photo-u1.jpg ファイルの表示

変更前 変更後
幅: 250  |  高さ: 250  |  サイズ: 7.5 KiB

バイナリ
src/DataFixtures/images/users/the-smurfette-brainy-smurf-papa-smurf-the-smurfs-blonde-hair-cartoon-characters.jpg ファイルの表示

変更前 変更後
幅: 621  |  高さ: 849  |  サイズ: 47 KiB

+ 2
- 1
src/Entity/MediaObject.php ファイルの表示

@@ -55,7 +55,8 @@ use Vich\UploaderBundle\Mapping\Annotation as Vich;
// controller: DeleteMediaObjectAction::class
),
],
normalizationContext: ['groups' => ['media_object:read']]
normalizationContext: ['groups' => ['media_object:read']],
security: 'is_granted("ROLE_USER")',
)]
class MediaObject
{


+ 79
- 0
src/Entity/Product.php ファイルの表示

@@ -0,0 +1,79 @@
<?php

namespace App\Entity;

use App\Repository\ProductRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity(repositoryClass: ProductRepository::class)]
class Product
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;

#[ORM\Column(length: 255)]
private ?string $name = null;

#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $description = null;

#[ORM\ManyToOne]
private ?MediaObject $image = null;

#[ORM\Column]
private ?\DateTimeImmutable $createdAt = null;

public function __construct()
{
$this->createdAt = new \DateTimeImmutable();
}

public function getId(): ?int
{
return $this->id;
}

public function getName(): ?string
{
return $this->name;
}

public function setName(string $name): static
{
$this->name = $name;

return $this;
}

public function getDescription(): ?string
{
return $this->description;
}

public function setDescription(?string $description): static
{
$this->description = $description;

return $this;
}

public function getImage(): ?MediaObject
{
return $this->image;
}

public function setImage(?MediaObject $image): static
{
$this->image = $image;

return $this;
}

public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
}

+ 13
- 0
src/Entity/User.php ファイルの表示

@@ -27,6 +27,9 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
#[ORM\Column(length: 255)]
private ?string $lastName = null;

#[ORM\ManyToOne]
private ?MediaObject $image = null;

#[ORM\Column]
private array $roles = [];

@@ -151,6 +154,16 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
return $this;
}

public function getImage(): ?MediaObject
{
return $this->image;
}

public function setImage(?MediaObject $image): void
{
$this->image = $image;
}

public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;


+ 1
- 1
src/Factory/ContactFactory.php ファイルの表示

@@ -55,7 +55,7 @@ final class ContactFactory extends ModelFactory
'phone' => self::faker()->phoneNumber(),
'email' => self::faker()->email(),
'partner' => PartnerFactory::random(),
'image' => MediaObjectProfileFactory::random()
'image' => MediaObjectContactFactory::random()
];
}



src/Factory/MediaObjectProfileFactory.php → src/Factory/MediaObjectContactFactory.php ファイルの表示

@@ -31,7 +31,7 @@ use Zenstruck\Foundry\RepositoryProxy;
* @method static MediaObject[]|Proxy[] randomRange(int $min, int $max, array $attributes = [])
* @method static MediaObject[]|Proxy[] randomSet(int $number, array $attributes = [])
*/
final class MediaObjectProfileFactory extends ModelFactory
final class MediaObjectContactFactory extends ModelFactory
{
/**
* @see https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#factories-as-services

+ 83
- 0
src/Factory/MediaObjectProductFactory.php ファイルの表示

@@ -0,0 +1,83 @@
<?php

namespace App\Factory;

use App\Entity\MediaObject;
use Doctrine\ORM\EntityRepository;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\HttpKernel\KernelInterface;
use Vich\UploaderBundle\FileAbstraction\ReplacingFile;
use Zenstruck\Foundry\ModelFactory;
use Zenstruck\Foundry\Proxy;
use Zenstruck\Foundry\RepositoryProxy;

/**
* @extends ModelFactory<MediaObject>
*
* @method MediaObject|Proxy create(array|callable $attributes = [])
* @method static MediaObject|Proxy createOne(array $attributes = [])
* @method static MediaObject|Proxy find(object|array|mixed $criteria)
* @method static MediaObject|Proxy findOrCreate(array $attributes)
* @method static MediaObject|Proxy first(string $sortedField = 'id')
* @method static MediaObject|Proxy last(string $sortedField = 'id')
* @method static MediaObject|Proxy random(array $attributes = [])
* @method static MediaObject|Proxy randomOrCreate(array $attributes = [])
* @method static EntityRepository|RepositoryProxy repository()
* @method static MediaObject[]|Proxy[] all()
* @method static MediaObject[]|Proxy[] createMany(int $number, array|callable $attributes = [])
* @method static MediaObject[]|Proxy[] createSequence(iterable|callable $sequence)
* @method static MediaObject[]|Proxy[] findBy(array $attributes)
* @method static MediaObject[]|Proxy[] randomRange(int $min, int $max, array $attributes = [])
* @method static MediaObject[]|Proxy[] randomSet(int $number, array $attributes = [])
*/
final class MediaObjectProductFactory extends ModelFactory
{
/**
* @see https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#factories-as-services
*
* @todo inject services if required
*/
public function __construct(
private KernelInterface $appKernel
)
{
parent::__construct();
}

/**
* @see https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#model-factories
*
* @todo add your default values here
*/
protected function getDefaults(): array
{
$projectRoot = $this->appKernel->getProjectDir();

$folderPath = $projectRoot . '/src/DataFixtures/images/products/';
$files = glob($folderPath . '*.*');
$randomFile = null;
if ($files !== false && count($files) > 0) {
$randomFile = $files[array_rand($files)];
}

return [
'file' => new ReplacingFile($randomFile)
];
}

/**
* @see https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#initialization
*/
protected function initialize(): self
{
return $this
// ->afterInstantiate(function(MediaObject $mediaObject): void {})
;
}

protected static function getClass(): string
{
return MediaObject::class;
}
}

+ 83
- 0
src/Factory/MediaObjectUserFactory.php ファイルの表示

@@ -0,0 +1,83 @@
<?php

namespace App\Factory;

use App\Entity\MediaObject;
use Doctrine\ORM\EntityRepository;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\HttpKernel\KernelInterface;
use Vich\UploaderBundle\FileAbstraction\ReplacingFile;
use Zenstruck\Foundry\ModelFactory;
use Zenstruck\Foundry\Proxy;
use Zenstruck\Foundry\RepositoryProxy;

/**
* @extends ModelFactory<MediaObject>
*
* @method MediaObject|Proxy create(array|callable $attributes = [])
* @method static MediaObject|Proxy createOne(array $attributes = [])
* @method static MediaObject|Proxy find(object|array|mixed $criteria)
* @method static MediaObject|Proxy findOrCreate(array $attributes)
* @method static MediaObject|Proxy first(string $sortedField = 'id')
* @method static MediaObject|Proxy last(string $sortedField = 'id')
* @method static MediaObject|Proxy random(array $attributes = [])
* @method static MediaObject|Proxy randomOrCreate(array $attributes = [])
* @method static EntityRepository|RepositoryProxy repository()
* @method static MediaObject[]|Proxy[] all()
* @method static MediaObject[]|Proxy[] createMany(int $number, array|callable $attributes = [])
* @method static MediaObject[]|Proxy[] createSequence(iterable|callable $sequence)
* @method static MediaObject[]|Proxy[] findBy(array $attributes)
* @method static MediaObject[]|Proxy[] randomRange(int $min, int $max, array $attributes = [])
* @method static MediaObject[]|Proxy[] randomSet(int $number, array $attributes = [])
*/
final class MediaObjectUserFactory extends ModelFactory
{
/**
* @see https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#factories-as-services
*
* @todo inject services if required
*/
public function __construct(
private KernelInterface $appKernel
)
{
parent::__construct();
}

/**
* @see https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#model-factories
*
* @todo add your default values here
*/
protected function getDefaults(): array
{
$projectRoot = $this->appKernel->getProjectDir();

$folderPath = $projectRoot . '/src/DataFixtures/images/users/';
$files = glob($folderPath . '*.*');
$randomFile = null;
if ($files !== false && count($files) > 0) {
$randomFile = $files[array_rand($files)];
}

return [
'file' => new ReplacingFile($randomFile)
];
}

/**
* @see https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#initialization
*/
protected function initialize(): self
{
return $this
// ->afterInstantiate(function(MediaObject $mediaObject): void {})
;
}

protected static function getClass(): string
{
return MediaObject::class;
}
}

+ 71
- 0
src/Factory/ProductFactory.php ファイルの表示

@@ -0,0 +1,71 @@
<?php

namespace App\Factory;

use App\DataFixtures\FakeValues;
use App\Entity\Product;
use App\Repository\ProductRepository;
use Zenstruck\Foundry\ModelFactory;
use Zenstruck\Foundry\Proxy;
use Zenstruck\Foundry\RepositoryProxy;

/**
* @extends ModelFactory<Product>
*
* @method Product|Proxy create(array|callable $attributes = [])
* @method static Product|Proxy createOne(array $attributes = [])
* @method static Product|Proxy find(object|array|mixed $criteria)
* @method static Product|Proxy findOrCreate(array $attributes)
* @method static Product|Proxy first(string $sortedField = 'id')
* @method static Product|Proxy last(string $sortedField = 'id')
* @method static Product|Proxy random(array $attributes = [])
* @method static Product|Proxy randomOrCreate(array $attributes = [])
* @method static ProductRepository|RepositoryProxy repository()
* @method static Product[]|Proxy[] all()
* @method static Product[]|Proxy[] createMany(int $number, array|callable $attributes = [])
* @method static Product[]|Proxy[] createSequence(iterable|callable $sequence)
* @method static Product[]|Proxy[] findBy(array $attributes)
* @method static Product[]|Proxy[] randomRange(int $min, int $max, array $attributes = [])
* @method static Product[]|Proxy[] randomSet(int $number, array $attributes = [])
*/
final class ProductFactory 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()->randomElement(FakeValues::PRODUCTS),
'description' => self::faker()->text(),
'image' => MediaObjectProductFactory::createOne(),
];
}

/**
* @see https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#initialization
*/
protected function initialize(): self
{
return $this
// ->afterInstantiate(function(Product $product): void {})
;
}

protected static function getClass(): string
{
return Product::class;
}
}

変更されたファイルが多すぎるため、一部のファイルは表示されません

読み込み中…
キャンセル
保存