Passed
Push — master ( a9bcb8...9eebd9 )
by Dāvis
02:45
created

TreeController::moveAction()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 17
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 11
nc 2
nop 4
dl 0
loc 17
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Sludio\HelperBundle\Position\Controller;
4
5
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
6
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
7
8
class TreeController extends Controller
9
{
10
    public function moveAction(Request $request, $class, $id, $position)
0 ignored issues
show
Bug introduced by
The type Sludio\HelperBundle\Position\Controller\Request was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
    {
12
        $entityManager = $this->getDoctrine()
13
            ->getManager($this->container->getParameter('sludio_helper.entity.manager'))
14
        ;
15
        $map = $this->container->getParameter('sludio_helper.position.field')['entities'];
16
        if (empty($map)) {
17
            throw new InvalidConfigurationException('Please configure sludio_helper.position.field.enties to use move functionality');
18
        }
19
        $class = $map[$class];
20
        $repo = $entityManager->getRepository($class);
21
        $object = $repo->findOneById($id);
22
        if ($object->getParent()) {
23
            $repo->{'move'.ucfirst($position)}($object);
24
        }
25
26
        return $this->redirect($request->headers->get('referer'));
27
    }
28
}
29