Passed
Push — master ( 48d2af...a4afe2 )
by Aimeos
11:39
created

AccountController   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 87
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 21
dl 0
loc 87
rs 10
c 0
b 0
f 0
wmc 7

6 Methods

Rating   Name   Duplication   Size   Complexity  
A profileComponentAction() 0 6 1
A historyComponentAction() 0 6 1
A favoriteComponentAction() 0 6 1
A downloadAction() 0 4 1
A watchComponentAction() 0 6 1
A indexAction() 0 12 2
1
<?php
2
3
/**
4
 * @license MIT, http://opensource.org/licenses/MIT
5
 * @copyright Aimeos (aimeos.org), 2014-2016
6
 * @package symfony
7
 * @subpackage Controller
8
 */
9
10
11
namespace Aimeos\ShopBundle\Controller;
12
13
use Symfony\Component\HttpFoundation\Response;
14
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
15
16
17
/**
18
 * Aimeos controller for account related functionality.
19
 *
20
 * @package symfony
21
 * @subpackage Controller
22
 */
23
class AccountController extends Controller
24
{
25
	/**
26
	 * Returns the html for the "My account" page.
27
	 *
28
	 * @return Response Response object containing the generated output
29
	 */
30
	public function indexAction() : Response
31
	{
32
		$params = [];
33
		$shop = $this->container->get( 'shop' );
34
35
		foreach( $this->container->getParameter( 'aimeos_shop.page' )['account-index'] as $name )
36
		{
37
			$params['aiheader'][$name] = $shop->get( $name )->getHeader();
38
			$params['aibody'][$name] = $shop->get( $name )->getBody();
39
		}
40
41
		return $this->render( '@AimeosShop/Account/index.html.twig', $params )->setPrivate()->setMaxAge( 300 );
42
	}
43
44
45
	/**
46
	 * Returns the html for the "My account" download page.
47
	 *
48
	 * @return Response Response object containing the generated output
49
	 */
50
	public function downloadAction() : Response
51
	{
52
		$response = $this->container->get( 'shop' )->get( 'account/download' )->getView()->response();
53
		return Response::create( (string) $response->getBody(), $response->getStatusCode(), $response->getHeaders() );
54
	}
55
56
57
	/**
58
	 * Returns the output of the account favorite component
59
	 *
60
	 * @return Response Response object containing the generated output
61
	 */
62
	public function favoriteComponentAction() : Response
63
	{
64
		$client = $this->container->get( 'shop' )->get( 'account/favorite' );
65
		$this->container->get( 'twig' )->addGlobal( 'aiheader', (string) $client->getHeader() );
66
67
		return new Response( (string) $client->getBody() );
68
	}
69
70
71
	/**
72
	 * Returns the output of the account history component
73
	 *
74
	 * @return Response Response object containing the generated output
75
	 */
76
	public function historyComponentAction() : Response
77
	{
78
		$client = $this->container->get( 'shop' )->get( 'account/history' );
79
		$this->container->get( 'twig' )->addGlobal( 'aiheader', (string) $client->getHeader() );
80
81
		return new Response( (string) $client->getBody() );
82
	}
83
84
85
	/**
86
	 * Returns the output of the account profile component
87
	 *
88
	 * @return Response Response object containing the generated output
89
	 */
90
	public function profileComponentAction() : Response
91
	{
92
		$client = $this->container->get( 'shop' )->get( 'account/profile' );
93
		$this->container->get( 'twig' )->addGlobal( 'aiheader', (string) $client->getHeader() );
94
95
		return new Response( (string) $client->getBody() );
96
	}
97
98
99
	/**
100
	 * Returns the output of the account watch component
101
	 *
102
	 * @return Response Response object containing the generated output
103
	 */
104
	public function watchComponentAction() : Response
105
	{
106
		$client = $this->container->get( 'shop' )->get( 'account/watch' );
107
		$this->container->get( 'twig' )->addGlobal( 'aiheader', (string) $client->getHeader() );
108
109
		return new Response( (string) $client->getBody() );
110
	}
111
}
112