1 | <?php |
||
8 | class TestHelperHtml |
||
9 | { |
||
10 | private static $aimeos; |
||
11 | private static $context = []; |
||
12 | |||
13 | |||
14 | public static function bootstrap() |
||
19 | } |
||
20 | |||
21 | |||
22 | public static function getContext( $site = 'unittest' ) |
||
29 | } |
||
30 | |||
31 | |||
32 | public static function getView( $site = 'unittest', \Aimeos\MW\Config\Iface $config = null ) |
||
33 | { |
||
34 | if( $config === null ) { |
||
35 | $config = self::getContext( $site )->getConfig(); |
||
36 | } |
||
37 | |||
38 | $view = new \Aimeos\MW\View\Standard( self::getHtmlTemplatePaths() ); |
||
39 | |||
40 | $trans = new \Aimeos\MW\Translation\None( 'de_DE' ); |
||
41 | $helper = new \Aimeos\MW\View\Helper\Translate\Standard( $view, $trans ); |
||
42 | $view->addHelper( 'translate', $helper ); |
||
43 | |||
44 | $helper = new \Aimeos\MW\View\Helper\Url\Standard( $view, 'http://baseurl' ); |
||
45 | $view->addHelper( 'url', $helper ); |
||
46 | |||
47 | $helper = new \Aimeos\MW\View\Helper\Number\Standard( $view, '.', '' ); |
||
48 | $view->addHelper( 'number', $helper ); |
||
49 | |||
50 | $helper = new \Aimeos\MW\View\Helper\Date\Standard( $view, 'Y-m-d' ); |
||
51 | $view->addHelper( 'date', $helper ); |
||
52 | |||
53 | $config = new \Aimeos\MW\Config\Decorator\Protect( $config, ['client', 'resource/fs/baseurl'] ); |
||
54 | $helper = new \Aimeos\MW\View\Helper\Config\Standard( $view, $config ); |
||
55 | $view->addHelper( 'config', $helper ); |
||
56 | |||
57 | $helper = new \Aimeos\MW\View\Helper\Csrf\Standard( $view, '_csrf_token', '_csrf_value' ); |
||
58 | $view->addHelper( 'csrf', $helper ); |
||
59 | |||
60 | $psr17Factory = new \Nyholm\Psr7\Factory\Psr17Factory(); |
||
61 | $helper = new \Aimeos\MW\View\Helper\Request\Standard( $view, $psr17Factory->createServerRequest( 'GET', 'https://aimeos.org' ) ); |
||
62 | $view->addHelper( 'request', $helper ); |
||
63 | |||
64 | $helper = new \Aimeos\MW\View\Helper\Response\Standard( $view, $psr17Factory->createResponse() ); |
||
65 | $view->addHelper( 'response', $helper ); |
||
66 | |||
67 | return $view; |
||
68 | } |
||
69 | |||
70 | |||
71 | public static function getHtmlTemplatePaths() |
||
72 | { |
||
73 | return self::getAimeos()->getCustomPaths( 'client/html/templates' ); |
||
74 | } |
||
75 | |||
76 | |||
77 | private static function getAimeos() |
||
78 | { |
||
79 | if( !isset( self::$aimeos ) ) |
||
80 | { |
||
81 | require_once 'Bootstrap.php'; |
||
82 | spl_autoload_register( 'Aimeos\\Bootstrap::autoload' ); |
||
83 | |||
84 | $extdir = dirname( dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) ); |
||
85 | self::$aimeos = new \Aimeos\Bootstrap( array( $extdir ), true ); |
||
86 | } |
||
87 | |||
88 | return self::$aimeos; |
||
89 | } |
||
90 | |||
91 | |||
92 | /** |
||
93 | * @param string $site |
||
94 | */ |
||
95 | private static function createContext( $site ) |
||
148 | } |
||
149 | } |
||
150 |