AdminController::indexAction()   A
last analyzed

Complexity

Conditions 5
Paths 3

Size

Total Lines 21
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 9
Bugs 0 Features 0
Metric Value
eloc 13
c 9
b 0
f 0
dl 0
loc 21
rs 9.5222
cc 5
nc 3
nop 1
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( 'login' );
44
		}
45
46
		$siteId = $request->user()->siteid;
47
		$context = app( 'aimeos.context' )->get( false );
48
		$siteManager = \Aimeos\MShop::create( $context, 'locale/site' );
49
		$siteCode = ( $siteId ? $siteManager->getItem( $siteId )->getCode() : 'default' );
0 ignored issues
show
Bug introduced by Andreas
The method getCode() does not exist on Aimeos\MShop\Common\Item\Iface. It seems like you code against a sub-type of Aimeos\MShop\Common\Item\Iface such as Aimeos\MShop\Product\Item\Iface or Aimeos\MShop\Service\Item\Iface or Aimeos\MShop\Locale\Item\Site\Iface or Aimeos\MShop\Customer\Item\Iface or Aimeos\MShop\Order\Item\Base\Service\Iface or Aimeos\MShop\Customer\Item\Group\Iface or Aimeos\MShop\Order\Item\Base\Coupon\Iface or Aimeos\MShop\Common\Item\Type\Iface or Aimeos\MShop\Attribute\Item\Iface or Aimeos\MShop\Locale\Item\Language\Iface or Aimeos\MShop\Order\Item\...Service\Attribute\Iface or Aimeos\MShop\Catalog\Item\Iface or Aimeos\MShop\Order\Item\...Product\Attribute\Iface or Aimeos\MShop\Coupon\Item\Code\Iface or Aimeos\MShop\Supplier\Item\Iface or Aimeos\MShop\Locale\Item\Currency\Iface or Aimeos\MShop\Attribute\Item\Standard or Aimeos\MShop\Catalog\Item\Standard or Aimeos\MShop\Customer\Item\Base or Aimeos\MShop\Customer\Item\Group\Standard or Aimeos\MShop\Common\Item\Type\Standard or Aimeos\MShop\Locale\Item\Site\Standard or Aimeos\MShop\Locale\Item\Currency\Standard or Aimeos\MShop\Locale\Item\Language\Standard or Aimeos\MShop\Order\Item\Base\Service\Base or Aimeos\MShop\Service\Item\Standard or Aimeos\MShop\Order\Item\Base\Coupon\Standard or Aimeos\MShop\Coupon\Item\Code\Standard or Aimeos\MShop\Order\Item\...vice\Attribute\Standard or Aimeos\MShop\Supplier\Item\Standard or Aimeos\MShop\Product\Item\Standard or Aimeos\MShop\Order\Item\...duct\Attribute\Standard or Aimeos\MShop\Product\Item\Iface or Aimeos\MShop\Service\Item\Iface or Aimeos\MShop\Customer\Item\Iface or Aimeos\MShop\Common\Item\Type\Iface or Aimeos\MShop\Attribute\Item\Iface or Aimeos\MShop\Locale\Item\Language\Iface or Aimeos\MShop\Common\Item\Tree\Iface or Aimeos\MShop\Supplier\Item\Iface or Aimeos\MShop\Locale\Item\Currency\Iface or Aimeos\MShop\Product\Item\Iface or Aimeos\MShop\Service\Item\Iface or Aimeos\MShop\Customer\Item\Iface or Aimeos\MShop\Attribute\Item\Iface or Aimeos\MShop\Catalog\Item\Iface or Aimeos\MShop\Supplier\Item\Iface or Aimeos\MShop\Product\Item\Iface or Aimeos\MShop\Customer\Item\Iface or Aimeos\MShop\Attribute\Item\Iface or Aimeos\MShop\Customer\Item\Iface or Aimeos\MShop\Supplier\Item\Iface. ( 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->getItem( $siteId )->/** @scrutinizer ignore-call */ getCode() : 'default' );
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
			'lang' => Route::input( 'lang', Request::get( 'lang', $locale ) )
56
		);
57
58
		return redirect()->route( 'aimeos_shop_jqadm_search', $param );
59
	}
60
}
61