mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-03-24 16:18:00 +01:00
Specify order in which the data fixtures should be loaded
This commit is contained in:
@@ -1,37 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
* Copyright (C) 2019 - 2022 Jan Böhmer (https://github.com/jbtronics)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\DataFixtures;
|
||||
|
||||
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
|
||||
class AppFixtures extends Fixture
|
||||
{
|
||||
public function load(ObjectManager $manager): void
|
||||
{
|
||||
// $product = new Product();
|
||||
// $manager->persist($product);
|
||||
|
||||
$manager->flush();
|
||||
}
|
||||
}
|
||||
@@ -31,12 +31,14 @@ use App\Entity\Parts\Manufacturer;
|
||||
use App\Entity\Parts\MeasurementUnit;
|
||||
use App\Entity\Parts\Storelocation;
|
||||
use App\Entity\Parts\Supplier;
|
||||
use App\Entity\UserSystem\User;
|
||||
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use InvalidArgumentException;
|
||||
|
||||
class DataStructureFixtures extends Fixture
|
||||
class DataStructureFixtures extends Fixture implements DependentFixtureInterface
|
||||
{
|
||||
public function __construct(protected EntityManagerInterface $em)
|
||||
{
|
||||
@@ -49,7 +51,7 @@ class DataStructureFixtures extends Fixture
|
||||
{
|
||||
//Reset autoincrement
|
||||
$types = [AttachmentType::class, Project::class, Category::class, Footprint::class, Manufacturer::class,
|
||||
MeasurementUnit::class, Storelocation::class, Supplier::class, ];
|
||||
MeasurementUnit::class, Storelocation::class, Supplier::class,];
|
||||
|
||||
foreach ($types as $type) {
|
||||
$this->createNodesForClass($type, $manager);
|
||||
@@ -106,4 +108,11 @@ class DataStructureFixtures extends Fixture
|
||||
$manager->persist($node2_1);
|
||||
$manager->persist($node1_1_1);
|
||||
}
|
||||
|
||||
public function getDependencies(): array
|
||||
{
|
||||
return [
|
||||
UserFixtures::class
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,4 +110,11 @@ class LabelProfileFixtures extends Fixture
|
||||
|
||||
$manager->flush();
|
||||
}
|
||||
|
||||
public function getDependencies(): array
|
||||
{
|
||||
return [
|
||||
PartFixtures::class,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,10 +55,11 @@ use App\Entity\PriceInformations\Pricedetail;
|
||||
use Brick\Math\BigDecimal;
|
||||
use DateTime;
|
||||
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
|
||||
class PartFixtures extends Fixture
|
||||
class PartFixtures extends Fixture implements DependentFixtureInterface
|
||||
{
|
||||
public function __construct(protected EntityManagerInterface $em)
|
||||
{
|
||||
@@ -132,4 +133,11 @@ class PartFixtures extends Fixture
|
||||
$manager->persist($part);
|
||||
$manager->flush();
|
||||
}
|
||||
|
||||
public function getDependencies(): array
|
||||
{
|
||||
return [
|
||||
DataStructureFixtures::class
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,11 +24,12 @@ namespace App\DataFixtures;
|
||||
|
||||
use App\Entity\UserSystem\User;
|
||||
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
|
||||
|
||||
class UserFixtures extends Fixture
|
||||
class UserFixtures extends Fixture implements DependentFixtureInterface
|
||||
{
|
||||
public function __construct(protected UserPasswordHasherInterface $encoder, protected EntityManagerInterface $em)
|
||||
{
|
||||
@@ -66,4 +67,11 @@ class UserFixtures extends Fixture
|
||||
|
||||
$manager->flush();
|
||||
}
|
||||
|
||||
public function getDependencies(): array
|
||||
{
|
||||
return [
|
||||
GroupFixtures::class,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user