Completed
Push — master ( b0734c...5d2c35 )
by Aimeos
03:40
created

Context::addData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 10
c 1
b 0
f 0
nc 1
nop 3
dl 0
loc 15
rs 9.9332
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2020
6
 * @package Client
7
 * @subpackage Html
8
 */
9
10
11
namespace Aimeos\Client\Html\Common\Decorator;
12
13
14
/**
15
 * Provides context data for html client decorators.
16
 *
17
 * @package Client
18
 * @subpackage Html
19
 */
20
class Context extends Base implements Iface
21
{
22
	/**
23
	 * Adds the data to the view object required by the templates
24
	 *
25
	 * @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output
26
	 * @param array &$tags Result array for the list of tags that are associated to the output
27
	 * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry)
28
	 * @return \Aimeos\MW\View\Iface The view object with the data required by the templates
29
	 * @since 2020.07
30
	 */
31
	public function addData( \Aimeos\MW\View\Iface $view, array &$tags = [], string &$expire = null ) : \Aimeos\MW\View\Iface
32
	{
33
		$context = $this->getContext();
34
		$locale = $context->getLocale();
35
36
		$view->assign( [
37
			'contextLanguage' => $locale->getLanguageId(),
38
			'contextCurrency' => $locale->getCurrencyId(),
39
			'contextSite' => $locale->getSiteItem()->getCode(),
40
			'contextSiteId' => $locale->getSiteId(),
41
			'contextUserId' => $context->getUserId(),
42
			'contextGroupIds' => $context->getGroupIds(),
43
		] );
44
45
		return $this->getClient()->addData( $view, $tags, $expire );
46
	}
47
}
48