Completed
Push — config-virtualpages ( 3eb1c8...ab0f18 )
by Arnaud
02:10
created

DefaultPages::generate()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 19
rs 9.6333
c 0
b 0
f 0
cc 4
nc 3
nop 0
1
<?php
2
/*
3
 * Copyright (c) Arnaud Ligny <[email protected]>
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
9
namespace Cecil\Generator;
10
11
use Cecil\Collection\Page\Page;
12
use Cecil\Collection\Page\Type;
13
use Cecil\Exception\Exception;
14
15
/**
16
 * Class DefaultPages.
17
 */
18
class DefaultPages extends AbstractGenerator implements GeneratorInterface
19
{
20
    /**
21
     * {@inheritdoc}
22
     */
23
    public function generate(): void
24
    {
25
        $defaultpages = $this->config->get('defaultpages');
26
27
        // DEBUG
28
        //var_dump($defaultpages);
29
        //die();
30
31
        foreach ($defaultpages as $path => $frontmatter) {
32
            if (isset($frontmatter['published']) && $frontmatter['published'] === false) {
33
                continue;
34
            }
35
            $page = (new Page(Page::slugify($path)))
36
                ->setPath(Page::slugify($path))
37
                ->setType(Type::PAGE);
38
            $page->setVariables($frontmatter);
39
            $this->generatedPages->add($page);
40
        }
41
    }
42
}
43