BaseDoctrineController::fastSave()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 7
rs 10
cc 2
nc 2
nop 1
1
<?php
2
3
/*
4
 * This file is part of the TheAlternativeZurich/events 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();
0 ignored issues
show
Deprecated Code introduced by
The function Symfony\Bundle\Framework...ntroller::getDoctrine() has been deprecated: since Symfony 5.4, inject an instance of ManagerRegistry in your controller instead ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

25
        $mgr = /** @scrutinizer ignore-deprecated */ $this->getDoctrine()->getManager();

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
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();
0 ignored issues
show
Deprecated Code introduced by
The function Symfony\Bundle\Framework...ntroller::getDoctrine() has been deprecated: since Symfony 5.4, inject an instance of ManagerRegistry in your controller instead ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

39
        $mgr = /** @scrutinizer ignore-deprecated */ $this->getDoctrine()->getManager();

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
40
        foreach ($entities as $item) {
41
            $mgr->remove($item);
42
        }
43
        $mgr->flush();
44
    }
45
}
46