CompanyPresenter::beforeRender()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 4
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/**
4
 * This file is part of the Investform module for webcms2.
5
 * Copyright (c) @see LICENSE
6
 */
7
8
namespace FrontendModule\InvestformModule;
9
10
use WebCMS\InvestformModule\Entity\Businessman;
11
12
13
/**
14
 * Description of InvestformPresenter
15
 *
16
 * @author Jakub Sanda <[email protected]>
17
 */
18 View Code Duplication
class CompanyPresenter extends BasePresenter
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
19
{
20
	private $id;
21
22
	private $businessman;
23
24
	/* \Nette\Http\Session */
25
	public $businessmanSession;
26
	
27
	protected function startup() 
28
    {
29
		parent::startup();
30
	}
31
32
	protected function beforeRender()
33
    {
34
		parent::beforeRender();	
35
	}
36
37
	public function actionDefault($id)
0 ignored issues
show
Unused Code introduced by
The parameter $id is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
38
    {	
39
		if (isset($_GET['bcode'])) {
40
			
41
			$this->businessman = $this->em->getRepository('\WebCMS\InvestformModule\Entity\Businessman')->findOneBy(array(
42
                'businessUrl' => $_GET['bcode']
43
            ));
44
45
			if ($this->businessman) {
46
	            $this->businessmanSession = $this->getSession('businessman');
47
				$this->businessmanSession->id = $this->businessman->getId();
48
49
				$this->flashMessage('Your business code has been saved.', 'success');
50
			} else {
51
				$this->flashMessage('Wrong business code.', 'error');
52
			}
53
54
		}
55
56
57
58
		$this->redirect(':Frontend:Homepage:');
59
	}
60
61
}
62