aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/DataFixtures
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2015-12-27 22:26:49 +0100
committerJeremy Benoist <jeremy.benoist@gmail.com>2015-12-28 13:20:48 +0100
commitfc031e5706acf89ff21f22ca8004ddc7f9b43089 (patch)
tree845fd4f69308dc11ca6c54cc9ed4be62cb4f471c /src/Wallabag/CoreBundle/DataFixtures
parent82899c040258896bff540080602e93aa49a71ae8 (diff)
downloadwallabag-fc031e5706acf89ff21f22ca8004ddc7f9b43089.tar.gz
wallabag-fc031e5706acf89ff21f22ca8004ddc7f9b43089.tar.zst
wallabag-fc031e5706acf89ff21f22ca8004ddc7f9b43089.zip
Avoid multiple tag creation
When a new tag is created but not yet persisted, it can be duplicated. It could happen when multiple rules match the content and at least 2 of them should attach same new tag. Fix #1528
Diffstat (limited to 'src/Wallabag/CoreBundle/DataFixtures')
-rw-r--r--src/Wallabag/CoreBundle/DataFixtures/ORM/LoadTaggingRuleData.php41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadTaggingRuleData.php b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadTaggingRuleData.php
new file mode 100644
index 00000000..09a08bb2
--- /dev/null
+++ b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadTaggingRuleData.php
@@ -0,0 +1,41 @@
1<?php
2
3namespace Wallabag\CoreBundle\DataFixtures\ORM;
4
5use Doctrine\Common\DataFixtures\AbstractFixture;
6use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
7use Doctrine\Common\Persistence\ObjectManager;
8use Wallabag\CoreBundle\Entity\TaggingRule;
9
10class LoadTaggingRuleData extends AbstractFixture implements OrderedFixtureInterface
11{
12 /**
13 * {@inheritdoc}
14 */
15 public function load(ObjectManager $manager)
16 {
17 $tr1 = new TaggingRule();
18 $tr1->setRule('content matches "spurs"');
19 $tr1->setTags(array('sport'));
20 $tr1->setConfig($this->getReference('admin-config'));
21
22 $manager->persist($tr1);
23
24 $tr2 = new TaggingRule();
25 $tr2->setRule('content matches "basket"');
26 $tr2->setTags(array('sport'));
27 $tr2->setConfig($this->getReference('admin-config'));
28
29 $manager->persist($tr2);
30
31 $manager->flush();
32 }
33
34 /**
35 * {@inheritdoc}
36 */
37 public function getOrder()
38 {
39 return 40;
40 }
41}