Issues (112)

src/Aimeos/Shop/Controller/AdminController.php (1 issue)

1
<?php
2
3
/**
4
 * @license MIT, http://opensource.org/licenses/MIT
5
 * @copyright Aimeos (aimeos.org), 2014-2016
6
 * @package laravel
7
 * @subpackage Controller
8
 */
9
10
11
namespace Aimeos\Shop\Controller;
12
13
use Illuminate\Routing\Controller;
14
use Illuminate\Support\Facades\Auth;
15
use Illuminate\Support\Facades\Request;
16
use Illuminate\Support\Facades\Route;
17
use Illuminate\Support\Facades\View;
18
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
19
20
21
/**
22
 * Controller providing the ExtJS administration interface
23
 *
24
 * @package laravel
25
 * @subpackage Controller
26
 */
27
class AdminController extends Controller
28
{
29
	use AuthorizesRequests;
30
31
32
	/**
33
	 * Returns the initial HTML view for the admin interface.
34
	 *
35
	 * @param \Illuminate\Http\Request $request Laravel request object
36
	 * @return \Illuminate\Contracts\View\View View for rendering the output
37
	 */
38
	public function indexAction( \Illuminate\Http\Request $request )
39
	{
40
		if( Auth::check() === false
41
			|| $request->user()->can( 'admin', [AdminController::class, ['admin', 'editor']] ) === false
42
		) {
43
			return redirect()->guest( route( 'login', app()->getLocale() ) );
44
		}
45
46
		$context = app( 'aimeos.context' )->get( false );
47
		$siteManager = \Aimeos\MShop::create( $context, 'locale/site' );
48
		$siteId = current( array_reverse( explode( '.', trim( $request->user()->siteid, '.' ) ) ) );
49
		$siteCode = ( $siteId ? $siteManager->get( $siteId )->getCode() : config( 'shop.mshop.locale.site', 'default' ) );
0 ignored issues
show
The call to config() has too many arguments starting with 'default'. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

49
		$siteCode = ( $siteId ? $siteManager->get( $siteId )->getCode() : /** @scrutinizer ignore-call */ config( 'shop.mshop.locale.site', 'default' ) );

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. Please note the @ignore annotation hint above.

Loading history...
50
		$locale = $request->user()->langid ?: config( 'app.locale', 'en' );
51
52
		$param = array(
53
			'resource' => 'dashboard',
54
			'site' => Route::input( 'site', Request::get( 'site', $siteCode ) ),
55
			'locale' => Route::input( 'locale', Request::get( 'locale', $locale ) )
56
		);
57
58
		return redirect()->route( 'aimeos_shop_jqadm_search', $param );
59
	}
60
}
61