Completed
Push — master ( 6130d0...57338d )
by Dev
24:32 queued 11:23
created

PageScannerController   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
dl 0
loc 25
rs 10
c 1
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A scanAction() 0 18 3
1
<?php
2
3
namespace PiedWeb\CMSBundle\Controller;
4
5
use PiedWeb\CMSBundle\Service\PageScannerService;
6
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
7
8
class PageScannerController extends AbstractController
9
{
10
    public function __construct(PageScannerService $scanner)
11
    {
12
        $this->scanner = $scanner;
0 ignored issues
show
Bug Best Practice introduced by
The property scanner does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
13
    }
14
15
    public function scanAction()
16
    {
17
        $pages = $this->getDoctrine()
18
            ->getRepository($this->container->getParameter('app.entity_page'))
19
            ->findAll();
20
21
        $errors = [];
22
23
        foreach ($pages as $page) {
24
            // todo import scanner via setScanner + services.yaml
25
            $scan = $this->scanner->scan($page);
26
            if (true !== $scan) {
27
                $errors = array_merge($errors, $scan);
28
            }
29
        }
30
31
        return $this->render('@PiedWebCMS/admin/scanView.html.twig', [
32
            'errors' => $errors,
33
        ]);
34
    }
35
}
36