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

PageScannerController::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 1
b 0
f 0
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