|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Zikula package. |
|
5
|
|
|
* |
|
6
|
|
|
* Copyright Zikula Foundation - http://zikula.org/ |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Zikula\ExtensionsModule\Entity\Repository; |
|
13
|
|
|
|
|
14
|
|
|
use Doctrine\ORM\EntityRepository; |
|
15
|
|
|
use Zikula\ExtensionsModule\Entity\ExtensionVarEntity; |
|
16
|
|
|
use Zikula\ExtensionsModule\Entity\RepositoryInterface\ExtensionVarRepositoryInterface; |
|
17
|
|
|
|
|
18
|
|
|
class ExtensionVarRepository extends EntityRepository implements ExtensionVarRepositoryInterface |
|
19
|
|
|
{ |
|
20
|
|
|
public function remove(ExtensionVarEntity $entity) |
|
21
|
|
|
{ |
|
22
|
|
|
$this->_em->remove($entity); |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
public function persistAndFlush(ExtensionVarEntity $entity) |
|
26
|
|
|
{ |
|
27
|
|
|
$this->_em->persist($entity); |
|
28
|
|
|
$this->_em->flush(); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
View Code Duplication |
public function deleteByExtensionAndName($extensionName, $variableName) |
|
|
|
|
|
|
32
|
|
|
{ |
|
33
|
|
|
$qb = $this->_em->createQueryBuilder() |
|
34
|
|
|
->delete('Zikula\ExtensionsModule\Entity\ExtensionVarEntity', 'v') |
|
35
|
|
|
->where('v.modname = :modname') |
|
36
|
|
|
->setParameter('modname', $extensionName) |
|
37
|
|
|
->andWhere('v.name = :name') |
|
38
|
|
|
->setParameter('name', $variableName); |
|
39
|
|
|
$query = $qb->getQuery(); |
|
40
|
|
|
$result = $query->execute(); |
|
41
|
|
|
|
|
42
|
|
|
return (bool)$result; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
View Code Duplication |
public function deleteByExtension($extensionName) |
|
|
|
|
|
|
46
|
|
|
{ |
|
47
|
|
|
$qb = $this->_em->createQueryBuilder() |
|
48
|
|
|
->delete('Zikula\ExtensionsModule\Entity\ExtensionVarEntity', 'v') |
|
49
|
|
|
->where('v.modname = :modname') |
|
50
|
|
|
->setParameter('modname', $extensionName); |
|
51
|
|
|
$query = $qb->getQuery(); |
|
52
|
|
|
$result = $query->execute(); |
|
53
|
|
|
|
|
54
|
|
|
return (bool)$result; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
View Code Duplication |
public function updateName($oldName, $newName) |
|
|
|
|
|
|
58
|
|
|
{ |
|
59
|
|
|
$query = $this->_em->createQueryBuilder() |
|
60
|
|
|
->update('Zikula\ExtensionsModule\Entity\ExtensionVarEntity', 'v') |
|
61
|
|
|
->set('v.modname', ':newname') |
|
62
|
|
|
->setParameter('newname', $newName) |
|
63
|
|
|
->where('v.modname = :oldname') |
|
64
|
|
|
->setParameter('oldname', $oldName) |
|
65
|
|
|
->getQuery(); |
|
66
|
|
|
$query->execute(); |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.