Passed
Push — master ( 8bf70e...6a7093 )
by Aimeos
03:42
created

Standard::getSubClientNames()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2015-2022
6
 * @package Client
7
 * @subpackage Html
8
 */
9
10
11
namespace Aimeos\Client\Html\Catalog\Session\Seen;
12
13
14
/**
15
 * Default implementation of catalog session seen section for HTML clients.
16
 *
17
 * @package Client
18
 * @subpackage Html
19
 */
20
class Standard
21
	extends \Aimeos\Client\Html\Common\Client\Factory\Base
22
	implements \Aimeos\Client\Html\Common\Client\Factory\Iface
23
{
24
	/**
25
	 * Returns the HTML code for insertion into the body.
26
	 *
27
	 * @param string $uid Unique identifier for the output if the content is placed more than once on the same page
28
	 * @return string HTML code
29
	 */
30
	public function body( string $uid = '' ) : string
31
	{
32
		$view = $this->view();
33
		$context = $this->context();
34
		$session = $context->session();
35
36
		/** client/html/catalog/session/seen
37
		 * All parameters defined for the catalog session seen subpart
38
		 *
39
		 * This returns all settings related to the catalog session seen subpart.
40
		 * Please refer to the single settings for details.
41
		 *
42
		 * @param array Associative list of name/value settings
43
		 * @see client/html/catalog#session
44
		 */
45
		$config = $context->config()->get( 'client/html/catalog/session/seen', [] );
46
		$key = $this->getParamHash( [], $uid . ':catalog:session-seen-body', $config );
47
48
		if( ( $html = $session->get( $key ) ) === null )
49
		{
50
			/** client/html/catalog/session/seen/template-body
51
			 * Relative path to the HTML body template of the catalog session seen client.
52
			 *
53
			 * The template file contains the HTML code and processing instructions
54
			 * to generate the result shown in the body of the frontend. The
55
			 * configuration string is the path to the template file relative
56
			 * to the templates directory (usually in client/html/templates).
57
			 *
58
			 * You can overwrite the template file configuration in extensions and
59
			 * provide alternative templates. These alternative templates should be
60
			 * named like the default one but suffixed by
61
			 * an unique name. You may use the name of your project for this. If
62
			 * you've implemented an alternative client class as well, it
63
			 * should be suffixed by the name of the new class.
64
			 *
65
			 * @param string Relative path to the template creating code for the HTML page body
66
			 * @since 2014.03
67
			 * @see client/html/catalog/session/seen/template-header
68
			 */
69
			$tplconf = 'client/html/catalog/session/seen/template-body';
70
			$default = 'catalog/session/seen-body';
71
72
			$html = $view->render( $view->config( $tplconf, $default ) );
73
74
			$cached = $session->get( 'aimeos/catalog/session/seen/cache', [] ) + array( $key => true );
75
			$session->set( 'aimeos/catalog/session/seen/cache', $cached );
76
			$session->set( $key, $html );
77
		}
78
79
		$view->block()->set( 'catalog/session/seen', $html );
80
81
		return $html;
82
	}
83
84
85
	/**
86
	 * Sets the necessary parameter values in the view.
87
	 *
88
	 * @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output
89
	 * @param array &$tags Result array for the list of tags that are associated to the output
90
	 * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry)
91
	 * @return \Aimeos\MW\View\Iface Modified view object
92
	 */
93
	public function data( \Aimeos\MW\View\Iface $view, array &$tags = [], string &$expire = null ) : \Aimeos\MW\View\Iface
94
	{
95
		$session = $this->context()->session();
96
		$lastSeen = $session->get( 'aimeos/catalog/session/seen/list', [] );
97
98
		$view->seenItems = array_reverse( $lastSeen );
99
100
		return parent::data( $view, $tags, $expire );
101
	}
102
}
103