mirror of https://github.com/wallabag/wallabag.git
Merge pull request #6798 from yguedidi/add-mandatory-$class-parameter
Add mandatory $class parameter
This commit is contained in:
commit
a4b0a01b6d
|
@ -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');
|
||||
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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'));
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue