From 667ea14d42f9c97f11a68caae89ecf4d48b7d65f Mon Sep 17 00:00:00 2001 From: Yassine Guedidi Date: Sat, 5 Aug 2023 17:25:03 +0100 Subject: [PATCH] Add mandatory $class parameter --- .../DataFixtures/AnnotationFixtures.php | 14 ++++++++------ .../CoreBundle/DataFixtures/ConfigFixtures.php | 7 ++++--- .../CoreBundle/DataFixtures/EntryFixtures.php | 6 ++++-- .../DataFixtures/IgnoreOriginUserRuleFixtures.php | 3 ++- .../DataFixtures/SiteCredentialFixtures.php | 5 +++-- .../DataFixtures/TaggingRuleFixtures.php | 13 +++++++------ 6 files changed, 28 insertions(+), 20 deletions(-) diff --git a/src/Wallabag/AnnotationBundle/DataFixtures/AnnotationFixtures.php b/src/Wallabag/AnnotationBundle/DataFixtures/AnnotationFixtures.php index 5161a4094..a2d857d2b 100644 --- a/src/Wallabag/AnnotationBundle/DataFixtures/AnnotationFixtures.php +++ b/src/Wallabag/AnnotationBundle/DataFixtures/AnnotationFixtures.php @@ -7,7 +7,9 @@ use Doctrine\Common\DataFixtures\DependentFixtureInterface; use Doctrine\Persistence\ObjectManager; use Wallabag\AnnotationBundle\Entity\Annotation; use Wallabag\CoreBundle\DataFixtures\EntryFixtures; +use Wallabag\CoreBundle\Entity\Entry; use Wallabag\UserBundle\DataFixtures\UserFixtures; +use Wallabag\UserBundle\Entity\User; class AnnotationFixtures extends Fixture implements DependentFixtureInterface { @@ -16,8 +18,8 @@ class AnnotationFixtures extends Fixture implements DependentFixtureInterface */ public function load(ObjectManager $manager) { - $annotation1 = new Annotation($this->getReference('admin-user')); - $annotation1->setEntry($this->getReference('entry1')); + $annotation1 = new Annotation($this->getReference('admin-user', User::class)); + $annotation1->setEntry($this->getReference('entry1', Entry::class)); $annotation1->setText('This is my annotation /o/'); $annotation1->setQuote('content'); @@ -25,8 +27,8 @@ class AnnotationFixtures extends Fixture implements DependentFixtureInterface $this->addReference('annotation1', $annotation1); - $annotation2 = new Annotation($this->getReference('admin-user')); - $annotation2->setEntry($this->getReference('entry2')); + $annotation2 = new Annotation($this->getReference('admin-user', User::class)); + $annotation2->setEntry($this->getReference('entry2', Entry::class)); $annotation2->setText('This is my 2nd annotation /o/'); $annotation2->setQuote('content'); @@ -34,8 +36,8 @@ class AnnotationFixtures extends Fixture implements DependentFixtureInterface $this->addReference('annotation2', $annotation2); - $annotation3 = new Annotation($this->getReference('bob-user')); - $annotation3->setEntry($this->getReference('entry3')); + $annotation3 = new Annotation($this->getReference('bob-user', User::class)); + $annotation3->setEntry($this->getReference('entry3', Entry::class)); $annotation3->setText('This is my first annotation !'); $annotation3->setQuote('content'); diff --git a/src/Wallabag/CoreBundle/DataFixtures/ConfigFixtures.php b/src/Wallabag/CoreBundle/DataFixtures/ConfigFixtures.php index 77809f95b..6f6942113 100644 --- a/src/Wallabag/CoreBundle/DataFixtures/ConfigFixtures.php +++ b/src/Wallabag/CoreBundle/DataFixtures/ConfigFixtures.php @@ -7,6 +7,7 @@ use Doctrine\Common\DataFixtures\DependentFixtureInterface; use Doctrine\Persistence\ObjectManager; use Wallabag\CoreBundle\Entity\Config; use Wallabag\UserBundle\DataFixtures\UserFixtures; +use Wallabag\UserBundle\Entity\User; class ConfigFixtures extends Fixture implements DependentFixtureInterface { @@ -15,7 +16,7 @@ class ConfigFixtures extends Fixture implements DependentFixtureInterface */ public function load(ObjectManager $manager): void { - $adminConfig = new Config($this->getReference('admin-user')); + $adminConfig = new Config($this->getReference('admin-user', User::class)); $adminConfig->setItemsPerPage(30); $adminConfig->setReadingSpeed(200); @@ -29,7 +30,7 @@ class ConfigFixtures extends Fixture implements DependentFixtureInterface $this->addReference('admin-config', $adminConfig); - $bobConfig = new Config($this->getReference('bob-user')); + $bobConfig = new Config($this->getReference('bob-user', User::class)); $bobConfig->setItemsPerPage(10); $bobConfig->setReadingSpeed(200); $bobConfig->setLanguage('fr'); @@ -42,7 +43,7 @@ class ConfigFixtures extends Fixture implements DependentFixtureInterface $this->addReference('bob-config', $bobConfig); - $emptyConfig = new Config($this->getReference('empty-user')); + $emptyConfig = new Config($this->getReference('empty-user', User::class)); $emptyConfig->setItemsPerPage(10); $emptyConfig->setReadingSpeed(100); $emptyConfig->setLanguage('en'); diff --git a/src/Wallabag/CoreBundle/DataFixtures/EntryFixtures.php b/src/Wallabag/CoreBundle/DataFixtures/EntryFixtures.php index 55e8fc172..6ce8d0db1 100644 --- a/src/Wallabag/CoreBundle/DataFixtures/EntryFixtures.php +++ b/src/Wallabag/CoreBundle/DataFixtures/EntryFixtures.php @@ -6,7 +6,9 @@ use Doctrine\Bundle\FixturesBundle\Fixture; use Doctrine\Common\DataFixtures\DependentFixtureInterface; use Doctrine\Persistence\ObjectManager; use Wallabag\CoreBundle\Entity\Entry; +use Wallabag\CoreBundle\Entity\Tag; use Wallabag\UserBundle\DataFixtures\UserFixtures; +use Wallabag\UserBundle\Entity\User; class EntryFixtures extends Fixture implements DependentFixtureInterface { @@ -87,7 +89,7 @@ class EntryFixtures extends Fixture implements DependentFixtureInterface ]; foreach ($entries as $reference => $item) { - $entry = new Entry($this->getReference($item['user'])); + $entry = new Entry($this->getReference($item['user'], User::class)); $entry->setUrl($item['url']); $entry->setReadingTime($item['reading_time']); $entry->setDomainName($item['domain']); @@ -98,7 +100,7 @@ class EntryFixtures extends Fixture implements DependentFixtureInterface if (isset($item['tags'])) { foreach ($item['tags'] as $tag) { - $entry->addTag($this->getReference($tag)); + $entry->addTag($this->getReference($tag, Tag::class)); } } diff --git a/src/Wallabag/CoreBundle/DataFixtures/IgnoreOriginUserRuleFixtures.php b/src/Wallabag/CoreBundle/DataFixtures/IgnoreOriginUserRuleFixtures.php index fbacef901..0bf5d29b0 100644 --- a/src/Wallabag/CoreBundle/DataFixtures/IgnoreOriginUserRuleFixtures.php +++ b/src/Wallabag/CoreBundle/DataFixtures/IgnoreOriginUserRuleFixtures.php @@ -7,6 +7,7 @@ use Doctrine\Common\DataFixtures\DependentFixtureInterface; use Doctrine\Persistence\ObjectManager; use Wallabag\CoreBundle\Entity\IgnoreOriginUserRule; use Wallabag\UserBundle\DataFixtures\UserFixtures; +use Wallabag\UserBundle\Entity\User; class IgnoreOriginUserRuleFixtures extends Fixture implements DependentFixtureInterface { @@ -17,7 +18,7 @@ class IgnoreOriginUserRuleFixtures extends Fixture implements DependentFixtureIn { $rule = new IgnoreOriginUserRule(); $rule->setRule('host = "example.fr"'); - $rule->setConfig($this->getReference('admin-user')->getConfig()); + $rule->setConfig($this->getReference('admin-user', User::class)->getConfig()); $manager->persist($rule); diff --git a/src/Wallabag/CoreBundle/DataFixtures/SiteCredentialFixtures.php b/src/Wallabag/CoreBundle/DataFixtures/SiteCredentialFixtures.php index 68cbe2182..45088168d 100644 --- a/src/Wallabag/CoreBundle/DataFixtures/SiteCredentialFixtures.php +++ b/src/Wallabag/CoreBundle/DataFixtures/SiteCredentialFixtures.php @@ -10,6 +10,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface; use Wallabag\CoreBundle\Entity\SiteCredential; use Wallabag\CoreBundle\Helper\CryptoProxy; use Wallabag\UserBundle\DataFixtures\UserFixtures; +use Wallabag\UserBundle\Entity\User; class SiteCredentialFixtures extends Fixture implements DependentFixtureInterface, ContainerAwareInterface { @@ -28,14 +29,14 @@ class SiteCredentialFixtures extends Fixture implements DependentFixtureInterfac */ public function load(ObjectManager $manager): void { - $credential = new SiteCredential($this->getReference('admin-user')); + $credential = new SiteCredential($this->getReference('admin-user', User::class)); $credential->setHost('.super.com'); $credential->setUsername($this->container->get(CryptoProxy::class)->crypt('.super')); $credential->setPassword($this->container->get(CryptoProxy::class)->crypt('bar')); $manager->persist($credential); - $credential = new SiteCredential($this->getReference('admin-user')); + $credential = new SiteCredential($this->getReference('admin-user', User::class)); $credential->setHost('paywall.example.com'); $credential->setUsername($this->container->get(CryptoProxy::class)->crypt('paywall.example')); $credential->setPassword($this->container->get(CryptoProxy::class)->crypt('bar')); diff --git a/src/Wallabag/CoreBundle/DataFixtures/TaggingRuleFixtures.php b/src/Wallabag/CoreBundle/DataFixtures/TaggingRuleFixtures.php index 083c7bc98..917df9a4e 100644 --- a/src/Wallabag/CoreBundle/DataFixtures/TaggingRuleFixtures.php +++ b/src/Wallabag/CoreBundle/DataFixtures/TaggingRuleFixtures.php @@ -5,6 +5,7 @@ namespace Wallabag\CoreBundle\DataFixtures; use Doctrine\Bundle\FixturesBundle\Fixture; use Doctrine\Common\DataFixtures\DependentFixtureInterface; use Doctrine\Persistence\ObjectManager; +use Wallabag\CoreBundle\Entity\Config; use Wallabag\CoreBundle\Entity\TaggingRule; class TaggingRuleFixtures extends Fixture implements DependentFixtureInterface @@ -17,14 +18,14 @@ class TaggingRuleFixtures extends Fixture implements DependentFixtureInterface $tr1 = new TaggingRule(); $tr1->setRule('content matches "spurs"'); $tr1->setTags(['sport']); - $tr1->setConfig($this->getReference('admin-config')); + $tr1->setConfig($this->getReference('admin-config', Config::class)); $manager->persist($tr1); $tr2 = new TaggingRule(); $tr2->setRule('content matches "basket"'); $tr2->setTags(['sport']); - $tr2->setConfig($this->getReference('admin-config')); + $tr2->setConfig($this->getReference('admin-config', Config::class)); $manager->persist($tr2); @@ -32,28 +33,28 @@ class TaggingRuleFixtures extends Fixture implements DependentFixtureInterface $tr3->setRule('title matches "wallabag"'); $tr3->setTags(['wallabag']); - $tr3->setConfig($this->getReference('admin-config')); + $tr3->setConfig($this->getReference('admin-config', Config::class)); $manager->persist($tr3); $tr4 = new TaggingRule(); $tr4->setRule('content notmatches "basket"'); $tr4->setTags(['foot']); - $tr4->setConfig($this->getReference('admin-config')); + $tr4->setConfig($this->getReference('admin-config', Config::class)); $manager->persist($tr4); $tr5 = new TaggingRule(); $tr5->setRule('readingTime <= 5'); $tr5->setTags(['shortread']); - $tr5->setConfig($this->getReference('empty-config')); + $tr5->setConfig($this->getReference('empty-config', Config::class)); $manager->persist($tr5); $tr6 = new TaggingRule(); $tr6->setRule('readingTime > 5'); $tr6->setTags(['longread']); - $tr6->setConfig($this->getReference('empty-config')); + $tr6->setConfig($this->getReference('empty-config', Config::class)); $manager->persist($tr6);