Completed
Push — master ( ec393a...539bbb )
by Aimeos
12:50
created

Symfony2::createUploadedFiles()   B

Complexity

Conditions 4
Paths 4

Size

Total Lines 24
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 1 Features 1
Metric Value
c 3
b 1
f 1
dl 0
loc 24
rs 8.6846
cc 4
eloc 13
nc 4
nop 1
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2014-2016
6
 * @package MW
7
 * @subpackage View
8
 */
9
10
11
namespace Aimeos\MW\View\Helper\Request;
12
13
14
/**
15
 * View helper class for retrieving data from Symfony2 requests.
16
 *
17
 * @package MW
18
 * @subpackage View
19
 */
20
class Symfony2
21
	extends \Aimeos\MW\View\Helper\Request\Standard
0 ignored issues
show
Coding Style introduced by
The extends keyword must be on the same line as the class name
Loading history...
Coding Style introduced by
Expected 0 spaces between "Standard" and comma; 1 found
Loading history...
22
	implements \Aimeos\MW\View\Helper\Request\Iface
0 ignored issues
show
Coding Style introduced by
The implements keyword must be on the same line as the class name
Loading history...
23
{
24
	private $request;
25
26
27
	/**
28
	 * Initializes the URL view helper.
29
	 *
30
	 * @param \Aimeos\MW\View\Iface $view View instance with registered view helpers
31
	 * @param \Symfony\Component\HttpFoundation\Request $request Symfony2 request object
32
	 */
33
	public function __construct( $view, \Symfony\Component\HttpFoundation\Request $request )
0 ignored issues
show
Bug introduced by
You have injected the Request via parameter $request. This is generally not recommended as there might be multiple instances during a request cycle (f.e. when using sub-requests). Instead, it is recommended to inject the RequestStack and retrieve the current request each time you need it via getCurrentRequest().
Loading history...
34
	{
35
		$this->request = $request;
36
37
		$factory = new \Symfony\Bridge\PsrHttpMessage\Factory\DiactorosFactory();
38
		$psr7request = $factory->createRequest( $request );
39
40
		parent::__construct( $view, $psr7request );
41
	}
42
43
44
	/**
45
	 * Returns the client IP address.
46
	 *
47
	 * @return string Client IP address
48
	 */
49
	public function getClientAddress()
50
	{
51
		return $this->request->getClientIp();
52
	}
53
54
55
	/**
56
	 * Returns the current page or route name
57
	 *
58
	 * @return string|null Current page or route name
59
	 */
60
	public function getTarget()
61
	{
62
		return $this->request->get( '_route' );
63
	}
64
}
65