Completed
Push — master ( af42de...cc6223 )
by Florian
17s queued 11s
created

BaseDoctrineController   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 9
dl 0
loc 28
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A fastSave() 0 7 2
A fastRemove() 0 7 2
1
<?php
2
3
/*
4
 * This file is part of the feedback project.
5
 *
6
 * (c) Florian Moser <[email protected]>
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 App\Controller\Base;
13
14
use App\Entity\Base\BaseEntity;
15
16
class BaseDoctrineController extends BaseController
17
{
18
    /**
19
     * saves entity to database.
20
     *
21
     * @param BaseEntity[] $entities
22
     */
23
    protected function fastSave(...$entities)
24
    {
25
        $mgr = $this->getDoctrine()->getManager();
26
        foreach ($entities as $item) {
27
            $mgr->persist($item);
28
        }
29
        $mgr->flush();
30
    }
31
32
    /**
33
     * removes entity to database.
34
     *
35
     * @param BaseEntity[] $entities
36
     */
37
    protected function fastRemove(...$entities)
38
    {
39
        $mgr = $this->getDoctrine()->getManager();
40
        foreach ($entities as $item) {
41
            $mgr->remove($item);
42
        }
43
        $mgr->flush();
44
    }
45
}
46