GraphqlController   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
dl 0
loc 35
rs 10
c 1
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A indexAction() 0 11 1
A createResponse() 0 4 1
A createRequest() 0 6 1
1
<?php
2
3
/**
4
 * @license MIT, http://opensource.org/licenses/MIT
5
 * @copyright Aimeos (aimeos.org), 2015-2016
6
 * @package symfony
7
 * @subpackage Controller
8
 */
9
10
11
namespace Aimeos\ShopBundle\Controller;
12
13
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
14
use Symfony\Bridge\PsrHttpMessage\Factory\HttpFoundationFactory;
15
use Symfony\Bridge\PsrHttpMessage\Factory\PsrHttpFactory;
16
use Symfony\Component\HttpFoundation\Response;
17
use Symfony\Component\HttpFoundation\Request;
18
use Nyholm\Psr7\Factory\Psr17Factory;
19
20
21
/**
22
 * Aimeos controller for the /admin/{site}/graphql route
23
 *
24
 * @package symfony
25
 * @subpackage Controller
26
 */
27
class GraphqlController extends AbstractController
28
{
29
	/**
30
	 * Returns the initial HTML view for the admin interface.
31
	 *
32
	 * @param Request $request Symfony request object
33
	 * @return Response Generated HTML page for the admin interface
34
	 */
35
	public function indexAction( Request $request, \Twig\Environment $twig ) : \Symfony\Component\HttpFoundation\Response
36
	{
37
		$site = $request->get( 'site', 'default' );
38
		$lang = $request->get( 'locale', 'en' );
39
40
		$context = $this->container->get( 'aimeos.context' )->get( false, 'backend' );
41
		$context->setI18n( $this->container->get( 'aimeos.i18n' )->get( array( $lang, 'en' ) ) );
42
		$context->setLocale( $this->container->get( 'aimeos.locale' )->getBackend( $context, $site ) );
43
		$context->setView( $this->container->get( 'aimeos.view' )->create( $context, [], $lang ) );
44
45
		return $this->createResponse( \Aimeos\Admin\Graphql::execute( $context, $this->createRequest( $request ) ) );
0 ignored issues
show
Bug introduced by
The type Aimeos\Admin\Graphql was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
46
	}
47
48
49
	protected function createRequest( Request $reqest ) : \Psr\Http\Message\RequestInterface
50
	{
51
		$psr17Factory = new Psr17Factory();
52
		$psrHttpFactory = new PsrHttpFactory( $psr17Factory, $psr17Factory, $psr17Factory, $psr17Factory );
53
54
		return $psrHttpFactory->createRequest( $reqest );
55
	}
56
57
58
	protected function createResponse( \Psr\Http\Message\ResponseInterface $response ) : Response
59
	{
60
		$httpFoundationFactory = new HttpFoundationFactory();
61
		return $httpFoundationFactory->createResponse( $response );
62
	}
63
}
64