Completed
Push — master ( def7d9...4bce11 )
by Aimeos
01:54
created

Catalog::treeAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 4
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2016
6
 * @package Slim
7
 * @subpackage Controller
8
 */
9
10
namespace Aimeos\Slim\Controller;
11
12
use Interop\Container\ContainerInterface;
13
use Psr\Http\Message\ServerRequestInterface;
14
use Psr\Http\Message\ResponseInterface;
15
16
17
/**
18
 * Aimeos controller for catalog related functionality.
19
 *
20
 * @package Slim
21
 * @subpackage Controller
22
 */
23
class Catalog
24
{
25
	/**
26
	 * Returns the view for the XHR response with the counts for the facetted search.
27
	 *
28
	 * @param ContainerInterface $container Dependency injection container
29
	 * @param ServerRequestInterface $request Request object
30
	 * @param ResponseInterface $response Response object
31
	 * @param array $args Associative list of route parameters
32
	 * @return ResponseInterface $response Modified response object with generated output
33
	 */
34 View Code Duplication
	public static function countAction( ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args )
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
35
	{
36
		$contents = $container->get( 'shop' )->get( 'catalog-count', $request, $response, $args );
37
		$response = $container->get( 'view' )->render( $response, 'Catalog/count.html.twig', $contents );
38
39
		return $response->withHeader( 'Content-Type', 'application/javascript' )
40
			->withHeader( 'Cache-Control', 'max-age=300' );
41
	}
42
43
44
	/**
45
	 * Returns the html for the catalog detail page.
46
	 *
47
	 * @param ContainerInterface $container Dependency injection container
48
	 * @param ServerRequestInterface $request Request object
49
	 * @param ResponseInterface $response Response object
50
	 * @param array $args Associative list of route parameters
51
	 * @return ResponseInterface $response Modified response object with generated output
52
	 */
53
	public static function detailAction( ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args )
54
	{
55
		$contents = $container->get( 'shop' )->get( 'catalog-detail', $request, $response, $args );
56
		return $container->get( 'view' )->render( $response, 'Catalog/detail.html.twig', $contents );
57
	}
58
59
60
	/**
61
	 * Returns the html for the catalog list page.
62
	 *
63
	 * @param ContainerInterface $container Dependency injection container
64
	 * @param ServerRequestInterface $request Request object
65
	 * @param ResponseInterface $response Response object
66
	 * @param array $args Associative list of route parameters
67
	 * @return ResponseInterface $response Modified response object with generated output
68
	 */
69
	public static function listAction( ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args )
70
	{
71
		$contents = $container->get( 'shop' )->get( 'catalog-list', $request, $response, $args );
72
		return $container->get( 'view' )->render( $response, 'Catalog/list.html.twig', $contents );
73
	}
74
75
76
	/**
77
	 * Returns the html body part for the catalog stock page.
78
	 *
79
	 * @param ContainerInterface $container Dependency injection container
80
	 * @param ServerRequestInterface $request Request object
81
	 * @param ResponseInterface $response Response object
82
	 * @param array $args Associative list of route parameters
83
	 * @return ResponseInterface $response Modified response object with generated output
84
	 */
85 View Code Duplication
	public static function stockAction( ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args )
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
86
	{
87
		$contents = $container->get( 'shop' )->get( 'catalog-stock', $request, $response, $args );
88
		$response = $container->get( 'view' )->render( $response, 'Catalog/stock.html.twig', $contents );
89
90
		return $response->withHeader( 'Cache-Control', 'max-age=30' )
91
			->withHeader( 'Content-Type', 'application/javascript' );
92
	}
93
94
95
	/**
96
	 * Returns the view for the XHR response with the product information for the search suggestion.
97
	 *
98
	 * @param ContainerInterface $container Dependency injection container
99
	 * @param ServerRequestInterface $request Request object
100
	 * @param ResponseInterface $response Response object
101
	 * @param array $args Associative list of route parameters
102
	 * @return ResponseInterface $response Modified response object with generated output
103
	 */
104 View Code Duplication
	public static function suggestAction( ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args )
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
105
	{
106
		$contents = $container->get( 'shop' )->get( 'catalog-suggest', $request, $response, $args );
107
		$response = $container->get( 'view' )->render( $response, 'Catalog/suggest.html.twig', $contents );
108
109
		return $response->withHeader( 'Content-Type', 'application/json' );
110
	}
111
112
113
	/**
114
	 * Returns the html for the catalog list page.
115
	 *
116
	 * @param ContainerInterface $container Dependency injection container
117
	 * @param ServerRequestInterface $request Request object
118
	 * @param ResponseInterface $response Response object
119
	 * @param array $args Associative list of route parameters
120
	 * @return ResponseInterface $response Modified response object with generated output
121
	 */
122
	public static function treeAction( ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args )
123
	{
124
		$contents = $container->get( 'shop' )->get( 'catalog-tree', $request, $response, $args );
125
		return $container->get( 'view' )->render( $response, 'Catalog/tree.html.twig', $contents );
126
	}
127
}