SettingsPresenter::createComponentSettingsForm()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 3
Bugs 0 Features 1
Metric Value
c 3
b 0
f 1
dl 0
loc 9
ccs 5
cts 5
cp 1
rs 9.6666
cc 1
eloc 5
nc 1
nop 0
crap 1
1
<?php
2
3
/**
4
 * This file is part of the Deploy module for webcms2.
5
 * Copyright (c) @see LICENSE
6
 */
7
8
namespace AdminModule\DeployModule;
9
10
/**
11
 * Settings presenter of the deploy module.
12
 * 
13
 * @author Tomáš Voslař <tomas.voslar at webcook.cz>
14
 */
15
class SettingsPresenter extends BasePresenter
16
{
17
    /**
18
     * {@inheritdoc}
19
     */
20 1
    protected function startup() 
21
    {
22 1
		parent::startup();
23 1
    }
24
25
    /**
26
     * {@inheritdoc}
27
     */
28 1
    protected function beforeRender() 
29
    {
30 1
		parent::beforeRender();	
31 1
    }
32
	
33
    /**
34
     * Creates settings form component.
35
     * 
36
     * @return  \Nette\Application\UI\Form
37
     */
38 1
    public function createComponentSettingsForm()
39
    {
40 1
		$settings = array();
41
42 1
        $settings[] = $this->settings->get('Deploy script', 'deployModule', 'text', array());
43 1
        $settings[] = $this->settings->get('Deploy database script', 'deployModule', 'text', array());
44
45 1
		return $this->createSettingsForm($settings);
46
    }
47
	
48
    /**
49
     * Renders default template.
50
     * 
51
     * @param  int $idPage Id of the page.
52
     * 
53
     * @return void
54
     */
55 1
    public function renderDefault($idPage)
56
    {
57 1
		$this->reloadContent();
58
59 1
		$this->template->idPage = $idPage;
0 ignored issues
show
Documentation introduced by
The property $template is declared private in Nette\Application\UI\Control. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
60
    }
61
}