Passed
Push — master ( d4aa98...d407e5 )
by Aimeos
03:02
created

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

Labels
Severity
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\Http\Request;
14
use Illuminate\Routing\Controller;
15
use Illuminate\Support\Facades\Auth;
16
use Illuminate\Support\Facades\Input;
17
use Illuminate\Support\Facades\Route;
18
use Illuminate\Support\Facades\View;
19
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
20
21
22
/**
23
 * Controller providing the ExtJS administration interface
24
 *
25
 * @package laravel
26
 * @subpackage Controller
27
 */
28
class AdminController extends Controller
29
{
30
	use AuthorizesRequests;
31
32
33
	/**
34
	 * Returns the initial HTML view for the admin interface.
35
	 *
36
	 * @param \Illuminate\Http\Request $request Laravel request object
37
	 * @return \Illuminate\Contracts\View\View View for rendering the output
38
	 */
39
	public function indexAction( Request $request )
40
	{
41
		if( Auth::check() === false
42
			|| $request->user()->can( 'admin', [AdminController::class, ['admin', 'editor']] ) === false
43
		) {
44
			return redirect()->guest( 'login' );
45
		}
46
47
		$siteId = $request->user()->siteid;
48
		$context = app( 'aimeos.context' )->get( false );
49
		$siteManager = \Aimeos\MShop::create( $context, 'locale/site' );
50
		$siteCode = ( $siteId ? $siteManager->getItem( $siteId )->getCode() : 'default' );
0 ignored issues
show
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

50
		$siteCode = ( $siteId ? $siteManager->getItem( $siteId )->/** @scrutinizer ignore-call */ getCode() : 'default' );
Loading history...
51
		$locale = $request->user()->langid ?: config( 'app.locale', 'en' );
52
53
		$param = array(
54
			'resource' => 'dashboard',
55
			'site' => Route::input( 'site', Input::get( 'site', $siteCode ) ),
56
			'lang' => Route::input( 'lang', Input::get( 'lang', $locale ) )
57
		);
58
59
		return redirect()->route( 'aimeos_shop_jqadm_search', $param );
60
	}
61
}
62