1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license MIT, http://opensource.org/licenses/MIT |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2015-2016 |
6
|
|
|
* @package laravel |
7
|
|
|
* @subpackage Base |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace Aimeos\Shop\Base; |
11
|
|
|
|
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Service providing the page object |
15
|
|
|
* |
16
|
|
|
* @package laravel |
17
|
|
|
* @subpackage Base |
18
|
|
|
*/ |
19
|
|
|
class Page |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @var \Illuminate\Contracts\Config\Repository |
23
|
|
|
*/ |
24
|
|
|
private $config; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @var \Aimeos\Shop\Base\Aimeos |
28
|
|
|
*/ |
29
|
|
|
private $aimeos; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var \Aimeos\Shop\Base\Context |
33
|
|
|
*/ |
34
|
|
|
private $context; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var \Aimeos\Shop\Base\Locale |
38
|
|
|
*/ |
39
|
|
|
private $locale; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var \Aimeos\Shop\Base\View |
43
|
|
|
*/ |
44
|
|
|
private $view; |
45
|
|
|
|
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Initializes the object |
49
|
|
|
* |
50
|
|
|
* @param \Illuminate\Contracts\Config\Repository $config Configuration object |
51
|
|
|
* @param \Aimeos\Shop\Base\Aimeos $aimeos Aimeos object |
52
|
|
|
* @param \Aimeos\Shop\Base\Context $context Context object |
53
|
|
|
* @param \Aimeos\Shop\Base\Locale $locale Locale object |
54
|
|
|
* @param \Aimeos\Shop\Base\View $view View object |
55
|
|
|
*/ |
56
|
|
|
public function __construct( \Illuminate\Contracts\Config\Repository $config, |
57
|
|
|
\Aimeos\Shop\Base\Aimeos $aimeos, \Aimeos\Shop\Base\Context $context, |
58
|
|
|
\Aimeos\Shop\Base\Locale $locale, \Aimeos\Shop\Base\View $view ) |
59
|
|
|
{ |
60
|
|
|
$this->config = $config; |
61
|
|
|
$this->aimeos = $aimeos; |
62
|
|
|
$this->context = $context; |
63
|
|
|
$this->locale = $locale; |
64
|
|
|
$this->view = $view; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Returns the body and header sections created by the clients configured for the given page name. |
70
|
|
|
* |
71
|
|
|
* @param string $pageName Name of the configured page |
72
|
|
|
* @return array Associative list with body and header output separated by client name |
73
|
|
|
*/ |
74
|
|
|
public function getSections( $pageName ) |
75
|
|
|
{ |
76
|
|
|
$context = $this->context->get(); |
77
|
|
|
$langid = $context->getLocale()->getLanguageId(); |
78
|
|
|
$tmplPaths = $this->aimeos->get()->getCustomPaths( 'client/html/templates' ); |
79
|
|
|
$view = $this->view->create( $context, $tmplPaths, $langid ); |
80
|
|
|
$context->setView( $view ); |
81
|
|
|
|
82
|
|
|
$result = array( 'aibody' => array(), 'aiheader' => array() ); |
83
|
|
|
$page = $context->getConfig()->get( 'page/' . $pageName, array() ); |
84
|
|
|
|
85
|
|
|
foreach( (array) $page as $clientName ) |
86
|
|
|
{ |
87
|
|
|
$client = \Aimeos\Client\Html\Factory::createClient( $context, $tmplPaths, $clientName ); |
88
|
|
|
$client->setView( clone $view ); |
89
|
|
|
$client->process(); |
90
|
|
|
|
91
|
|
|
$result['aibody'][$clientName] = $client->getBody(); |
92
|
|
|
$result['aiheader'][$clientName] = $client->getHeader(); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
return $result; |
96
|
|
|
} |
97
|
|
|
} |