1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license MIT, http://opensource.org/licenses/MIT |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2015 |
6
|
|
|
* @package laravel |
7
|
|
|
* @subpackage Base |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace Aimeos\Shop\Base; |
11
|
|
|
|
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Service providing the view objects |
15
|
|
|
* |
16
|
|
|
* @package laravel |
17
|
|
|
* @subpackage Base |
18
|
|
|
*/ |
19
|
|
|
class View |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* Creates the view object for the HTML client. |
23
|
|
|
* |
24
|
|
|
* @param \Aimeos\MW\Config\Iface $config Configuration object |
25
|
|
|
* @param array $templatePaths List of base path names with relative template paths as key/value pairs |
26
|
|
|
* @param string|null $locale Code of the current language or null for no translation |
27
|
|
|
* @return \Aimeos\MW\View\Iface View object |
28
|
|
|
*/ |
29
|
|
|
public function create( \Aimeos\MW\Config\Iface $config, array $templatePaths, $locale = null ) |
30
|
|
|
{ |
31
|
|
|
$params = $fixed = array(); |
32
|
|
|
|
33
|
|
|
if( $locale !== null ) |
34
|
|
|
{ |
35
|
|
|
$params = \Route::current()->parameters() + \Input::all(); |
36
|
|
|
$fixed = $this->getFixedParams(); |
37
|
|
|
|
38
|
|
|
$i18n = app('\Aimeos\Shop\Base\I18n')->get( array( $locale ) ); |
39
|
|
|
$translation = $i18n[$locale]; |
40
|
|
|
} |
41
|
|
|
else |
42
|
|
|
{ |
43
|
|
|
$translation = new \Aimeos\MW\Translation\None( 'en' ); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
|
47
|
|
|
$view = new \Aimeos\MW\View\Standard( $templatePaths ); |
|
|
|
|
48
|
|
|
|
49
|
|
|
$helper = new \Aimeos\MW\View\Helper\Translate\Standard( $view, $translation ); |
50
|
|
|
$view->addHelper( 'translate', $helper ); |
51
|
|
|
|
52
|
|
|
$helper = new \Aimeos\MW\View\Helper\Url\Laravel5( $view, app('url'), $fixed ); |
53
|
|
|
$view->addHelper( 'url', $helper ); |
54
|
|
|
|
55
|
|
|
$helper = new \Aimeos\MW\View\Helper\Param\Standard( $view, $params ); |
56
|
|
|
$view->addHelper( 'param', $helper ); |
57
|
|
|
|
58
|
|
|
$helper = new \Aimeos\MW\View\Helper\Config\Standard( $view, $config ); |
59
|
|
|
$view->addHelper( 'config', $helper ); |
60
|
|
|
|
61
|
|
|
$sepDec = $config->get( 'client/html/common/format/seperatorDecimal', '.' ); |
62
|
|
|
$sep1000 = $config->get( 'client/html/common/format/seperator1000', ' ' ); |
63
|
|
|
$helper = new \Aimeos\MW\View\Helper\Number\Standard( $view, $sepDec, $sep1000 ); |
64
|
|
|
$view->addHelper( 'number', $helper ); |
65
|
|
|
|
66
|
|
|
$helper = new \Aimeos\MW\View\Helper\Request\Laravel5( $view, \Request::instance() ); |
67
|
|
|
$view->addHelper( 'request', $helper ); |
68
|
|
|
|
69
|
|
|
$helper = new \Aimeos\MW\View\Helper\Csrf\Standard( $view, '_token', csrf_token() ); |
70
|
|
|
$view->addHelper( 'csrf', $helper ); |
71
|
|
|
|
72
|
|
|
return $view; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Returns the routing parameters passed in the URL |
78
|
|
|
* |
79
|
|
|
* @return array Associative list of parameters with "site", "locale" and "currency" if available |
80
|
|
|
*/ |
81
|
|
|
protected function getFixedParams() |
82
|
|
|
{ |
83
|
|
|
$fixed = array(); |
84
|
|
|
|
85
|
|
|
if( ( $value = \Route::input( 'site' ) ) !== null ) { |
86
|
|
|
$fixed['site'] = $value; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
if( ( $value = \Route::input( 'locale' ) ) !== null ) { |
90
|
|
|
$fixed['locale'] = $value; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
if( ( $value = \Route::input( 'currency' ) ) !== null ) { |
94
|
|
|
$fixed['currency'] = $value; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
return $fixed; |
98
|
|
|
} |
99
|
|
|
} |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.