@@ -31,21 +31,21 @@ discard block |
||
31 | 31 | /** |
32 | 32 | * {@inheritDoc} |
33 | 33 | */ |
34 | - public function load( array $configs, ContainerBuilder $container ) |
|
34 | + public function load(array $configs, ContainerBuilder $container) |
|
35 | 35 | { |
36 | 36 | $configuration = new Configuration(); |
37 | - $config = $this->processConfiguration( $configuration, $configs ); |
|
37 | + $config = $this->processConfiguration($configuration, $configs); |
|
38 | 38 | |
39 | - foreach( $configs as $list ) { |
|
40 | - $config = array_replace_recursive( $config, $list ); |
|
39 | + foreach ($configs as $list) { |
|
40 | + $config = array_replace_recursive($config, $list); |
|
41 | 41 | } |
42 | 42 | |
43 | - foreach( $config as $key => $value ) { |
|
44 | - $container->setParameter( 'aimeos_shop.' . $key, $value ); |
|
43 | + foreach ($config as $key => $value) { |
|
44 | + $container->setParameter('aimeos_shop.'.$key, $value); |
|
45 | 45 | } |
46 | 46 | |
47 | - $loader = new Loader\YamlFileLoader( $container, new FileLocator( dirname( __DIR__ ) . '/Resources/config' ) ); |
|
48 | - $loader->load( 'services.yml' ); |
|
47 | + $loader = new Loader\YamlFileLoader($container, new FileLocator(dirname(__DIR__).'/Resources/config')); |
|
48 | + $loader->load('services.yml'); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | |
@@ -54,12 +54,12 @@ discard block |
||
54 | 54 | * |
55 | 55 | * @param ContainerBuilder $container ContainerBuilder object |
56 | 56 | */ |
57 | - public function prepend( ContainerBuilder $container ) |
|
57 | + public function prepend(ContainerBuilder $container) |
|
58 | 58 | { |
59 | - $configFile = dirname( __DIR__ ) . '/Resources/config/aimeos_shop.yml'; |
|
60 | - $config = Yaml::parse( file_get_contents( $configFile ) ); |
|
59 | + $configFile = dirname(__DIR__).'/Resources/config/aimeos_shop.yml'; |
|
60 | + $config = Yaml::parse(file_get_contents($configFile)); |
|
61 | 61 | |
62 | - $container->prependExtensionConfig( 'aimeos_shop', $config ); |
|
63 | - $container->addResource( new FileResource( $configFile ) ); |
|
62 | + $container->prependExtensionConfig('aimeos_shop', $config); |
|
63 | + $container->addResource(new FileResource($configFile)); |
|
64 | 64 | } |
65 | 65 | } |
@@ -3,24 +3,24 @@ discard block |
||
3 | 3 | use Doctrine\Common\Annotations\AnnotationRegistry; |
4 | 4 | |
5 | 5 | |
6 | -setlocale( LC_ALL, 'en_US.UTF-8' ); |
|
6 | +setlocale(LC_ALL, 'en_US.UTF-8'); |
|
7 | 7 | |
8 | 8 | // if the bundle is within a symfony project, try to reuse the project's autoload |
9 | 9 | $files = array( |
10 | - __DIR__ . '/../vendor/autoload.php', |
|
11 | - __DIR__ . '/../../vendor/autoload.php', |
|
10 | + __DIR__.'/../vendor/autoload.php', |
|
11 | + __DIR__.'/../../vendor/autoload.php', |
|
12 | 12 | ); |
13 | 13 | |
14 | 14 | $autoload = false; |
15 | -foreach( $files as $file ) |
|
15 | +foreach ($files as $file) |
|
16 | 16 | { |
17 | - if( is_file( $file ) ) { |
|
17 | + if (is_file($file)) { |
|
18 | 18 | $autoload = require $file; |
19 | 19 | break; |
20 | 20 | } |
21 | 21 | } |
22 | 22 | |
23 | -if( !$autoload ) |
|
23 | +if (!$autoload) |
|
24 | 24 | { |
25 | 25 | exit( |
26 | 26 | "Unable to find autoload.php file, please use composer to load dependencies: |
@@ -30,4 +30,4 @@ discard block |
||
30 | 30 | ); |
31 | 31 | } |
32 | 32 | |
33 | -AnnotationRegistry::registerLoader( array( $autoload, 'loadClass' ) ); |
|
33 | +AnnotationRegistry::registerLoader(array($autoload, 'loadClass')); |
@@ -29,35 +29,35 @@ discard block |
||
29 | 29 | * @param $type File type, i.e. "css" or "js" |
30 | 30 | * @return Response Response object |
31 | 31 | */ |
32 | - public function fileAction( $type ) |
|
32 | + public function fileAction($type) |
|
33 | 33 | { |
34 | 34 | $contents = ''; |
35 | 35 | $files = array(); |
36 | - $aimeos = $this->get( 'aimeos' )->get(); |
|
36 | + $aimeos = $this->get('aimeos')->get(); |
|
37 | 37 | |
38 | - foreach( $aimeos->getCustomPaths( 'admin/jqadm' ) as $base => $paths ) |
|
38 | + foreach ($aimeos->getCustomPaths('admin/jqadm') as $base => $paths) |
|
39 | 39 | { |
40 | - foreach( $paths as $path ) |
|
40 | + foreach ($paths as $path) |
|
41 | 41 | { |
42 | - $jsbAbsPath = $base . '/' . $path; |
|
43 | - $jsb2 = new \Aimeos\MW\Jsb2\Standard( $jsbAbsPath, dirname( $jsbAbsPath ) ); |
|
44 | - $files = array_merge( $files, $jsb2->getFiles( $type ) ); |
|
42 | + $jsbAbsPath = $base.'/'.$path; |
|
43 | + $jsb2 = new \Aimeos\MW\Jsb2\Standard($jsbAbsPath, dirname($jsbAbsPath)); |
|
44 | + $files = array_merge($files, $jsb2->getFiles($type)); |
|
45 | 45 | } |
46 | 46 | } |
47 | 47 | |
48 | - foreach( $files as $file ) |
|
48 | + foreach ($files as $file) |
|
49 | 49 | { |
50 | - if( ( $content = file_get_contents( $file ) ) !== false ) { |
|
50 | + if (($content = file_get_contents($file)) !== false) { |
|
51 | 51 | $contents .= $content; |
52 | 52 | } |
53 | 53 | } |
54 | 54 | |
55 | - $response = new Response( $contents ); |
|
55 | + $response = new Response($contents); |
|
56 | 56 | |
57 | - if( $type === 'js' ) { |
|
58 | - $response->headers->set( 'Content-Type', 'application/javascript' ); |
|
59 | - } elseif( $type === 'css' ) { |
|
60 | - $response->headers->set( 'Content-Type', 'text/css' ); |
|
57 | + if ($type === 'js') { |
|
58 | + $response->headers->set('Content-Type', 'application/javascript'); |
|
59 | + } elseif ($type === 'css') { |
|
60 | + $response->headers->set('Content-Type', 'text/css'); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | return $response; |
@@ -72,10 +72,10 @@ discard block |
||
72 | 72 | * @param string $site Unique site code |
73 | 73 | * @return Response Generated output |
74 | 74 | */ |
75 | - public function copyAction( Request $request, $resource, $site = 'default' ) |
|
75 | + public function copyAction(Request $request, $resource, $site = 'default') |
|
76 | 76 | { |
77 | - $cntl = $this->createClient( $request, $site, $resource ); |
|
78 | - return $this->getHtml( $cntl->copy() ); |
|
77 | + $cntl = $this->createClient($request, $site, $resource); |
|
78 | + return $this->getHtml($cntl->copy()); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | |
@@ -87,10 +87,10 @@ discard block |
||
87 | 87 | * @param string $site Unique site code |
88 | 88 | * @return Response Generated output |
89 | 89 | */ |
90 | - public function createAction( Request $request, $resource, $site = 'default' ) |
|
90 | + public function createAction(Request $request, $resource, $site = 'default') |
|
91 | 91 | { |
92 | - $cntl = $this->createClient( $request, $site, $resource ); |
|
93 | - return $this->getHtml( $cntl->create() ); |
|
92 | + $cntl = $this->createClient($request, $site, $resource); |
|
93 | + return $this->getHtml($cntl->create()); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | |
@@ -102,10 +102,10 @@ discard block |
||
102 | 102 | * @param string $site Unique site code |
103 | 103 | * @return Response Generated output |
104 | 104 | */ |
105 | - public function deleteAction( Request $request, $resource, $site = 'default' ) |
|
105 | + public function deleteAction(Request $request, $resource, $site = 'default') |
|
106 | 106 | { |
107 | - $cntl = $this->createClient( $request, $site, $resource ); |
|
108 | - return $this->getHtml( $cntl->delete() . $cntl->search() ); |
|
107 | + $cntl = $this->createClient($request, $site, $resource); |
|
108 | + return $this->getHtml($cntl->delete().$cntl->search()); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | |
@@ -117,10 +117,10 @@ discard block |
||
117 | 117 | * @param string $site Unique site code |
118 | 118 | * @return Response Generated output |
119 | 119 | */ |
120 | - public function getAction( Request $request, $resource, $site = 'default' ) |
|
120 | + public function getAction(Request $request, $resource, $site = 'default') |
|
121 | 121 | { |
122 | - $cntl = $this->createClient( $request, $site, $resource ); |
|
123 | - return $this->getHtml( $cntl->get() ); |
|
122 | + $cntl = $this->createClient($request, $site, $resource); |
|
123 | + return $this->getHtml($cntl->get()); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | |
@@ -132,10 +132,10 @@ discard block |
||
132 | 132 | * @param string $site Unique site code |
133 | 133 | * @return Response Generated output |
134 | 134 | */ |
135 | - public function saveAction( Request $request, $resource, $site = 'default' ) |
|
135 | + public function saveAction(Request $request, $resource, $site = 'default') |
|
136 | 136 | { |
137 | - $cntl = $this->createClient( $request, $site, $resource ); |
|
138 | - return $this->getHtml( ( $cntl->save() ? : $cntl->search() ) ); |
|
137 | + $cntl = $this->createClient($request, $site, $resource); |
|
138 | + return $this->getHtml(($cntl->save() ?: $cntl->search())); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | |
@@ -147,10 +147,10 @@ discard block |
||
147 | 147 | * @param string $site Unique site code |
148 | 148 | * @return Response Generated output |
149 | 149 | */ |
150 | - public function searchAction( Request $request, $resource, $site = 'default' ) |
|
150 | + public function searchAction(Request $request, $resource, $site = 'default') |
|
151 | 151 | { |
152 | - $cntl = $this->createClient( $request, $site, $resource ); |
|
153 | - return $this->getHtml( $cntl->search() ); |
|
152 | + $cntl = $this->createClient($request, $site, $resource); |
|
153 | + return $this->getHtml($cntl->search()); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | |
@@ -162,21 +162,21 @@ discard block |
||
162 | 162 | * @param string $resource Resource location, e.g. "product" |
163 | 163 | * @return \Aimeos\Admin\JQAdm\Iface Context item |
164 | 164 | */ |
165 | - protected function createClient( Request $request, $site, $resource ) |
|
165 | + protected function createClient(Request $request, $site, $resource) |
|
166 | 166 | { |
167 | - $lang = $request->get( 'lang', 'en' ); |
|
167 | + $lang = $request->get('lang', 'en'); |
|
168 | 168 | |
169 | - $aimeos = $this->get( 'aimeos' )->get(); |
|
170 | - $templatePaths = $aimeos->getCustomPaths( 'admin/jqadm/templates' ); |
|
169 | + $aimeos = $this->get('aimeos')->get(); |
|
170 | + $templatePaths = $aimeos->getCustomPaths('admin/jqadm/templates'); |
|
171 | 171 | |
172 | - $context = $this->get( 'aimeos_context' )->get( false, 'backend' ); |
|
173 | - $context->setI18n( $this->get( 'aimeos_i18n' )->get( array( $lang, 'en' ) ) ); |
|
174 | - $context->setLocale( $this->get( 'aimeos_locale' )->getBackend( $context, $site ) ); |
|
172 | + $context = $this->get('aimeos_context')->get(false, 'backend'); |
|
173 | + $context->setI18n($this->get('aimeos_i18n')->get(array($lang, 'en'))); |
|
174 | + $context->setLocale($this->get('aimeos_locale')->getBackend($context, $site)); |
|
175 | 175 | |
176 | - $view = $this->get( 'aimeos_view' )->create( $context, $templatePaths, $lang ); |
|
177 | - $context->setView( $view ); |
|
176 | + $view = $this->get('aimeos_view')->create($context, $templatePaths, $lang); |
|
177 | + $context->setView($view); |
|
178 | 178 | |
179 | - return \Aimeos\Admin\JQAdm\Factory::createClient( $context, $templatePaths, $resource ); |
|
179 | + return \Aimeos\Admin\JQAdm\Factory::createClient($context, $templatePaths, $resource); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | |
@@ -186,12 +186,12 @@ discard block |
||
186 | 186 | * @param string $content Content from admin client |
187 | 187 | * @return Response View for rendering the output |
188 | 188 | */ |
189 | - protected function getHtml( $content ) |
|
189 | + protected function getHtml($content) |
|
190 | 190 | { |
191 | - $version = $this->get( 'aimeos' )->getVersion(); |
|
192 | - $extnames = implode( ',', $this->get( 'aimeos' )->get()->getExtensions() ); |
|
193 | - $content = str_replace( ['{type}', '{version}', '{extensions}'], ['Symfony', $version, $extnames], $content ); |
|
191 | + $version = $this->get('aimeos')->getVersion(); |
|
192 | + $extnames = implode(',', $this->get('aimeos')->get()->getExtensions()); |
|
193 | + $content = str_replace(['{type}', '{version}', '{extensions}'], ['Symfony', $version, $extnames], $content); |
|
194 | 194 | |
195 | - return $this->render( 'AimeosShopBundle:Jqadm:index.html.twig', array( 'content' => $content ) ); |
|
195 | + return $this->render('AimeosShopBundle:Jqadm:index.html.twig', array('content' => $content)); |
|
196 | 196 | } |
197 | 197 | } |
@@ -28,9 +28,9 @@ discard block |
||
28 | 28 | /** |
29 | 29 | * {@inheritdoc} |
30 | 30 | */ |
31 | - public function registerContainerConfiguration( LoaderInterface $loader ) |
|
31 | + public function registerContainerConfiguration(LoaderInterface $loader) |
|
32 | 32 | { |
33 | - $loader->load( __DIR__ . '/config/config.yml' ); |
|
33 | + $loader->load(__DIR__.'/config/config.yml'); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function getCacheDir() |
41 | 41 | { |
42 | - return sys_get_temp_dir() . '/aimeos-symfony/cache'; |
|
42 | + return sys_get_temp_dir().'/aimeos-symfony/cache'; |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | |
@@ -48,6 +48,6 @@ discard block |
||
48 | 48 | */ |
49 | 49 | public function getLogDir() |
50 | 50 | { |
51 | - return sys_get_temp_dir() . '/aimeos-symfony/logs'; |
|
51 | + return sys_get_temp_dir().'/aimeos-symfony/logs'; |
|
52 | 52 | } |
53 | 53 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | * |
30 | 30 | * @param Container $container Container object to access parameters |
31 | 31 | */ |
32 | - public function __construct( Container $container ) |
|
32 | + public function __construct(Container $container) |
|
33 | 33 | { |
34 | 34 | $this->container = $container; |
35 | 35 | } |
@@ -41,27 +41,27 @@ discard block |
||
41 | 41 | * @param array $languageIds List of two letter ISO language IDs |
42 | 42 | * @return \Aimeos\MW\Translation\Interface[] List of translation objects |
43 | 43 | */ |
44 | - public function get( array $languageIds ) |
|
44 | + public function get(array $languageIds) |
|
45 | 45 | { |
46 | - $i18nPaths = $this->container->get( 'aimeos' )->get()->getI18nPaths(); |
|
46 | + $i18nPaths = $this->container->get('aimeos')->get()->getI18nPaths(); |
|
47 | 47 | |
48 | - foreach( $languageIds as $langid ) |
|
48 | + foreach ($languageIds as $langid) |
|
49 | 49 | { |
50 | - if( !isset( $this->i18n[$langid] ) ) |
|
50 | + if (!isset($this->i18n[$langid])) |
|
51 | 51 | { |
52 | - $i18n = new \Aimeos\MW\Translation\Gettext( $i18nPaths, $langid ); |
|
52 | + $i18n = new \Aimeos\MW\Translation\Gettext($i18nPaths, $langid); |
|
53 | 53 | |
54 | - $apc = (bool) $this->container->getParameter( 'aimeos_shop.apc_enable' ); |
|
55 | - $prefix = $this->container->getParameter( 'aimeos_shop.apc_prefix' ); |
|
54 | + $apc = (bool) $this->container->getParameter('aimeos_shop.apc_enable'); |
|
55 | + $prefix = $this->container->getParameter('aimeos_shop.apc_prefix'); |
|
56 | 56 | |
57 | - if( function_exists( 'apcu_store' ) === true && $apc === true ) { |
|
58 | - $i18n = new \Aimeos\MW\Translation\Decorator\APC( $i18n, $prefix ); |
|
57 | + if (function_exists('apcu_store') === true && $apc === true) { |
|
58 | + $i18n = new \Aimeos\MW\Translation\Decorator\APC($i18n, $prefix); |
|
59 | 59 | } |
60 | 60 | |
61 | - $translations = $this->container->getParameter( 'aimeos_shop.i18n' ); |
|
61 | + $translations = $this->container->getParameter('aimeos_shop.i18n'); |
|
62 | 62 | |
63 | - if( isset( $translations[$langid] ) ) { |
|
64 | - $i18n = new \Aimeos\MW\Translation\Decorator\Memory( $i18n, $translations[$langid] ); |
|
63 | + if (isset($translations[$langid])) { |
|
64 | + $i18n = new \Aimeos\MW\Translation\Decorator\Memory($i18n, $translations[$langid]); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | $this->i18n[$langid] = $i18n; |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @param Container $container Container object to access parameters |
30 | 30 | */ |
31 | - public function __construct( Container $container ) |
|
31 | + public function __construct(Container $container) |
|
32 | 32 | { |
33 | 33 | $this->container = $container; |
34 | 34 | } |
@@ -40,33 +40,33 @@ discard block |
||
40 | 40 | * @param string $type Configuration type ("frontend" or "backend") |
41 | 41 | * @return \Aimeos\MW\Config\Iface Config object |
42 | 42 | */ |
43 | - public function get( $type = 'frontend' ) |
|
43 | + public function get($type = 'frontend') |
|
44 | 44 | { |
45 | 45 | $configPaths = $this->container->get('aimeos')->get()->getConfigPaths(); |
46 | 46 | |
47 | - $conf = new \Aimeos\MW\Config\PHPArray( array(), $configPaths ); |
|
47 | + $conf = new \Aimeos\MW\Config\PHPArray(array(), $configPaths); |
|
48 | 48 | |
49 | - $apc = (bool) $this->container->getParameter( 'aimeos_shop.apc_enable' ); |
|
50 | - $prefix = $this->container->getParameter( 'aimeos_shop.apc_prefix' ); |
|
49 | + $apc = (bool) $this->container->getParameter('aimeos_shop.apc_enable'); |
|
50 | + $prefix = $this->container->getParameter('aimeos_shop.apc_prefix'); |
|
51 | 51 | |
52 | - if( function_exists( 'apcu_store' ) === true && $apc === true ) { |
|
53 | - $conf = new \Aimeos\MW\Config\Decorator\APC( $conf, $prefix ); |
|
52 | + if (function_exists('apcu_store') === true && $apc === true) { |
|
53 | + $conf = new \Aimeos\MW\Config\Decorator\APC($conf, $prefix); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | $local = array( |
57 | - 'admin' => $this->container->getParameter( 'aimeos_shop.admin' ), |
|
58 | - 'client' => $this->container->getParameter( 'aimeos_shop.client' ), |
|
59 | - 'controller' => $this->container->getParameter( 'aimeos_shop.controller' ), |
|
60 | - 'madmin' => $this->container->getParameter( 'aimeos_shop.madmin' ), |
|
61 | - 'mshop' => $this->container->getParameter( 'aimeos_shop.mshop' ), |
|
62 | - 'resource' => $this->container->getParameter( 'aimeos_shop.resource' ), |
|
57 | + 'admin' => $this->container->getParameter('aimeos_shop.admin'), |
|
58 | + 'client' => $this->container->getParameter('aimeos_shop.client'), |
|
59 | + 'controller' => $this->container->getParameter('aimeos_shop.controller'), |
|
60 | + 'madmin' => $this->container->getParameter('aimeos_shop.madmin'), |
|
61 | + 'mshop' => $this->container->getParameter('aimeos_shop.mshop'), |
|
62 | + 'resource' => $this->container->getParameter('aimeos_shop.resource'), |
|
63 | 63 | ); |
64 | 64 | |
65 | - $config = new \Aimeos\MW\Config\Decorator\Memory( $conf, $local ); |
|
66 | - $settings = $this->container->getParameter( 'aimeos_shop.' . $type ); |
|
65 | + $config = new \Aimeos\MW\Config\Decorator\Memory($conf, $local); |
|
66 | + $settings = $this->container->getParameter('aimeos_shop.'.$type); |
|
67 | 67 | |
68 | - if( $settings !== array() ) { |
|
69 | - $config = new \Aimeos\MW\Config\Decorator\Memory( $config, $settings ); |
|
68 | + if ($settings !== array()) { |
|
69 | + $config = new \Aimeos\MW\Config\Decorator\Memory($config, $settings); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | return $config; |
@@ -31,9 +31,9 @@ discard block |
||
31 | 31 | * @param string Related resource location, e.g. "address" |
32 | 32 | * @return \Psr\Http\Message\ResponseInterface Response object containing the generated output |
33 | 33 | */ |
34 | - public function deleteAction( ServerRequestInterface $request, $resource, $related = '' ) |
|
34 | + public function deleteAction(ServerRequestInterface $request, $resource, $related = '') |
|
35 | 35 | { |
36 | - return $this->createClient( $resource, $related )->delete( $request, new Response() ); |
|
36 | + return $this->createClient($resource, $related)->delete($request, new Response()); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | |
@@ -45,9 +45,9 @@ discard block |
||
45 | 45 | * @param string Related resource location, e.g. "address" |
46 | 46 | * @return \Psr\Http\Message\ResponseInterface Response object containing the generated output |
47 | 47 | */ |
48 | - public function getAction( ServerRequestInterface $request, $resource, $related = '' ) |
|
48 | + public function getAction(ServerRequestInterface $request, $resource, $related = '') |
|
49 | 49 | { |
50 | - return $this->createClient( $resource, $related )->get( $request, new Response() ); |
|
50 | + return $this->createClient($resource, $related)->get($request, new Response()); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | |
@@ -59,9 +59,9 @@ discard block |
||
59 | 59 | * @param string Related resource location, e.g. "address" |
60 | 60 | * @return \Psr\Http\Message\ResponseInterface Response object containing the generated output |
61 | 61 | */ |
62 | - public function patchAction( ServerRequestInterface $request, $resource, $related = '' ) |
|
62 | + public function patchAction(ServerRequestInterface $request, $resource, $related = '') |
|
63 | 63 | { |
64 | - return $this->createClient( $resource, $related )->patch( $request, new Response() ); |
|
64 | + return $this->createClient($resource, $related)->patch($request, new Response()); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | |
@@ -73,9 +73,9 @@ discard block |
||
73 | 73 | * @param string Related resource location, e.g. "address" |
74 | 74 | * @return \Psr\Http\Message\ResponseInterface Response object containing the generated output |
75 | 75 | */ |
76 | - public function postAction( ServerRequestInterface $request, $resource, $related = '' ) |
|
76 | + public function postAction(ServerRequestInterface $request, $resource, $related = '') |
|
77 | 77 | { |
78 | - return $this->createClient( $resource, $related )->post( $request, new Response() ); |
|
78 | + return $this->createClient($resource, $related)->post($request, new Response()); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | |
@@ -87,9 +87,9 @@ discard block |
||
87 | 87 | * @param string Related resource location, e.g. "address" |
88 | 88 | * @return \Psr\Http\Message\ResponseInterface Response object containing the generated output |
89 | 89 | */ |
90 | - public function putAction( ServerRequestInterface $request, $resource, $related = '' ) |
|
90 | + public function putAction(ServerRequestInterface $request, $resource, $related = '') |
|
91 | 91 | { |
92 | - return $this->createClient( $resource, $related )->put( $request, new Response() ); |
|
92 | + return $this->createClient($resource, $related)->put($request, new Response()); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | |
@@ -100,9 +100,9 @@ discard block |
||
100 | 100 | * @param string Resource location, e.g. "customer" |
101 | 101 | * @return \Psr\Http\Message\ResponseInterface Response object containing the generated output |
102 | 102 | */ |
103 | - public function optionsAction( ServerRequestInterface $request, $resource = '' ) |
|
103 | + public function optionsAction(ServerRequestInterface $request, $resource = '') |
|
104 | 104 | { |
105 | - return $this->createClient( $resource )->options( $request, new Response() ); |
|
105 | + return $this->createClient($resource)->options($request, new Response()); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | |
@@ -113,15 +113,15 @@ discard block |
||
113 | 113 | * @param string Related resource location, e.g. "address" |
114 | 114 | * @return \Aimeos\Client\JsonApi\Iface JSON API client |
115 | 115 | */ |
116 | - protected function createClient( $resource, $related = '' ) |
|
116 | + protected function createClient($resource, $related = '') |
|
117 | 117 | { |
118 | - $tmplPaths = $this->container->get( 'aimeos' )->get()->getCustomPaths( 'client/jsonapi/templates' ); |
|
119 | - $context = $this->container->get( 'aimeos_context' )->get(); |
|
118 | + $tmplPaths = $this->container->get('aimeos')->get()->getCustomPaths('client/jsonapi/templates'); |
|
119 | + $context = $this->container->get('aimeos_context')->get(); |
|
120 | 120 | $langid = $context->getLocale()->getLanguageId(); |
121 | 121 | |
122 | - $view = $this->container->get( 'aimeos_view' )->create( $context, $tmplPaths, $langid ); |
|
123 | - $context->setView( $view ); |
|
122 | + $view = $this->container->get('aimeos_view')->create($context, $tmplPaths, $langid); |
|
123 | + $context->setView($view); |
|
124 | 124 | |
125 | - return \Aimeos\Client\JsonApi\Factory::createClient( $context, $tmplPaths, $resource . '/' . $related ); |
|
125 | + return \Aimeos\Client\JsonApi\Factory::createClient($context, $tmplPaths, $resource.'/'.$related); |
|
126 | 126 | } |
127 | 127 | } |
@@ -10,74 +10,74 @@ discard block |
||
10 | 10 | public function testOptionsAction() |
11 | 11 | { |
12 | 12 | $client = static::createClient(); |
13 | - $client->request( 'OPTIONS', '/unittest/de/EUR/jsonapi' ); |
|
13 | + $client->request('OPTIONS', '/unittest/de/EUR/jsonapi'); |
|
14 | 14 | $response = $client->getResponse(); |
15 | 15 | |
16 | - $json = json_decode( $response->getContent(), true ); |
|
16 | + $json = json_decode($response->getContent(), true); |
|
17 | 17 | |
18 | - $this->assertNotNull( $json ); |
|
19 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
20 | - $this->assertArrayHasKey( 'resources', $json['meta'] ); |
|
21 | - $this->assertGreaterThan( 1, count( $json['meta']['resources'] ) ); |
|
18 | + $this->assertNotNull($json); |
|
19 | + $this->assertEquals(200, $response->getStatusCode()); |
|
20 | + $this->assertArrayHasKey('resources', $json['meta']); |
|
21 | + $this->assertGreaterThan(1, count($json['meta']['resources'])); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | |
25 | 25 | public function testPutAction() |
26 | 26 | { |
27 | 27 | $client = static::createClient(); |
28 | - $client->request( 'PUT', '/unittest/de/EUR/jsonapi/basket' ); |
|
28 | + $client->request('PUT', '/unittest/de/EUR/jsonapi/basket'); |
|
29 | 29 | $response = $client->getResponse(); |
30 | 30 | |
31 | - $json = json_decode( $response->getContent(), true ); |
|
31 | + $json = json_decode($response->getContent(), true); |
|
32 | 32 | |
33 | - $this->assertNotNull( $json ); |
|
34 | - $this->assertEquals( 403, $response->getStatusCode() ); |
|
35 | - $this->assertArrayHasKey( 'errors', $json ); |
|
33 | + $this->assertNotNull($json); |
|
34 | + $this->assertEquals(403, $response->getStatusCode()); |
|
35 | + $this->assertArrayHasKey('errors', $json); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | |
39 | 39 | public function testGetAttributeAction() |
40 | 40 | { |
41 | 41 | $client = static::createClient(); |
42 | - $client->request( 'GET', '/unittest/de/EUR/jsonapi/attribute', [] ); |
|
42 | + $client->request('GET', '/unittest/de/EUR/jsonapi/attribute', []); |
|
43 | 43 | $response = $client->getResponse(); |
44 | 44 | |
45 | - $json = json_decode( $response->getContent(), true ); |
|
45 | + $json = json_decode($response->getContent(), true); |
|
46 | 46 | |
47 | - $this->assertNotNull( $json ); |
|
48 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
49 | - $this->assertEquals( 24, $json['meta']['total'] ); |
|
50 | - $this->assertEquals( 24, count( $json['data'] ) ); |
|
47 | + $this->assertNotNull($json); |
|
48 | + $this->assertEquals(200, $response->getStatusCode()); |
|
49 | + $this->assertEquals(24, $json['meta']['total']); |
|
50 | + $this->assertEquals(24, count($json['data'])); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | |
54 | 54 | public function testGetCatalogAction() |
55 | 55 | { |
56 | 56 | $client = static::createClient(); |
57 | - $client->request( 'GET', '/unittest/de/EUR/jsonapi/catalog', [] ); |
|
57 | + $client->request('GET', '/unittest/de/EUR/jsonapi/catalog', []); |
|
58 | 58 | $response = $client->getResponse(); |
59 | 59 | |
60 | - $json = json_decode( $response->getContent(), true ); |
|
60 | + $json = json_decode($response->getContent(), true); |
|
61 | 61 | |
62 | - $this->assertNotNull( $json ); |
|
63 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
64 | - $this->assertEquals( 1, $json['meta']['total'] ); |
|
65 | - $this->assertEquals( 4, count( $json['data'] ) ); |
|
62 | + $this->assertNotNull($json); |
|
63 | + $this->assertEquals(200, $response->getStatusCode()); |
|
64 | + $this->assertEquals(1, $json['meta']['total']); |
|
65 | + $this->assertEquals(4, count($json['data'])); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | |
69 | 69 | public function testGetLocaleAction() |
70 | 70 | { |
71 | 71 | $client = static::createClient(); |
72 | - $client->request( 'GET', '/unittest/de/EUR/jsonapi/locale', [] ); |
|
72 | + $client->request('GET', '/unittest/de/EUR/jsonapi/locale', []); |
|
73 | 73 | $response = $client->getResponse(); |
74 | 74 | |
75 | - $json = json_decode( $response->getContent(), true ); |
|
75 | + $json = json_decode($response->getContent(), true); |
|
76 | 76 | |
77 | - $this->assertNotNull( $json ); |
|
78 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
79 | - $this->assertEquals( 1, $json['meta']['total'] ); |
|
80 | - $this->assertEquals( 1, count( $json['data'] ) ); |
|
77 | + $this->assertNotNull($json); |
|
78 | + $this->assertEquals(200, $response->getStatusCode()); |
|
79 | + $this->assertEquals(1, $json['meta']['total']); |
|
80 | + $this->assertEquals(1, count($json['data'])); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | |
@@ -86,60 +86,60 @@ discard block |
||
86 | 86 | $client = static::createClient(); |
87 | 87 | |
88 | 88 | $params = ['filter' => ['f_search' => 'Cafe Noire Cap', 'f_listtype' => 'unittype19']]; |
89 | - $client->request( 'GET', '/unittest/de/EUR/jsonapi/product', $params ); |
|
89 | + $client->request('GET', '/unittest/de/EUR/jsonapi/product', $params); |
|
90 | 90 | $response = $client->getResponse(); |
91 | 91 | |
92 | - $json = json_decode( $response->getContent(), true ); |
|
92 | + $json = json_decode($response->getContent(), true); |
|
93 | 93 | |
94 | - $this->assertNotNull( $json ); |
|
95 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
96 | - $this->assertEquals( 1, $json['meta']['total'] ); |
|
97 | - $this->assertEquals( 1, count( $json['data'] ) ); |
|
98 | - $this->assertArrayHasKey( 'id', $json['data'][0] ); |
|
99 | - $this->assertEquals( 'CNC', $json['data'][0]['attributes']['product.code'] ); |
|
94 | + $this->assertNotNull($json); |
|
95 | + $this->assertEquals(200, $response->getStatusCode()); |
|
96 | + $this->assertEquals(1, $json['meta']['total']); |
|
97 | + $this->assertEquals(1, count($json['data'])); |
|
98 | + $this->assertArrayHasKey('id', $json['data'][0]); |
|
99 | + $this->assertEquals('CNC', $json['data'][0]['attributes']['product.code']); |
|
100 | 100 | |
101 | 101 | $id = $json['data'][0]['id']; |
102 | 102 | |
103 | - $client->request( 'GET', '/unittest/de/EUR/jsonapi/product/' . $id ); |
|
103 | + $client->request('GET', '/unittest/de/EUR/jsonapi/product/'.$id); |
|
104 | 104 | $response = $client->getResponse(); |
105 | 105 | |
106 | - $json = json_decode( $response->getContent(), true ); |
|
106 | + $json = json_decode($response->getContent(), true); |
|
107 | 107 | |
108 | - $this->assertNotNull( $json ); |
|
109 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
110 | - $this->assertEquals( 1, $json['meta']['total'] ); |
|
111 | - $this->assertArrayHasKey( 'id', $json['data'] ); |
|
112 | - $this->assertEquals( 'CNC', $json['data']['attributes']['product.code'] ); |
|
108 | + $this->assertNotNull($json); |
|
109 | + $this->assertEquals(200, $response->getStatusCode()); |
|
110 | + $this->assertEquals(1, $json['meta']['total']); |
|
111 | + $this->assertArrayHasKey('id', $json['data']); |
|
112 | + $this->assertEquals('CNC', $json['data']['attributes']['product.code']); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | |
116 | 116 | public function testGetServiceAction() |
117 | 117 | { |
118 | 118 | $client = static::createClient(); |
119 | - $client->request( 'GET', '/unittest/de/EUR/jsonapi/service', [] ); |
|
119 | + $client->request('GET', '/unittest/de/EUR/jsonapi/service', []); |
|
120 | 120 | $response = $client->getResponse(); |
121 | 121 | |
122 | - $json = json_decode( $response->getContent(), true ); |
|
122 | + $json = json_decode($response->getContent(), true); |
|
123 | 123 | |
124 | - $this->assertNotNull( $json ); |
|
125 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
126 | - $this->assertEquals( 4, $json['meta']['total'] ); |
|
127 | - $this->assertEquals( 4, count( $json['data'] ) ); |
|
124 | + $this->assertNotNull($json); |
|
125 | + $this->assertEquals(200, $response->getStatusCode()); |
|
126 | + $this->assertEquals(4, $json['meta']['total']); |
|
127 | + $this->assertEquals(4, count($json['data'])); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | |
131 | 131 | public function testGetStockAction() |
132 | 132 | { |
133 | 133 | $client = static::createClient(); |
134 | - $client->request( 'GET', '/unittest/de/EUR/jsonapi/stock', ['filter' => ['s_prodcode' => ['CNC', 'CNE']]] ); |
|
134 | + $client->request('GET', '/unittest/de/EUR/jsonapi/stock', ['filter' => ['s_prodcode' => ['CNC', 'CNE']]]); |
|
135 | 135 | $response = $client->getResponse(); |
136 | 136 | |
137 | - $json = json_decode( $response->getContent(), true ); |
|
137 | + $json = json_decode($response->getContent(), true); |
|
138 | 138 | |
139 | - $this->assertNotNull( $json ); |
|
140 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
141 | - $this->assertEquals( 2, $json['meta']['total'] ); |
|
142 | - $this->assertEquals( 2, count( $json['data'] ) ); |
|
139 | + $this->assertNotNull($json); |
|
140 | + $this->assertEquals(200, $response->getStatusCode()); |
|
141 | + $this->assertEquals(2, $json['meta']['total']); |
|
142 | + $this->assertEquals(2, count($json['data'])); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | |
@@ -147,24 +147,24 @@ discard block |
||
147 | 147 | { |
148 | 148 | $client = static::createClient(); |
149 | 149 | |
150 | - $client->request( 'OPTIONS', '/unittest/de/EUR/jsonapi' ); |
|
151 | - $optJson = json_decode( $client->getResponse()->getContent(), true ); |
|
152 | - $this->assertGreaterThan( 8, count( $optJson['meta']['resources'] ) ); |
|
150 | + $client->request('OPTIONS', '/unittest/de/EUR/jsonapi'); |
|
151 | + $optJson = json_decode($client->getResponse()->getContent(), true); |
|
152 | + $this->assertGreaterThan(8, count($optJson['meta']['resources'])); |
|
153 | 153 | |
154 | 154 | // catalog root |
155 | - $client->request( 'GET', $optJson['meta']['resources']['catalog'], ['include' => 'catalog'] ); |
|
156 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
157 | - $this->assertEquals( 'categories', $json['included'][0]['attributes']['catalog.code'] ); |
|
155 | + $client->request('GET', $optJson['meta']['resources']['catalog'], ['include' => 'catalog']); |
|
156 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
157 | + $this->assertEquals('categories', $json['included'][0]['attributes']['catalog.code']); |
|
158 | 158 | |
159 | 159 | // "categories" category |
160 | - $client->request( 'GET', $json['included'][0]['links']['self']['href'], ['include' => 'catalog'] ); |
|
161 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
162 | - $this->assertEquals( 'cafe', $json['included'][0]['attributes']['catalog.code'] ); |
|
160 | + $client->request('GET', $json['included'][0]['links']['self']['href'], ['include' => 'catalog']); |
|
161 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
162 | + $this->assertEquals('cafe', $json['included'][0]['attributes']['catalog.code']); |
|
163 | 163 | |
164 | 164 | // product list for "cafe" category |
165 | - $client->request( 'GET', $optJson['meta']['resources']['product'], ['f_catid' => $json['included'][0]['id']] ); |
|
166 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
167 | - $this->assertEquals( 'CNE', $json['data'][0]['attributes']['product.code'] ); |
|
165 | + $client->request('GET', $optJson['meta']['resources']['product'], ['f_catid' => $json['included'][0]['id']]); |
|
166 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
167 | + $this->assertEquals('CNE', $json['data'][0]['attributes']['product.code']); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | |
@@ -172,26 +172,26 @@ discard block |
||
172 | 172 | { |
173 | 173 | $client = static::createClient(); |
174 | 174 | |
175 | - $client->request( 'OPTIONS', '/unittest/de/EUR/jsonapi' ); |
|
176 | - $options = json_decode( $client->getResponse()->getContent(), true ); |
|
177 | - $this->assertGreaterThan( 8, count( $options['meta']['resources'] ) ); |
|
175 | + $client->request('OPTIONS', '/unittest/de/EUR/jsonapi'); |
|
176 | + $options = json_decode($client->getResponse()->getContent(), true); |
|
177 | + $this->assertGreaterThan(8, count($options['meta']['resources'])); |
|
178 | 178 | |
179 | 179 | // all available attrbutes |
180 | - $client->request( 'GET', $options['meta']['resources']['attribute'] ); |
|
181 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
180 | + $client->request('GET', $options['meta']['resources']['attribute']); |
|
181 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
182 | 182 | |
183 | - foreach( $json['data'] as $entry ) |
|
183 | + foreach ($json['data'] as $entry) |
|
184 | 184 | { |
185 | - if( $entry['attributes']['attribute.code'] === 'xl' ) |
|
185 | + if ($entry['attributes']['attribute.code'] === 'xl') |
|
186 | 186 | { |
187 | 187 | // products with attrbute "xl" |
188 | - $client->request( 'GET', $options['meta']['resources']['product'], ['filter' => ['f_attrid' => $entry['id']]] ); |
|
188 | + $client->request('GET', $options['meta']['resources']['product'], ['filter' => ['f_attrid' => $entry['id']]]); |
|
189 | 189 | break; |
190 | 190 | } |
191 | 191 | } |
192 | 192 | |
193 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
194 | - $this->assertEquals( 2, $json['meta']['total'] ); |
|
193 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
194 | + $this->assertEquals(2, $json['meta']['total']); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | |
@@ -199,14 +199,14 @@ discard block |
||
199 | 199 | { |
200 | 200 | $client = static::createClient(); |
201 | 201 | |
202 | - $client->request( 'OPTIONS', '/unittest/de/EUR/jsonapi' ); |
|
203 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
204 | - $this->assertGreaterThan( 8, count( $json['meta']['resources'] ) ); |
|
202 | + $client->request('OPTIONS', '/unittest/de/EUR/jsonapi'); |
|
203 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
204 | + $this->assertGreaterThan(8, count($json['meta']['resources'])); |
|
205 | 205 | |
206 | 206 | // product list for full text search |
207 | - $client->request( 'GET', $json['meta']['resources']['product'], ['filter' => ['f_search' => 'selection']] ); |
|
208 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
209 | - $this->assertEquals( 3, count( $json['data'] ) ); |
|
207 | + $client->request('GET', $json['meta']['resources']['product'], ['filter' => ['f_search' => 'selection']]); |
|
208 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
209 | + $this->assertEquals(3, count($json['data'])); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | |
@@ -214,23 +214,23 @@ discard block |
||
214 | 214 | { |
215 | 215 | $client = static::createClient(); |
216 | 216 | |
217 | - $client->request( 'OPTIONS', '/unittest/de/EUR/jsonapi' ); |
|
218 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
219 | - $this->assertGreaterThan( 8, count( $json['meta']['resources'] ) ); |
|
217 | + $client->request('OPTIONS', '/unittest/de/EUR/jsonapi'); |
|
218 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
219 | + $this->assertGreaterThan(8, count($json['meta']['resources'])); |
|
220 | 220 | |
221 | 221 | // get empty basket |
222 | - $client->request( 'GET', $json['meta']['resources']['basket'] ); |
|
223 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
224 | - $this->assertEquals( 'basket', $json['data']['type'] ); |
|
222 | + $client->request('GET', $json['meta']['resources']['basket']); |
|
223 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
224 | + $this->assertEquals('basket', $json['data']['type']); |
|
225 | 225 | |
226 | 226 | $content = '{"data": {"id": "delivery", "attributes": {"order.base.address.firstname": "test"}}}'; |
227 | - $client->request( 'POST', $json['links']['basket/address']['href'], [], [], [], $content ); |
|
228 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
229 | - $this->assertEquals( 'basket/address', $json['included'][0]['type'] ); |
|
227 | + $client->request('POST', $json['links']['basket/address']['href'], [], [], [], $content); |
|
228 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
229 | + $this->assertEquals('basket/address', $json['included'][0]['type']); |
|
230 | 230 | |
231 | - $client->request( 'DELETE', $json['included'][0]['links']['self']['href'] ); |
|
232 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
233 | - $this->assertEquals( 0, count( $json['included'] ) ); |
|
231 | + $client->request('DELETE', $json['included'][0]['links']['self']['href']); |
|
232 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
233 | + $this->assertEquals(0, count($json['included'])); |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | |
@@ -238,31 +238,31 @@ discard block |
||
238 | 238 | { |
239 | 239 | $client = static::createClient(); |
240 | 240 | |
241 | - $client->request( 'OPTIONS', '/unittest/de/EUR/jsonapi' ); |
|
242 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
243 | - $this->assertGreaterThan( 8, count( $json['meta']['resources'] ) ); |
|
241 | + $client->request('OPTIONS', '/unittest/de/EUR/jsonapi'); |
|
242 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
243 | + $this->assertGreaterThan(8, count($json['meta']['resources'])); |
|
244 | 244 | |
245 | 245 | // product for code "CNC" |
246 | - $client->request( 'GET', $json['meta']['resources']['product'], ['filter' => ['==' => ['product.code' => 'CNC']]] ); |
|
247 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
248 | - $this->assertEquals( 1, count( $json['data'] ) ); |
|
246 | + $client->request('GET', $json['meta']['resources']['product'], ['filter' => ['==' => ['product.code' => 'CNC']]]); |
|
247 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
248 | + $this->assertEquals(1, count($json['data'])); |
|
249 | 249 | |
250 | 250 | // add product "CNC" as prerequisite |
251 | - $content = '{"data": {"attributes": {"product.id": ' . $json['data'][0]['id'] . '}}}'; |
|
252 | - $client->request( 'POST', $json['data'][0]['links']['basket/product']['href'], [], [], [], $content ); |
|
253 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
254 | - $this->assertEquals( 'basket/product', $json['included'][0]['type'] ); |
|
251 | + $content = '{"data": {"attributes": {"product.id": '.$json['data'][0]['id'].'}}}'; |
|
252 | + $client->request('POST', $json['data'][0]['links']['basket/product']['href'], [], [], [], $content); |
|
253 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
254 | + $this->assertEquals('basket/product', $json['included'][0]['type']); |
|
255 | 255 | |
256 | 256 | // add coupon "GHIJ" |
257 | 257 | $content = '{"data": {"id": "GHIJ"}}'; |
258 | - $client->request( 'POST', $json['links']['basket/coupon']['href'], [], [], [], $content ); |
|
259 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
260 | - $this->assertEquals( 'basket/coupon', $json['included'][2]['type'] ); |
|
258 | + $client->request('POST', $json['links']['basket/coupon']['href'], [], [], [], $content); |
|
259 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
260 | + $this->assertEquals('basket/coupon', $json['included'][2]['type']); |
|
261 | 261 | |
262 | 262 | // remove coupon "GHIJ" again |
263 | - $client->request( 'DELETE', $json['included'][2]['links']['self']['href'] ); |
|
264 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
265 | - $this->assertEquals( 1, count( $json['included'] ) ); |
|
263 | + $client->request('DELETE', $json['included'][2]['links']['self']['href']); |
|
264 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
265 | + $this->assertEquals(1, count($json['included'])); |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | |
@@ -270,28 +270,28 @@ discard block |
||
270 | 270 | { |
271 | 271 | $client = static::createClient(); |
272 | 272 | |
273 | - $client->request( 'OPTIONS', '/unittest/de/EUR/jsonapi' ); |
|
274 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
275 | - $this->assertGreaterThan( 8, count( $json['meta']['resources'] ) ); |
|
273 | + $client->request('OPTIONS', '/unittest/de/EUR/jsonapi'); |
|
274 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
275 | + $this->assertGreaterThan(8, count($json['meta']['resources'])); |
|
276 | 276 | |
277 | 277 | // product for code "CNC" |
278 | - $client->request( 'GET', $json['meta']['resources']['product'], ['filter' => ['f_search' => 'ABCD']] ); |
|
279 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
280 | - $this->assertEquals( 1, count( $json['data'] ) ); |
|
278 | + $client->request('GET', $json['meta']['resources']['product'], ['filter' => ['f_search' => 'ABCD']]); |
|
279 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
280 | + $this->assertEquals(1, count($json['data'])); |
|
281 | 281 | |
282 | - $content = '{"data": {"attributes": {"product.id": ' . $json['data'][0]['id'] . '}}}'; |
|
283 | - $client->request( 'POST', $json['data'][0]['links']['basket/product']['href'], [], [], [], $content ); |
|
284 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
285 | - $this->assertEquals( 'basket/product', $json['included'][0]['type'] ); |
|
282 | + $content = '{"data": {"attributes": {"product.id": '.$json['data'][0]['id'].'}}}'; |
|
283 | + $client->request('POST', $json['data'][0]['links']['basket/product']['href'], [], [], [], $content); |
|
284 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
285 | + $this->assertEquals('basket/product', $json['included'][0]['type']); |
|
286 | 286 | |
287 | 287 | $content = '{"data": {"attributes": {"quantity": 2}}}'; |
288 | - $client->request( 'PATCH', $json['included'][0]['links']['self']['href'], [], [], [], $content ); |
|
289 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
290 | - $this->assertEquals( 2, $json['included'][0]['attributes']['order.base.product.quantity'] ); |
|
288 | + $client->request('PATCH', $json['included'][0]['links']['self']['href'], [], [], [], $content); |
|
289 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
290 | + $this->assertEquals(2, $json['included'][0]['attributes']['order.base.product.quantity']); |
|
291 | 291 | |
292 | - $client->request( 'DELETE', $json['included'][0]['links']['self']['href'] ); |
|
293 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
294 | - $this->assertEquals( 0, count( $json['included'] ) ); |
|
292 | + $client->request('DELETE', $json['included'][0]['links']['self']['href']); |
|
293 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
294 | + $this->assertEquals(0, count($json['included'])); |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | |
@@ -299,14 +299,14 @@ discard block |
||
299 | 299 | { |
300 | 300 | $client = static::createClient(); |
301 | 301 | |
302 | - $client->request( 'OPTIONS', '/unittest/de/EUR/jsonapi' ); |
|
303 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
304 | - $this->assertGreaterThan( 8, count( $json['meta']['resources'] ) ); |
|
302 | + $client->request('OPTIONS', '/unittest/de/EUR/jsonapi'); |
|
303 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
304 | + $this->assertGreaterThan(8, count($json['meta']['resources'])); |
|
305 | 305 | |
306 | 306 | // payment services |
307 | - $client->request( 'GET', $json['meta']['resources']['service'], ['filter' => ['cs_type' => 'payment']] ); |
|
308 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
309 | - $this->assertEquals( 3, count( $json['data'] ) ); |
|
307 | + $client->request('GET', $json['meta']['resources']['service'], ['filter' => ['cs_type' => 'payment']]); |
|
308 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
309 | + $this->assertEquals(3, count($json['data'])); |
|
310 | 310 | |
311 | 311 | $content = ['data' => ['id' => 'payment', 'attributes' => [ |
312 | 312 | 'service.id' => $json['data'][1]['id'], |
@@ -315,15 +315,15 @@ discard block |
||
315 | 315 | 'directdebit.bankcode' => 'ABCDEFGH', |
316 | 316 | 'directdebit.bankname' => 'test bank', |
317 | 317 | ]]]; |
318 | - $client->request( 'POST', $json['data'][1]['links']['basket/service']['href'], [], [], [], json_encode( $content ) ); |
|
319 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
320 | - $this->assertEquals( 'basket/service', $json['included'][0]['type'] ); |
|
321 | - $this->assertEquals( 'directdebit-test', $json['included'][0]['attributes']['order.base.service.code'] ); |
|
322 | - $this->assertEquals( 5, count( $json['included'][0]['attributes']['attribute'] ) ); |
|
323 | - |
|
324 | - $client->request( 'DELETE', $json['included'][0]['links']['self']['href'] ); |
|
325 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
326 | - $this->assertEquals( 0, count( $json['included'] ) ); |
|
318 | + $client->request('POST', $json['data'][1]['links']['basket/service']['href'], [], [], [], json_encode($content)); |
|
319 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
320 | + $this->assertEquals('basket/service', $json['included'][0]['type']); |
|
321 | + $this->assertEquals('directdebit-test', $json['included'][0]['attributes']['order.base.service.code']); |
|
322 | + $this->assertEquals(5, count($json['included'][0]['attributes']['attribute'])); |
|
323 | + |
|
324 | + $client->request('DELETE', $json['included'][0]['links']['self']['href']); |
|
325 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
326 | + $this->assertEquals(0, count($json['included'])); |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | |
@@ -332,17 +332,17 @@ discard block |
||
332 | 332 | $client = static::createClient(array(), array( |
333 | 333 | 'PHP_AUTH_USER' => 'UTC001', |
334 | 334 | 'PHP_AUTH_PW' => 'unittest', |
335 | - ) ); |
|
335 | + )); |
|
336 | 336 | |
337 | - $client->request( 'GET', '/unittest/de/EUR/jsonapi/customer', [] ); |
|
337 | + $client->request('GET', '/unittest/de/EUR/jsonapi/customer', []); |
|
338 | 338 | $response = $client->getResponse(); |
339 | 339 | |
340 | - $json = json_decode( $response->getContent(), true ); |
|
340 | + $json = json_decode($response->getContent(), true); |
|
341 | 341 | |
342 | - $this->assertNotNull( $json ); |
|
343 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
344 | - $this->assertEquals( 1, $json['meta']['total'] ); |
|
345 | - $this->assertEquals( 4, count( $json['data'] ) ); |
|
342 | + $this->assertNotNull($json); |
|
343 | + $this->assertEquals(200, $response->getStatusCode()); |
|
344 | + $this->assertEquals(1, $json['meta']['total']); |
|
345 | + $this->assertEquals(4, count($json['data'])); |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | |
@@ -351,22 +351,22 @@ discard block |
||
351 | 351 | $client = static::createClient(array(), array( |
352 | 352 | 'PHP_AUTH_USER' => 'UTC001', |
353 | 353 | 'PHP_AUTH_PW' => 'unittest', |
354 | - ) ); |
|
354 | + )); |
|
355 | 355 | |
356 | - $client->request( 'GET', '/unittest/de/EUR/jsonapi/customer', [] ); |
|
356 | + $client->request('GET', '/unittest/de/EUR/jsonapi/customer', []); |
|
357 | 357 | $response = $client->getResponse(); |
358 | 358 | |
359 | - $json = json_decode( $response->getContent(), true ); |
|
359 | + $json = json_decode($response->getContent(), true); |
|
360 | 360 | |
361 | - $client->request( 'GET', $json['links']['customer/address']['href'], [] ); |
|
361 | + $client->request('GET', $json['links']['customer/address']['href'], []); |
|
362 | 362 | $response = $client->getResponse(); |
363 | 363 | |
364 | - $json = json_decode( $response->getContent(), true ); |
|
364 | + $json = json_decode($response->getContent(), true); |
|
365 | 365 | |
366 | - $this->assertNotNull( $json ); |
|
367 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
368 | - $this->assertEquals( 1, $json['meta']['total'] ); |
|
369 | - $this->assertEquals( 1, count( $json['data'] ) ); |
|
366 | + $this->assertNotNull($json); |
|
367 | + $this->assertEquals(200, $response->getStatusCode()); |
|
368 | + $this->assertEquals(1, $json['meta']['total']); |
|
369 | + $this->assertEquals(1, count($json['data'])); |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | |
@@ -375,17 +375,17 @@ discard block |
||
375 | 375 | $client = static::createClient(array(), array( |
376 | 376 | 'PHP_AUTH_USER' => 'UTC001', |
377 | 377 | 'PHP_AUTH_PW' => 'unittest', |
378 | - ) ); |
|
378 | + )); |
|
379 | 379 | |
380 | - $client->request( 'GET', '/unittest/de/EUR/jsonapi/order', [] ); |
|
380 | + $client->request('GET', '/unittest/de/EUR/jsonapi/order', []); |
|
381 | 381 | $response = $client->getResponse(); |
382 | 382 | |
383 | - $json = json_decode( $response->getContent(), true ); |
|
383 | + $json = json_decode($response->getContent(), true); |
|
384 | 384 | |
385 | - $this->assertNotNull( $json ); |
|
386 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
387 | - $this->assertEquals( 5, $json['meta']['total'] ); |
|
388 | - $this->assertEquals( 5, count( $json['data'] ) ); |
|
385 | + $this->assertNotNull($json); |
|
386 | + $this->assertEquals(200, $response->getStatusCode()); |
|
387 | + $this->assertEquals(5, $json['meta']['total']); |
|
388 | + $this->assertEquals(5, count($json['data'])); |
|
389 | 389 | } |
390 | 390 | |
391 | 391 | |
@@ -393,63 +393,63 @@ discard block |
||
393 | 393 | { |
394 | 394 | $client = static::createClient(); |
395 | 395 | |
396 | - $client->request( 'OPTIONS', '/unittest/de/EUR/jsonapi' ); |
|
397 | - $optJson = json_decode( $client->getResponse()->getContent(), true ); |
|
398 | - $this->assertGreaterThan( 8, count( $optJson['meta']['resources'] ) ); |
|
396 | + $client->request('OPTIONS', '/unittest/de/EUR/jsonapi'); |
|
397 | + $optJson = json_decode($client->getResponse()->getContent(), true); |
|
398 | + $this->assertGreaterThan(8, count($optJson['meta']['resources'])); |
|
399 | 399 | |
400 | 400 | // product for code "CNC" |
401 | - $client->request( 'GET', $optJson['meta']['resources']['product'], ['filter' => ['==' => ['product.code' => 'CNC']]] ); |
|
402 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
403 | - $this->assertEquals( 1, count( $json['data'] ) ); |
|
401 | + $client->request('GET', $optJson['meta']['resources']['product'], ['filter' => ['==' => ['product.code' => 'CNC']]]); |
|
402 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
403 | + $this->assertEquals(1, count($json['data'])); |
|
404 | 404 | |
405 | 405 | // add product "CNC" |
406 | - $content = '{"data": {"attributes": {"product.id": ' . $json['data'][0]['id'] . '}}}'; |
|
407 | - $client->request( 'POST', $json['data'][0]['links']['basket/product']['href'], [], [], [], $content ); |
|
408 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
409 | - $this->assertEquals( 'basket/product', $json['included'][0]['type'] ); |
|
406 | + $content = '{"data": {"attributes": {"product.id": '.$json['data'][0]['id'].'}}}'; |
|
407 | + $client->request('POST', $json['data'][0]['links']['basket/product']['href'], [], [], [], $content); |
|
408 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
409 | + $this->assertEquals('basket/product', $json['included'][0]['type']); |
|
410 | 410 | |
411 | 411 | // delivery services |
412 | - $client->request( 'GET', $optJson['meta']['resources']['service'], ['filter' => ['cs_type' => 'delivery']] ); |
|
413 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
414 | - $this->assertEquals( 1, count( $json['data'] ) ); |
|
412 | + $client->request('GET', $optJson['meta']['resources']['service'], ['filter' => ['cs_type' => 'delivery']]); |
|
413 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
414 | + $this->assertEquals(1, count($json['data'])); |
|
415 | 415 | |
416 | 416 | // add delivery service |
417 | - $content = '{"data": {"id": "delivery", "attributes": {"service.id": ' . $json['data'][0]['id'] . '}}}'; |
|
418 | - $client->request( 'POST', $json['data'][0]['links']['basket/service']['href'], [], [], [], $content ); |
|
419 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
420 | - $this->assertEquals( 'basket/service', $json['included'][1]['type'] ); |
|
417 | + $content = '{"data": {"id": "delivery", "attributes": {"service.id": '.$json['data'][0]['id'].'}}}'; |
|
418 | + $client->request('POST', $json['data'][0]['links']['basket/service']['href'], [], [], [], $content); |
|
419 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
420 | + $this->assertEquals('basket/service', $json['included'][1]['type']); |
|
421 | 421 | |
422 | 422 | // payment services |
423 | - $client->request( 'GET', $optJson['meta']['resources']['service'], ['filter' => ['cs_type' => 'payment']] ); |
|
424 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
425 | - $this->assertEquals( 3, count( $json['data'] ) ); |
|
423 | + $client->request('GET', $optJson['meta']['resources']['service'], ['filter' => ['cs_type' => 'payment']]); |
|
424 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
425 | + $this->assertEquals(3, count($json['data'])); |
|
426 | 426 | |
427 | 427 | // add payment service |
428 | - $content = '{"data": {"id": "payment", "attributes": {"service.id": ' . $json['data'][0]['id'] . '}}}'; |
|
429 | - $client->request( 'POST', $json['data'][0]['links']['basket/service']['href'], [], [], [], $content ); |
|
430 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
431 | - $this->assertEquals( 'basket/service', $json['included'][2]['type'] ); |
|
428 | + $content = '{"data": {"id": "payment", "attributes": {"service.id": '.$json['data'][0]['id'].'}}}'; |
|
429 | + $client->request('POST', $json['data'][0]['links']['basket/service']['href'], [], [], [], $content); |
|
430 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
431 | + $this->assertEquals('basket/service', $json['included'][2]['type']); |
|
432 | 432 | |
433 | 433 | // add address |
434 | 434 | $content = '{"data": {"id": "payment", "attributes": {"order.base.address.firstname": "test"}}}'; |
435 | - $client->request( 'POST', $json['links']['basket/address']['href'], [], [], [], $content ); |
|
436 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
437 | - $this->assertEquals( 'basket/address', $json['included'][3]['type'] ); |
|
435 | + $client->request('POST', $json['links']['basket/address']['href'], [], [], [], $content); |
|
436 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
437 | + $this->assertEquals('basket/address', $json['included'][3]['type']); |
|
438 | 438 | |
439 | 439 | // store basket |
440 | - $client->request( 'POST', $json['data']['links']['self']['href'] ); |
|
441 | - $basketJson = json_decode( $client->getResponse()->getContent(), true ); |
|
442 | - $this->assertEquals( true, ctype_digit( $basketJson['data']['id'] ) ); |
|
440 | + $client->request('POST', $json['data']['links']['self']['href']); |
|
441 | + $basketJson = json_decode($client->getResponse()->getContent(), true); |
|
442 | + $this->assertEquals(true, ctype_digit($basketJson['data']['id'])); |
|
443 | 443 | |
444 | 444 | // add order |
445 | - $content = '{"data": {"attributes": {"order.baseid": ' . $basketJson['data']['id'] . '}}}'; |
|
446 | - $client->request( 'POST', $basketJson['links']['order']['href'], [], [], [], $content ); |
|
447 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
448 | - $this->assertEquals( true, ctype_digit( $json['data']['id'] ) ); |
|
445 | + $content = '{"data": {"attributes": {"order.baseid": '.$basketJson['data']['id'].'}}}'; |
|
446 | + $client->request('POST', $basketJson['links']['order']['href'], [], [], [], $content); |
|
447 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
448 | + $this->assertEquals(true, ctype_digit($json['data']['id'])); |
|
449 | 449 | |
450 | 450 | |
451 | 451 | // delete created order |
452 | - $context = static::$kernel->getContainer()->get( 'aimeos_context' )->get(); |
|
453 | - \Aimeos\MShop\Factory::createManager( $context, 'order/base' )->deleteItem( $basketJson['data']['id'] ); |
|
452 | + $context = static::$kernel->getContainer()->get('aimeos_context')->get(); |
|
453 | + \Aimeos\MShop\Factory::createManager($context, 'order/base')->deleteItem($basketJson['data']['id']); |
|
454 | 454 | } |
455 | 455 | } |
@@ -28,18 +28,18 @@ discard block |
||
28 | 28 | * @param Event $event Event instance |
29 | 29 | * @throws \RuntimeException If an error occured |
30 | 30 | */ |
31 | - public static function setupDatabase( Event $event ) |
|
31 | + public static function setupDatabase(Event $event) |
|
32 | 32 | { |
33 | 33 | $options = $env = array(); |
34 | 34 | |
35 | - if( $event->isDevMode() ) { |
|
35 | + if ($event->isDevMode()) { |
|
36 | 36 | $options[] = '--option=setup/default/demo:1'; |
37 | 37 | } else { |
38 | 38 | $env[] = '--env=prod'; |
39 | 39 | } |
40 | 40 | |
41 | - self::executeCommand( $event, 'aimeos:setup', $options + $env ); |
|
42 | - self::executeCommand( $event, 'aimeos:cache', $env ); |
|
41 | + self::executeCommand($event, 'aimeos:setup', $options + $env); |
|
42 | + self::executeCommand($event, 'aimeos:cache', $env); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | |
@@ -49,20 +49,20 @@ discard block |
||
49 | 49 | * @param Event $event Event instance |
50 | 50 | * @throws \RuntimeException If an error occured |
51 | 51 | */ |
52 | - public static function updateConfig( Event $event ) |
|
52 | + public static function updateConfig(Event $event) |
|
53 | 53 | { |
54 | - $event->getIO()->write( 'Ensure existing config and routing for the shop bundle' ); |
|
54 | + $event->getIO()->write('Ensure existing config and routing for the shop bundle'); |
|
55 | 55 | |
56 | - $options = self::getOptions( $event ); |
|
56 | + $options = self::getOptions($event); |
|
57 | 57 | |
58 | - if( !isset( $options['symfony-app-dir'] ) || !is_dir( $options['symfony-app-dir'] ) ) |
|
58 | + if (!isset($options['symfony-app-dir']) || !is_dir($options['symfony-app-dir'])) |
|
59 | 59 | { |
60 | 60 | $msg = 'An error occurred because the "%1$s" option or the "%2$s" directory isn\'t available'; |
61 | - throw new \RuntimeException( sprintf( $msg, 'symfony-app-dir', $options['symfony-app-dir'] ) ); |
|
61 | + throw new \RuntimeException(sprintf($msg, 'symfony-app-dir', $options['symfony-app-dir'])); |
|
62 | 62 | } |
63 | 63 | |
64 | - self::updateConfigFile( $options['symfony-app-dir'] . '/config/config.yml' ); |
|
65 | - self::updateRoutingFile( $options['symfony-app-dir'] . '/config/routing.yml' ); |
|
64 | + self::updateConfigFile($options['symfony-app-dir'].'/config/config.yml'); |
|
65 | + self::updateRoutingFile($options['symfony-app-dir'].'/config/routing.yml'); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | |
@@ -72,28 +72,28 @@ discard block |
||
72 | 72 | * @param Event $event Event instance |
73 | 73 | * @throws \RuntimeException If an error occured |
74 | 74 | */ |
75 | - public static function installBundle( Event $event ) |
|
75 | + public static function installBundle(Event $event) |
|
76 | 76 | { |
77 | - $event->getIO()->write( 'Installing the Aimeos shop bundle' ); |
|
77 | + $event->getIO()->write('Installing the Aimeos shop bundle'); |
|
78 | 78 | |
79 | - $options = self::getOptions( $event ); |
|
79 | + $options = self::getOptions($event); |
|
80 | 80 | |
81 | - if( !isset( $options['symfony-app-dir'] ) || !is_dir( $options['symfony-app-dir'] ) ) |
|
81 | + if (!isset($options['symfony-app-dir']) || !is_dir($options['symfony-app-dir'])) |
|
82 | 82 | { |
83 | 83 | $msg = 'An error occurred because the "%1$s" option or the "%2$s" directory isn\'t available'; |
84 | - throw new \RuntimeException( sprintf( $msg, 'symfony-app-dir', $options['symfony-app-dir'] ) ); |
|
84 | + throw new \RuntimeException(sprintf($msg, 'symfony-app-dir', $options['symfony-app-dir'])); |
|
85 | 85 | } |
86 | 86 | |
87 | - if( !isset( $options['symfony-web-dir'] ) || !is_dir( $options['symfony-web-dir'] ) ) |
|
87 | + if (!isset($options['symfony-web-dir']) || !is_dir($options['symfony-web-dir'])) |
|
88 | 88 | { |
89 | 89 | $msg = 'An error occurred because the "%1$s" option or the "%2$s" directory isn\'t available'; |
90 | - throw new \RuntimeException( sprintf( $msg, 'symfony-web-dir', $options['symfony-web-dir'] ) ); |
|
90 | + throw new \RuntimeException(sprintf($msg, 'symfony-web-dir', $options['symfony-web-dir'])); |
|
91 | 91 | } |
92 | 92 | |
93 | - self::createDirectory( $options['symfony-app-dir'] . '/secure' ); |
|
94 | - self::createDirectory( $options['symfony-web-dir'] . '/uploads' ); |
|
95 | - self::createDirectory( $options['symfony-web-dir'] . '/preview' ); |
|
96 | - self::createDirectory( $options['symfony-web-dir'] . '/files' ); |
|
93 | + self::createDirectory($options['symfony-app-dir'].'/secure'); |
|
94 | + self::createDirectory($options['symfony-web-dir'].'/uploads'); |
|
95 | + self::createDirectory($options['symfony-web-dir'].'/preview'); |
|
96 | + self::createDirectory($options['symfony-web-dir'].'/files'); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | |
@@ -103,14 +103,14 @@ discard block |
||
103 | 103 | * @param string $dir Absolute path of the new directory |
104 | 104 | * @throws \RuntimeException If directory couldn't be created |
105 | 105 | */ |
106 | - protected static function createDirectory( $dir ) |
|
106 | + protected static function createDirectory($dir) |
|
107 | 107 | { |
108 | 108 | $perm = 0755; |
109 | 109 | |
110 | - if( !is_dir( $dir ) && !mkdir( $dir, $perm, true ) ) |
|
110 | + if (!is_dir($dir) && !mkdir($dir, $perm, true)) |
|
111 | 111 | { |
112 | 112 | $msg = 'Unable to create directory "%1$s" with permission "%2$s"'; |
113 | - throw new \RuntimeException( sprintf( $msg, $dir, $perm ) ); |
|
113 | + throw new \RuntimeException(sprintf($msg, $dir, $perm)); |
|
114 | 114 | } |
115 | 115 | } |
116 | 116 | |
@@ -123,28 +123,28 @@ discard block |
||
123 | 123 | * @param array List of configuration options for the given command |
124 | 124 | * @throws \RuntimeException If the command couldn't be executed |
125 | 125 | */ |
126 | - protected static function executeCommand( Event $event, $cmd, array $options = array() ) |
|
126 | + protected static function executeCommand(Event $event, $cmd, array $options = array()) |
|
127 | 127 | { |
128 | - $php = escapeshellarg( self::getPhp() ); |
|
129 | - $console = escapeshellarg( self::getConsoleDir( $event ) . '/console' ); |
|
130 | - $cmd = escapeshellarg( $cmd ); |
|
128 | + $php = escapeshellarg(self::getPhp()); |
|
129 | + $console = escapeshellarg(self::getConsoleDir($event).'/console'); |
|
130 | + $cmd = escapeshellarg($cmd); |
|
131 | 131 | |
132 | - foreach( $options as $key => $option ) { |
|
133 | - $options[$key] = escapeshellarg( $option ); |
|
132 | + foreach ($options as $key => $option) { |
|
133 | + $options[$key] = escapeshellarg($option); |
|
134 | 134 | } |
135 | 135 | |
136 | - if( $event->getIO()->isDecorated() ) { |
|
136 | + if ($event->getIO()->isDecorated()) { |
|
137 | 137 | $console .= ' --ansi'; |
138 | 138 | } |
139 | 139 | |
140 | - $process = new Process( $php . ' ' . $console . ' ' . $cmd . ' ' . implode( ' ', $options ), null, null, null, 3600 ); |
|
140 | + $process = new Process($php.' '.$console.' '.$cmd.' '.implode(' ', $options), null, null, null, 3600); |
|
141 | 141 | |
142 | - $process->run( function( $type, $buffer ) use ( $event ) { |
|
143 | - $event->getIO()->write( $buffer, false ); |
|
142 | + $process->run(function($type, $buffer) use ($event) { |
|
143 | + $event->getIO()->write($buffer, false); |
|
144 | 144 | } ); |
145 | 145 | |
146 | - if( !$process->isSuccessful() ) { |
|
147 | - throw new \RuntimeException( sprintf( 'An error occurred when executing the "%s" command', escapeshellarg( $cmd ) ) ); |
|
146 | + if (!$process->isSuccessful()) { |
|
147 | + throw new \RuntimeException(sprintf('An error occurred when executing the "%s" command', escapeshellarg($cmd))); |
|
148 | 148 | } |
149 | 149 | } |
150 | 150 | |
@@ -157,19 +157,19 @@ discard block |
||
157 | 157 | * @return string The path to the console directory |
158 | 158 | * @throws \RuntimeException If console directory couldn't be found |
159 | 159 | */ |
160 | - protected static function getConsoleDir( Event $event ) |
|
160 | + protected static function getConsoleDir(Event $event) |
|
161 | 161 | { |
162 | - $options = self::getOptions( $event ); |
|
162 | + $options = self::getOptions($event); |
|
163 | 163 | |
164 | - if( isset( $options['symfony-bin-dir'] ) && is_dir( $options['symfony-bin-dir'] ) ) { |
|
164 | + if (isset($options['symfony-bin-dir']) && is_dir($options['symfony-bin-dir'])) { |
|
165 | 165 | return $options['symfony-bin-dir']; |
166 | 166 | } |
167 | 167 | |
168 | - if( isset( $options['symfony-app-dir'] ) && is_dir( $options['symfony-app-dir'] ) ) { |
|
168 | + if (isset($options['symfony-app-dir']) && is_dir($options['symfony-app-dir'])) { |
|
169 | 169 | return $options['symfony-app-dir']; |
170 | 170 | } |
171 | 171 | |
172 | - throw new \RuntimeException( sprintf( 'Console directory not found. Neither %1$s nor %2$s option exist', 'symfony-app-dir', 'symfony-bin-dir' ) ); |
|
172 | + throw new \RuntimeException(sprintf('Console directory not found. Neither %1$s nor %2$s option exist', 'symfony-app-dir', 'symfony-bin-dir')); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | * @param Event $event Command event object |
180 | 180 | * @return array Associative list of option keys and values |
181 | 181 | */ |
182 | - protected static function getOptions( Event $event ) |
|
182 | + protected static function getOptions(Event $event) |
|
183 | 183 | { |
184 | 184 | return $event->getComposer()->getPackage()->getExtra(); |
185 | 185 | } |
@@ -195,8 +195,8 @@ discard block |
||
195 | 195 | { |
196 | 196 | $phpFinder = new PhpExecutableFinder; |
197 | 197 | |
198 | - if( !( $phpPath = $phpFinder->find() ) ) { |
|
199 | - throw new \RuntimeException( 'The php executable could not be found, add it to your PATH environment variable and try again' ); |
|
198 | + if (!($phpPath = $phpFinder->find())) { |
|
199 | + throw new \RuntimeException('The php executable could not be found, add it to your PATH environment variable and try again'); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | return $phpPath; |
@@ -209,15 +209,15 @@ discard block |
||
209 | 209 | * @param string $filename Name of the YAML config file |
210 | 210 | * @throws \RuntimeException If file is not found |
211 | 211 | */ |
212 | - protected static function updateConfigFile( $filename ) |
|
212 | + protected static function updateConfigFile($filename) |
|
213 | 213 | { |
214 | - if( ( $content = file_get_contents( $filename ) ) === false ) { |
|
215 | - throw new \RuntimeException( sprintf( 'File "%1$s" not found', $filename ) ); |
|
214 | + if (($content = file_get_contents($filename)) === false) { |
|
215 | + throw new \RuntimeException(sprintf('File "%1$s" not found', $filename)); |
|
216 | 216 | } |
217 | 217 | |
218 | - if( self::addAsseticBundle( $content ) === true ) { |
|
218 | + if (self::addAsseticBundle($content) === true) { |
|
219 | 219 | $fs = new Filesystem(); |
220 | - $fs->dumpFile( $filename, $content ); |
|
220 | + $fs->dumpFile($filename, $content); |
|
221 | 221 | } |
222 | 222 | } |
223 | 223 | |
@@ -228,56 +228,56 @@ discard block |
||
228 | 228 | * @param string $filename Name of the YAML config file |
229 | 229 | * @throws \RuntimeException If file is not found |
230 | 230 | */ |
231 | - protected static function updateRoutingFile( $filename ) |
|
231 | + protected static function updateRoutingFile($filename) |
|
232 | 232 | { |
233 | - if( ( $content = file_get_contents( $filename ) ) === false ) { |
|
234 | - throw new \RuntimeException( sprintf( 'File "%1$s" not found', $filename ) ); |
|
233 | + if (($content = file_get_contents($filename)) === false) { |
|
234 | + throw new \RuntimeException(sprintf('File "%1$s" not found', $filename)); |
|
235 | 235 | } |
236 | 236 | |
237 | - if( strpos( $content, 'aimeos_shop:' ) === false ) |
|
237 | + if (strpos($content, 'aimeos_shop:') === false) |
|
238 | 238 | { |
239 | - $content .= "\n" . 'aimeos_shop: |
|
239 | + $content .= "\n".'aimeos_shop: |
|
240 | 240 | resource: "@AimeosShopBundle/Resources/config/routing.yml" |
241 | 241 | prefix: /'; |
242 | 242 | } |
243 | 243 | |
244 | - if( strpos( $content, 'aimeos_shop_adm:' ) === false ) |
|
244 | + if (strpos($content, 'aimeos_shop_adm:') === false) |
|
245 | 245 | { |
246 | - $content .= "\n" . 'aimeos_shop_adm: |
|
246 | + $content .= "\n".'aimeos_shop_adm: |
|
247 | 247 | resource: "@AimeosShopBundle/Resources/config/routing_adm.yml" |
248 | 248 | prefix: /'; |
249 | 249 | } |
250 | 250 | |
251 | - if( strpos( $content, 'aimeos_shop_extadm:' ) === false ) |
|
251 | + if (strpos($content, 'aimeos_shop_extadm:') === false) |
|
252 | 252 | { |
253 | - $content .= "\n" . 'aimeos_shop_extadm: |
|
253 | + $content .= "\n".'aimeos_shop_extadm: |
|
254 | 254 | resource: "@AimeosShopBundle/Resources/config/routing_extadm.yml" |
255 | 255 | prefix: /admin/{site}/extadm'; |
256 | 256 | } |
257 | 257 | |
258 | - if( strpos( $content, 'aimeos_shop_jqadm:' ) === false ) |
|
258 | + if (strpos($content, 'aimeos_shop_jqadm:') === false) |
|
259 | 259 | { |
260 | - $content .= "\n" . 'aimeos_shop_jqadm: |
|
260 | + $content .= "\n".'aimeos_shop_jqadm: |
|
261 | 261 | resource: "@AimeosShopBundle/Resources/config/routing_jqadm.yml" |
262 | 262 | prefix: /admin/{site}/jqadm'; |
263 | 263 | } |
264 | 264 | |
265 | - if( strpos( $content, 'aimeos_shop_jsonadm:' ) === false ) |
|
265 | + if (strpos($content, 'aimeos_shop_jsonadm:') === false) |
|
266 | 266 | { |
267 | - $content .= "\n" . 'aimeos_shop_jsonadm: |
|
267 | + $content .= "\n".'aimeos_shop_jsonadm: |
|
268 | 268 | resource: "@AimeosShopBundle/Resources/config/routing_jsonadm.yml" |
269 | 269 | prefix: /admin/{site}/jsonadm'; |
270 | 270 | } |
271 | 271 | |
272 | - if( strpos( $content, 'aimeos_shop_jsonapi:' ) === false ) |
|
272 | + if (strpos($content, 'aimeos_shop_jsonapi:') === false) |
|
273 | 273 | { |
274 | - $content .= "\n" . 'aimeos_shop_jsonapi: |
|
274 | + $content .= "\n".'aimeos_shop_jsonapi: |
|
275 | 275 | resource: "@AimeosShopBundle/Resources/config/routing_jsonapi.yml" |
276 | 276 | prefix: /jsonapi'; |
277 | 277 | } |
278 | 278 | |
279 | 279 | $fs = new Filesystem(); |
280 | - $fs->dumpFile( $filename, $content ); |
|
280 | + $fs->dumpFile($filename, $content); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | |
@@ -287,14 +287,14 @@ discard block |
||
287 | 287 | * @param string &$content Content of the config.yml file |
288 | 288 | * @return boolean True if modified, false if not |
289 | 289 | */ |
290 | - protected static function addAsseticBundle( &$content ) |
|
290 | + protected static function addAsseticBundle(&$content) |
|
291 | 291 | { |
292 | - if( preg_match( "/ bundles:[ ]*\[.*'AimeosShopBundle'.*\]/", $content ) !== 1 ) |
|
292 | + if (preg_match("/ bundles:[ ]*\[.*'AimeosShopBundle'.*\]/", $content) !== 1) |
|
293 | 293 | { |
294 | - $search = array( "/ bundles:[ ]*\[([^\]]+)\]/", "/ bundles:[ ]*\[([ ]*)\]/" ); |
|
295 | - $replace = array( " bundles: [$1,'AimeosShopBundle']", " bundles: ['AimeosShopBundle']" ); |
|
294 | + $search = array("/ bundles:[ ]*\[([^\]]+)\]/", "/ bundles:[ ]*\[([ ]*)\]/"); |
|
295 | + $replace = array(" bundles: [$1,'AimeosShopBundle']", " bundles: ['AimeosShopBundle']"); |
|
296 | 296 | |
297 | - if( ( $content = preg_replace( $search, $replace, $content ) ) !== null ) { |
|
297 | + if (($content = preg_replace($search, $replace, $content)) !== null) { |
|
298 | 298 | return true; |
299 | 299 | } |
300 | 300 | } |