1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://www.gnu.org/copyleft/lgpl.html |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2015-2016 |
6
|
|
|
* @package flow |
7
|
|
|
* @subpackage Base |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
|
11
|
|
|
namespace Aimeos\Shop\Base; |
12
|
|
|
|
13
|
|
|
use Neos\Flow\Annotations as Flow; |
14
|
|
|
|
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Class providing the shop objects |
18
|
|
|
* |
19
|
|
|
* @package flow |
20
|
|
|
* @subpackage Base |
21
|
|
|
* @Flow\Scope("singleton") |
22
|
|
|
*/ |
23
|
|
|
class Shop |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* @var \Aimeos\Shop\Base\Aimeos |
27
|
|
|
* @Flow\Inject |
28
|
|
|
*/ |
29
|
|
|
protected $aimeos; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var \Aimeos\Shop\Base\Context |
33
|
|
|
* @Flow\Inject |
34
|
|
|
*/ |
35
|
|
|
protected $context; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @var \Aimeos\Shop\Base\View |
39
|
|
|
* @Flow\Inject |
40
|
|
|
*/ |
41
|
|
|
protected $view; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @var \Neos\Flow\Mvc\Routing\UriBuilder |
45
|
|
|
* @Flow\Inject |
46
|
|
|
*/ |
47
|
|
|
protected $uriBuilder; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @var array |
51
|
|
|
*/ |
52
|
|
|
private $settings; |
53
|
|
|
|
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Returns the body and header sections created by the clients configured for the given page name. |
57
|
|
|
* |
58
|
|
|
* @param \Neos\Flow\Mvc\RequestInterface $request Request object |
59
|
|
|
* @param string $pageName Name of the configured page |
60
|
|
|
* @return array Associative list with body and header output separated by client name |
61
|
|
|
*/ |
62
|
|
|
public function get( \Neos\Flow\Mvc\RequestInterface $request, $pageName ) |
63
|
|
|
{ |
64
|
|
|
$this->uriBuilder->setRequest( $request ); |
65
|
|
|
|
66
|
|
|
$tmplPaths = $this->aimeos->get()->getCustomPaths( 'client/html/templates' ); |
67
|
|
|
$pagesConfig = $this->settings['page']; |
68
|
|
|
$result = array( 'aibody' => array(), 'aiheader' => array() ); |
69
|
|
|
|
70
|
|
|
$context = $this->context->get( $request ); |
71
|
|
|
$langid = $context->getLocale()->getLanguageId(); |
72
|
|
|
$view = $this->view->create( $context, $this->uriBuilder, $tmplPaths, $request, $langid ); |
73
|
|
|
$context->setView( $view ); |
74
|
|
|
|
75
|
|
|
if( isset( $pagesConfig[$pageName] ) ) |
76
|
|
|
{ |
77
|
|
|
foreach( (array) $pagesConfig[$pageName] as $clientName ) |
78
|
|
|
{ |
79
|
|
|
$client = \Aimeos\Client\Html::create( $context, $clientName ); |
80
|
|
|
$client->setView( clone $view ); |
81
|
|
|
$client->process(); |
82
|
|
|
|
83
|
|
|
$varName = str_replace( '/', '_', $clientName ); |
84
|
|
|
|
85
|
|
|
$result['aibody'][$varName] = $client->getBody(); |
86
|
|
|
$result['aiheader'][$varName] = $client->getHeader(); |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
return $result; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* Inject the settings |
96
|
|
|
* |
97
|
|
|
* @param array $settings |
98
|
|
|
* @return void |
99
|
|
|
*/ |
100
|
|
|
public function injectSettings( array $settings ) |
101
|
|
|
{ |
102
|
|
|
$this->settings = $settings; |
103
|
|
|
} |
104
|
|
|
} |
105
|
|
|
|