DocumentFolderComponent   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 34
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A run() 0 6 1
A checkParameters() 0 8 3
1
<?php
2
/**
3
 * Created by jensk on 17-3-2017.
4
 */
5
6
namespace CloudControl\Cms\components;
7
8
9
use CloudControl\Cms\storage\Storage;
10
11
class DocumentFolderComponent extends CachableBaseComponent
12
{
13
    const PARAMETER_DOCUMENT_FOLDER_PATH = 'documentFolderPath';
14
    const PARAMETER_DOCUMENT_FOLDER_PARAMETER_NAME = 'documentFolderParameter';
15
16
    protected $documentFolderParameterName = 'folder';
17
    protected $documentFolderPath;
18
19
    /**
20
     * @param Storage $storage
21
     *
22
     * @return mixed|void
23
     * @throws \Exception
24
     */
25
    public function run(Storage $storage)
26
    {
27
        parent::run($storage);
28
29
        $this->checkParameters();
30
        $this->parameters[$this->documentFolderParameterName] = $this->storage->getDocuments()->getDocumentFolderBySlug($this->documentFolderPath);
31
    }
32
33
34
    /**
35
     * Checks to see if any parameters were defined in the cms and acts according
36
     */
37
    protected function checkParameters()
38
    {
39
        if (isset($this->parameters[self::PARAMETER_DOCUMENT_FOLDER_PATH])) {
40
            $this->documentFolderPath = $this->parameters[self::PARAMETER_DOCUMENT_FOLDER_PATH];
41
        }
42
43
        if (isset($this->parameters[self::PARAMETER_DOCUMENT_FOLDER_PARAMETER_NAME])) {
44
            $this->documentFolderParameterName = $this->parameters[self::PARAMETER_DOCUMENT_FOLDER_PARAMETER_NAME];
45
        }
46
    }
47
}