@@ -15,14 +15,14 @@ discard block |
||
15 | 15 | public static function bootstrap() |
16 | 16 | { |
17 | 17 | self::getAimeos(); |
18 | - \Aimeos\MShop\Factory::setCache( false ); |
|
18 | + \Aimeos\MShop\Factory::setCache(false); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | |
22 | - public static function getContext( $site = 'unittest' ) |
|
22 | + public static function getContext($site = 'unittest') |
|
23 | 23 | { |
24 | - if( !isset( self::$context[$site] ) ) { |
|
25 | - self::$context[$site] = self::createContext( $site ); |
|
24 | + if (!isset(self::$context[$site])) { |
|
25 | + self::$context[$site] = self::createContext($site); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | return clone self::$context[$site]; |
@@ -31,13 +31,13 @@ discard block |
||
31 | 31 | |
32 | 32 | public static function getAimeos() |
33 | 33 | { |
34 | - if( !isset( self::$aimeos ) ) |
|
34 | + if (!isset(self::$aimeos)) |
|
35 | 35 | { |
36 | 36 | require_once 'Bootstrap.php'; |
37 | - spl_autoload_register( 'Aimeos\\Bootstrap::autoload' ); |
|
37 | + spl_autoload_register('Aimeos\\Bootstrap::autoload'); |
|
38 | 38 | |
39 | - $extdir = dirname( dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) ); |
|
40 | - self::$aimeos = new \Aimeos\Bootstrap( array( $extdir ), true ); |
|
39 | + $extdir = dirname(dirname(dirname(dirname(dirname(__FILE__))))); |
|
40 | + self::$aimeos = new \Aimeos\Bootstrap(array($extdir), true); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | return self::$aimeos; |
@@ -46,93 +46,93 @@ discard block |
||
46 | 46 | |
47 | 47 | public static function getControllerPaths() |
48 | 48 | { |
49 | - return self::getAimeos()->getCustomPaths( 'controller/jobs' ); |
|
49 | + return self::getAimeos()->getCustomPaths('controller/jobs'); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | |
53 | 53 | /** |
54 | 54 | * @param string $site |
55 | 55 | */ |
56 | - private static function createContext( $site ) |
|
56 | + private static function createContext($site) |
|
57 | 57 | { |
58 | 58 | $ctx = new \Aimeos\MShop\Context\Item\Standard(); |
59 | 59 | $aimeos = self::getAimeos(); |
60 | 60 | |
61 | 61 | |
62 | - $paths = $aimeos->getConfigPaths( 'mysql' ); |
|
62 | + $paths = $aimeos->getConfigPaths('mysql'); |
|
63 | 63 | $paths[] = __DIR__ . DIRECTORY_SEPARATOR . 'config'; |
64 | 64 | $file = __DIR__ . DIRECTORY_SEPARATOR . 'confdoc.ser'; |
65 | 65 | |
66 | - $conf = new \Aimeos\MW\Config\PHPArray( [], $paths ); |
|
67 | - $conf = new \Aimeos\MW\Config\Decorator\Memory( $conf ); |
|
68 | - $conf = new \Aimeos\MW\Config\Decorator\Documentor( $conf, $file ); |
|
69 | - $ctx->setConfig( $conf ); |
|
66 | + $conf = new \Aimeos\MW\Config\PHPArray([], $paths); |
|
67 | + $conf = new \Aimeos\MW\Config\Decorator\Memory($conf); |
|
68 | + $conf = new \Aimeos\MW\Config\Decorator\Documentor($conf, $file); |
|
69 | + $ctx->setConfig($conf); |
|
70 | 70 | |
71 | 71 | |
72 | - $logger = new \Aimeos\MW\Logger\File( $site . '.log', \Aimeos\MW\Logger\Base::DEBUG ); |
|
73 | - $ctx->setLogger( $logger ); |
|
72 | + $logger = new \Aimeos\MW\Logger\File($site . '.log', \Aimeos\MW\Logger\Base::DEBUG); |
|
73 | + $ctx->setLogger($logger); |
|
74 | 74 | |
75 | 75 | |
76 | - $dbm = new \Aimeos\MW\DB\Manager\PDO( $conf ); |
|
77 | - $ctx->setDatabaseManager( $dbm ); |
|
76 | + $dbm = new \Aimeos\MW\DB\Manager\PDO($conf); |
|
77 | + $ctx->setDatabaseManager($dbm); |
|
78 | 78 | |
79 | 79 | |
80 | - $fs = new \Aimeos\MW\Filesystem\Manager\Standard( $conf ); |
|
81 | - $ctx->setFilesystemManager( $fs ); |
|
80 | + $fs = new \Aimeos\MW\Filesystem\Manager\Standard($conf); |
|
81 | + $ctx->setFilesystemManager($fs); |
|
82 | 82 | |
83 | 83 | |
84 | - $mq = new \Aimeos\MW\MQueue\Manager\Standard( $conf ); |
|
85 | - $ctx->setMessageQueueManager( $mq ); |
|
84 | + $mq = new \Aimeos\MW\MQueue\Manager\Standard($conf); |
|
85 | + $ctx->setMessageQueueManager($mq); |
|
86 | 86 | |
87 | 87 | |
88 | 88 | $session = new \Aimeos\MW\Session\None(); |
89 | - $ctx->setSession( $session ); |
|
89 | + $ctx->setSession($session); |
|
90 | 90 | |
91 | 91 | |
92 | - $i18n = new \Aimeos\MW\Translation\None( 'de' ); |
|
93 | - $ctx->setI18n( array( 'de' => $i18n ) ); |
|
92 | + $i18n = new \Aimeos\MW\Translation\None('de'); |
|
93 | + $ctx->setI18n(array('de' => $i18n)); |
|
94 | 94 | |
95 | 95 | |
96 | - $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager( $ctx ); |
|
97 | - $locale = $localeManager->bootstrap( $site, 'de', '', false ); |
|
98 | - $ctx->setLocale( $locale ); |
|
96 | + $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($ctx); |
|
97 | + $locale = $localeManager->bootstrap($site, 'de', '', false); |
|
98 | + $ctx->setLocale($locale); |
|
99 | 99 | |
100 | 100 | |
101 | - $view = self::createView( $conf ); |
|
102 | - $ctx->setView( $view ); |
|
101 | + $view = self::createView($conf); |
|
102 | + $ctx->setView($view); |
|
103 | 103 | |
104 | 104 | |
105 | - $ctx->setEditor( 'core:controller/jobs' ); |
|
105 | + $ctx->setEditor('core:controller/jobs'); |
|
106 | 106 | |
107 | 107 | return $ctx; |
108 | 108 | } |
109 | 109 | |
110 | 110 | |
111 | - protected static function createView( \Aimeos\MW\Config\Iface $config ) |
|
111 | + protected static function createView(\Aimeos\MW\Config\Iface $config) |
|
112 | 112 | { |
113 | 113 | $tmplpaths = array_merge_recursive( |
114 | - self::getAimeos()->getCustomPaths( 'client/html/templates' ), |
|
115 | - self::getAimeos()->getCustomPaths( 'controller/jobs/templates' ) |
|
114 | + self::getAimeos()->getCustomPaths('client/html/templates'), |
|
115 | + self::getAimeos()->getCustomPaths('controller/jobs/templates') |
|
116 | 116 | ); |
117 | 117 | |
118 | - $view = new \Aimeos\MW\View\Standard( $tmplpaths ); |
|
118 | + $view = new \Aimeos\MW\View\Standard($tmplpaths); |
|
119 | 119 | |
120 | - $trans = new \Aimeos\MW\Translation\None( 'de_DE' ); |
|
121 | - $helper = new \Aimeos\MW\View\Helper\Translate\Standard( $view, $trans ); |
|
122 | - $view->addHelper( 'translate', $helper ); |
|
120 | + $trans = new \Aimeos\MW\Translation\None('de_DE'); |
|
121 | + $helper = new \Aimeos\MW\View\Helper\Translate\Standard($view, $trans); |
|
122 | + $view->addHelper('translate', $helper); |
|
123 | 123 | |
124 | - $helper = new \Aimeos\MW\View\Helper\Url\Standard( $view, 'http://baseurl' ); |
|
125 | - $view->addHelper( 'url', $helper ); |
|
124 | + $helper = new \Aimeos\MW\View\Helper\Url\Standard($view, 'http://baseurl'); |
|
125 | + $view->addHelper('url', $helper); |
|
126 | 126 | |
127 | - $helper = new \Aimeos\MW\View\Helper\Number\Standard( $view, '.', '' ); |
|
128 | - $view->addHelper( 'number', $helper ); |
|
127 | + $helper = new \Aimeos\MW\View\Helper\Number\Standard($view, '.', ''); |
|
128 | + $view->addHelper('number', $helper); |
|
129 | 129 | |
130 | - $helper = new \Aimeos\MW\View\Helper\Date\Standard( $view, 'Y-m-d' ); |
|
131 | - $view->addHelper( 'date', $helper ); |
|
130 | + $helper = new \Aimeos\MW\View\Helper\Date\Standard($view, 'Y-m-d'); |
|
131 | + $view->addHelper('date', $helper); |
|
132 | 132 | |
133 | - $config = new \Aimeos\MW\Config\Decorator\Protect( $config, array( 'controller/jobs', 'client/html' ) ); |
|
134 | - $helper = new \Aimeos\MW\View\Helper\Config\Standard( $view, $config ); |
|
135 | - $view->addHelper( 'config', $helper ); |
|
133 | + $config = new \Aimeos\MW\Config\Decorator\Protect($config, array('controller/jobs', 'client/html')); |
|
134 | + $helper = new \Aimeos\MW\View\Helper\Config\Standard($view, $config); |
|
135 | + $view->addHelper('config', $helper); |
|
136 | 136 | |
137 | 137 | return $view; |
138 | 138 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function getName() |
30 | 30 | { |
31 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Product site map' ); |
|
31 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Product site map'); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function getDescription() |
41 | 41 | { |
42 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Creates a product site map for search engines' ); |
|
42 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Creates a product site map for search engines'); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | { |
53 | 53 | $container = $this->createContainer(); |
54 | 54 | |
55 | - $files = $this->export( $container ); |
|
56 | - $this->createSitemapIndex( $container, $files ); |
|
55 | + $files = $this->export($container); |
|
56 | + $this->createSitemapIndex($container, $files); |
|
57 | 57 | |
58 | 58 | $container->close(); |
59 | 59 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * @param \Aimeos\MW\Container\Content\Iface $content File content object |
66 | 66 | * @param \Aimeos\MShop\Product\Item\Iface[] $items List of product items |
67 | 67 | */ |
68 | - protected function addItems( \Aimeos\MW\Container\Content\Iface $content, array $items ) |
|
68 | + protected function addItems(\Aimeos\MW\Container\Content\Iface $content, array $items) |
|
69 | 69 | { |
70 | 70 | $config = $this->getContext()->getConfig(); |
71 | 71 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * @see controller/jobs/product/export/sitemap/max-items |
97 | 97 | * @see controller/jobs/product/export/sitemap/max-query |
98 | 98 | */ |
99 | - $changefreq = $config->get( 'controller/jobs/product/export/sitemap/changefreq', 'daily' ); |
|
99 | + $changefreq = $config->get('controller/jobs/product/export/sitemap/changefreq', 'daily'); |
|
100 | 100 | |
101 | 101 | /** controller/jobs/product/export/sitemap/standard/template-items |
102 | 102 | * Relative path to the XML items template of the product site map job controller. |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | $view->siteItems = $items; |
130 | 130 | $view->siteFreq = $changefreq; |
131 | 131 | |
132 | - $content->add( $view->render( $context->getConfig()->get( $tplconf, $default ) ) ); |
|
132 | + $content->add($view->render($context->getConfig()->get($tplconf, $default))); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | * @see controller/jobs/product/export/sitemap/max-query |
176 | 176 | * @see controller/jobs/product/export/sitemap/changefreq |
177 | 177 | */ |
178 | - $location = $config->get( 'controller/jobs/product/export/sitemap/location', sys_get_temp_dir() ); |
|
178 | + $location = $config->get('controller/jobs/product/export/sitemap/location', sys_get_temp_dir()); |
|
179 | 179 | |
180 | 180 | /** controller/jobs/product/export/sitemap/container/options |
181 | 181 | * List of file container options for the site map files |
@@ -195,9 +195,9 @@ discard block |
||
195 | 195 | * @see controller/jobs/product/export/sitemap/max-query |
196 | 196 | * @see controller/jobs/product/export/sitemap/changefreq |
197 | 197 | */ |
198 | - $options = $config->get( 'controller/jobs/product/export/sitemap/container/options', [] ); |
|
198 | + $options = $config->get('controller/jobs/product/export/sitemap/container/options', []); |
|
199 | 199 | |
200 | - return \Aimeos\MW\Container\Factory::getContainer( $location, 'Directory', 'Gzip', $options ); |
|
200 | + return \Aimeos\MW\Container\Factory::getContainer($location, 'Directory', 'Gzip', $options); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | * @param integer $filenum New file number |
209 | 209 | * @return \Aimeos\MW\Container\Content\Iface New content object |
210 | 210 | */ |
211 | - protected function createContent( \Aimeos\MW\Container\Iface $container, $filenum ) |
|
211 | + protected function createContent(\Aimeos\MW\Container\Iface $container, $filenum) |
|
212 | 212 | { |
213 | 213 | /** controller/jobs/product/export/sitemap/standard/template-header |
214 | 214 | * Relative path to the XML site map header template of the product site map job controller. |
@@ -238,9 +238,9 @@ discard block |
||
238 | 238 | $context = $this->getContext(); |
239 | 239 | $view = $context->getView(); |
240 | 240 | |
241 | - $content = $container->create( $this->getFilename( $filenum ) ); |
|
242 | - $content->add( $view->render( $context->getConfig()->get( $tplconf, $default ) ) ); |
|
243 | - $container->add( $content ); |
|
241 | + $content = $container->create($this->getFilename($filenum)); |
|
242 | + $content->add($view->render($context->getConfig()->get($tplconf, $default))); |
|
243 | + $container->add($content); |
|
244 | 244 | |
245 | 245 | return $content; |
246 | 246 | } |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | * |
252 | 252 | * @param \Aimeos\MW\Container\Content\Iface $content |
253 | 253 | */ |
254 | - protected function closeContent( \Aimeos\MW\Container\Content\Iface $content ) |
|
254 | + protected function closeContent(\Aimeos\MW\Container\Content\Iface $content) |
|
255 | 255 | { |
256 | 256 | /** controller/jobs/product/export/sitemap/standard/template-footer |
257 | 257 | * Relative path to the XML site map footer template of the product site map job controller. |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | $context = $this->getContext(); |
282 | 282 | $view = $context->getView(); |
283 | 283 | |
284 | - $content->add( $view->render( $context->getConfig()->get( $tplconf, $default ) ) ); |
|
284 | + $content->add($view->render($context->getConfig()->get($tplconf, $default))); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | * @param \Aimeos\MW\Container\Iface $container File container object |
292 | 292 | * @param array $files List of generated site map file names |
293 | 293 | */ |
294 | - protected function createSitemapIndex( \Aimeos\MW\Container\Iface $container, array $files ) |
|
294 | + protected function createSitemapIndex(\Aimeos\MW\Container\Iface $container, array $files) |
|
295 | 295 | { |
296 | 296 | /** controller/jobs/product/export/sitemap/standard/template-index |
297 | 297 | * Relative path to the XML site map index template of the product site map job controller. |
@@ -323,9 +323,9 @@ discard block |
||
323 | 323 | |
324 | 324 | $view->siteFiles = $files; |
325 | 325 | |
326 | - $content = $container->create( 'aimeos-sitemap-index.xml' ); |
|
327 | - $content->add( $view->render( $context->getConfig()->get( $tplconf, $default ) ) ); |
|
328 | - $container->add( $content ); |
|
326 | + $content = $container->create('aimeos-sitemap-index.xml'); |
|
327 | + $content->add($view->render($context->getConfig()->get($tplconf, $default))); |
|
328 | + $container->add($content); |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | |
@@ -336,11 +336,11 @@ discard block |
||
336 | 336 | * @param mixed $default Default value if name is unknown |
337 | 337 | * @return mixed Configuration value |
338 | 338 | */ |
339 | - protected function getConfig( $name, $default = null ) |
|
339 | + protected function getConfig($name, $default = null) |
|
340 | 340 | { |
341 | 341 | $config = $this->getContext()->getConfig(); |
342 | 342 | |
343 | - switch( $name ) |
|
343 | + switch ($name) |
|
344 | 344 | { |
345 | 345 | case 'domain': |
346 | 346 | return []; |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | * @see controller/jobs/product/export/sitemap/max-query |
368 | 368 | * @see controller/jobs/product/export/sitemap/changefreq |
369 | 369 | */ |
370 | - return $config->get( 'controller/jobs/product/export/sitemap/max-items', 50000 ); |
|
370 | + return $config->get('controller/jobs/product/export/sitemap/max-items', 50000); |
|
371 | 371 | |
372 | 372 | case 'max-query': |
373 | 373 | /** controller/jobs/product/export/sitemap/max-query |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | * @see controller/jobs/product/export/sitemap/max-items |
388 | 388 | * @see controller/jobs/product/export/sitemap/changefreq |
389 | 389 | */ |
390 | - return $config->get( 'controller/jobs/product/export/sitemap/max-query', 1000 ); |
|
390 | + return $config->get('controller/jobs/product/export/sitemap/max-query', 1000); |
|
391 | 391 | } |
392 | 392 | |
393 | 393 | return $default; |
@@ -400,8 +400,8 @@ discard block |
||
400 | 400 | * @param integer $number Current file number |
401 | 401 | * @return string New file name |
402 | 402 | */ |
403 | - protected function getFilename( $number ) |
|
403 | + protected function getFilename($number) |
|
404 | 404 | { |
405 | - return sprintf( 'aimeos-sitemap-%d.xml', $number ); |
|
405 | + return sprintf('aimeos-sitemap-%d.xml', $number); |
|
406 | 406 | } |
407 | 407 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function getName() |
30 | 30 | { |
31 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Product export' ); |
|
31 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Product export'); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function getDescription() |
41 | 41 | { |
42 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Exports all available products' ); |
|
42 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Exports all available products'); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | public function run() |
52 | 52 | { |
53 | 53 | $container = $this->createContainer(); |
54 | - $this->export( $container ); |
|
54 | + $this->export($container); |
|
55 | 55 | $container->close(); |
56 | 56 | } |
57 | 57 | |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * @param \Aimeos\MW\Container\Content\Iface $content File content object |
63 | 63 | * @param \Aimeos\MShop\Product\Item\Iface[] $items List of product items |
64 | 64 | */ |
65 | - protected function addItems( \Aimeos\MW\Container\Content\Iface $content, array $items ) |
|
65 | + protected function addItems(\Aimeos\MW\Container\Content\Iface $content, array $items) |
|
66 | 66 | { |
67 | 67 | /** controller/jobs/product/export/standard/template-items |
68 | 68 | * Relative path to the XML items template of the product site map job controller. |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | |
95 | 95 | $view->exportItems = $items; |
96 | 96 | |
97 | - $content->add( $view->render( $context->getConfig()->get( $tplconf, $default ) ) ); |
|
97 | + $content->add($view->render($context->getConfig()->get($tplconf, $default))); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | * @see controller/jobs/product/export/max-items |
124 | 124 | * @see controller/jobs/product/export/max-query |
125 | 125 | */ |
126 | - $location = $config->get( 'controller/jobs/product/export/location', sys_get_temp_dir() ); |
|
126 | + $location = $config->get('controller/jobs/product/export/location', sys_get_temp_dir()); |
|
127 | 127 | |
128 | 128 | /** controller/jobs/product/export/standard/container/type |
129 | 129 | * List of file container options for the export files |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * @see controller/jobs/product/export/max-items |
141 | 141 | * @see controller/jobs/product/export/max-query |
142 | 142 | */ |
143 | - $container = $config->get( 'controller/jobs/product/export/standard/container/type', 'Directory' ); |
|
143 | + $container = $config->get('controller/jobs/product/export/standard/container/type', 'Directory'); |
|
144 | 144 | |
145 | 145 | /** controller/jobs/product/export/standard/container/content |
146 | 146 | * List of file container options for the export files |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * @see controller/jobs/product/export/max-items |
158 | 158 | * @see controller/jobs/product/export/max-query |
159 | 159 | */ |
160 | - $content = $config->get( 'controller/jobs/product/export/standard/container/content', 'Binary' ); |
|
160 | + $content = $config->get('controller/jobs/product/export/standard/container/content', 'Binary'); |
|
161 | 161 | |
162 | 162 | /** controller/jobs/product/export/standard/container/options |
163 | 163 | * List of file container options for the export files |
@@ -174,9 +174,9 @@ discard block |
||
174 | 174 | * @see controller/jobs/product/export/max-items |
175 | 175 | * @see controller/jobs/product/export/max-query |
176 | 176 | */ |
177 | - $options = $config->get( 'controller/jobs/product/export/standard/container/options', [] ); |
|
177 | + $options = $config->get('controller/jobs/product/export/standard/container/options', []); |
|
178 | 178 | |
179 | - return \Aimeos\MW\Container\Factory::getContainer( $location, $container, $content, $options ); |
|
179 | + return \Aimeos\MW\Container\Factory::getContainer($location, $container, $content, $options); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | * @param integer $filenum New file number |
188 | 188 | * @return \Aimeos\MW\Container\Content\Iface New content object |
189 | 189 | */ |
190 | - protected function createContent( \Aimeos\MW\Container\Iface $container, $filenum ) |
|
190 | + protected function createContent(\Aimeos\MW\Container\Iface $container, $filenum) |
|
191 | 191 | { |
192 | 192 | /** controller/jobs/product/export/standard/template-header |
193 | 193 | * Relative path to the XML site map header template of the product site map job controller. |
@@ -217,9 +217,9 @@ discard block |
||
217 | 217 | $context = $this->getContext(); |
218 | 218 | $view = $context->getView(); |
219 | 219 | |
220 | - $content = $container->create( $this->getFilename( $filenum ) ); |
|
221 | - $content->add( $view->render( $context->getConfig()->get( $tplconf, $default ) ) ); |
|
222 | - $container->add( $content ); |
|
220 | + $content = $container->create($this->getFilename($filenum)); |
|
221 | + $content->add($view->render($context->getConfig()->get($tplconf, $default))); |
|
222 | + $container->add($content); |
|
223 | 223 | |
224 | 224 | return $content; |
225 | 225 | } |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | * |
231 | 231 | * @param \Aimeos\MW\Container\Content\Iface $content |
232 | 232 | */ |
233 | - protected function closeContent( \Aimeos\MW\Container\Content\Iface $content ) |
|
233 | + protected function closeContent(\Aimeos\MW\Container\Content\Iface $content) |
|
234 | 234 | { |
235 | 235 | /** controller/jobs/product/export/standard/template-footer |
236 | 236 | * Relative path to the XML site map footer template of the product site map job controller. |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | $context = $this->getContext(); |
261 | 261 | $view = $context->getView(); |
262 | 262 | |
263 | - $content->add( $view->render( $context->getConfig()->get( $tplconf, $default ) ) ); |
|
263 | + $content->add($view->render($context->getConfig()->get($tplconf, $default))); |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | |
@@ -270,45 +270,45 @@ discard block |
||
270 | 270 | * @param \Aimeos\MW\Container\Iface $container Container object |
271 | 271 | * @return array List of content (file) names |
272 | 272 | */ |
273 | - protected function export( \Aimeos\MW\Container\Iface $container ) |
|
273 | + protected function export(\Aimeos\MW\Container\Iface $container) |
|
274 | 274 | { |
275 | - $default = array( 'attribute', 'media', 'price', 'product', 'text' ); |
|
275 | + $default = array('attribute', 'media', 'price', 'product', 'text'); |
|
276 | 276 | |
277 | - $domains = $this->getConfig( 'domains', $default ); |
|
278 | - $maxItems = $this->getConfig( 'max-items', 10000 ); |
|
279 | - $maxQuery = $this->getConfig( 'max-query', 1000 ); |
|
277 | + $domains = $this->getConfig('domains', $default); |
|
278 | + $maxItems = $this->getConfig('max-items', 10000); |
|
279 | + $maxQuery = $this->getConfig('max-query', 1000); |
|
280 | 280 | |
281 | 281 | $start = 0; $filenum = 1; |
282 | 282 | $names = []; |
283 | 283 | |
284 | - $productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
284 | + $productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
285 | 285 | |
286 | - $search = $productManager->createSearch( true ); |
|
287 | - $search->setSortations( array( $search->sort( '+', 'product.id' ) ) ); |
|
288 | - $search->setSlice( 0, $maxQuery ); |
|
286 | + $search = $productManager->createSearch(true); |
|
287 | + $search->setSortations(array($search->sort('+', 'product.id'))); |
|
288 | + $search->setSlice(0, $maxQuery); |
|
289 | 289 | |
290 | - $content = $this->createContent( $container, $filenum ); |
|
290 | + $content = $this->createContent($container, $filenum); |
|
291 | 291 | $names[] = $content->getResource(); |
292 | 292 | |
293 | 293 | do |
294 | 294 | { |
295 | - $items = $productManager->searchItems( $search, $domains ); |
|
296 | - $this->addItems( $content, $items ); |
|
295 | + $items = $productManager->searchItems($search, $domains); |
|
296 | + $this->addItems($content, $items); |
|
297 | 297 | |
298 | - $count = count( $items ); |
|
298 | + $count = count($items); |
|
299 | 299 | $start += $count; |
300 | - $search->setSlice( $start, $maxQuery ); |
|
300 | + $search->setSlice($start, $maxQuery); |
|
301 | 301 | |
302 | - if( $start + $maxQuery > $maxItems * $filenum ) |
|
302 | + if ($start + $maxQuery > $maxItems * $filenum) |
|
303 | 303 | { |
304 | - $this->closeContent( $content ); |
|
305 | - $content = $this->createContent( $container, ++$filenum ); |
|
304 | + $this->closeContent($content); |
|
305 | + $content = $this->createContent($container, ++$filenum); |
|
306 | 306 | $names[] = $content->getResource(); |
307 | 307 | } |
308 | 308 | } |
309 | - while( $count >= $search->getSliceSize() ); |
|
309 | + while ($count >= $search->getSliceSize()); |
|
310 | 310 | |
311 | - $this->closeContent( $content ); |
|
311 | + $this->closeContent($content); |
|
312 | 312 | |
313 | 313 | return $names; |
314 | 314 | } |
@@ -321,11 +321,11 @@ discard block |
||
321 | 321 | * @param mixed $default Default value if name is unknown |
322 | 322 | * @return mixed Configuration value |
323 | 323 | */ |
324 | - protected function getConfig( $name, $default = null ) |
|
324 | + protected function getConfig($name, $default = null) |
|
325 | 325 | { |
326 | 326 | $config = $this->getContext()->getConfig(); |
327 | 327 | |
328 | - switch( $name ) |
|
328 | + switch ($name) |
|
329 | 329 | { |
330 | 330 | case 'domain': |
331 | 331 | /** controller/jobs/product/export/domains |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | * @see controller/jobs/product/export/max-items |
348 | 348 | * @see controller/jobs/product/export/max-query |
349 | 349 | */ |
350 | - return $config->get( 'controller/jobs/product/export/domains', $default ); |
|
350 | + return $config->get('controller/jobs/product/export/domains', $default); |
|
351 | 351 | |
352 | 352 | case 'max-items': |
353 | 353 | /** controller/jobs/product/export/max-items |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | * @see controller/jobs/product/export/max-query |
370 | 370 | * @see controller/jobs/product/export/domains |
371 | 371 | */ |
372 | - return $config->get( 'controller/jobs/product/export/max-items', $default ); |
|
372 | + return $config->get('controller/jobs/product/export/max-items', $default); |
|
373 | 373 | |
374 | 374 | case 'max-query': |
375 | 375 | /** controller/jobs/product/export/max-query |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | * @see controller/jobs/product/export/max-items |
392 | 392 | * @see controller/jobs/product/export/domains |
393 | 393 | */ |
394 | - return $config->get( 'controller/jobs/product/export/max-query', $default ); |
|
394 | + return $config->get('controller/jobs/product/export/max-query', $default); |
|
395 | 395 | } |
396 | 396 | |
397 | 397 | return $default; |
@@ -404,8 +404,8 @@ discard block |
||
404 | 404 | * @param integer $number Current file number |
405 | 405 | * @return string New file name |
406 | 406 | */ |
407 | - protected function getFilename( $number ) |
|
407 | + protected function getFilename($number) |
|
408 | 408 | { |
409 | - return sprintf( 'aimeos-products-%d.xml', $number ); |
|
409 | + return sprintf('aimeos-products-%d.xml', $number); |
|
410 | 410 | } |
411 | 411 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | */ |
30 | 30 | public function getName() |
31 | 31 | { |
32 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Products bought together' ); |
|
32 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Products bought together'); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public function getDescription() |
42 | 42 | { |
43 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Creates bought together product suggestions' ); |
|
43 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Creates bought together product suggestions'); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * @see controller/jobs/product/bought/min-confidence |
73 | 73 | * @see controller/jobs/product/bought/limit-days |
74 | 74 | */ |
75 | - $maxItems = $config->get( 'controller/jobs/product/bought/max-items', 5 ); |
|
75 | + $maxItems = $config->get('controller/jobs/product/bought/max-items', 5); |
|
76 | 76 | |
77 | 77 | /** controller/jobs/product/bought/min-support |
78 | 78 | * Minimum support value to sort out all irrelevant combinations |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * @see controller/jobs/product/bought/min-confidence |
102 | 102 | * @see controller/jobs/product/bought/limit-days |
103 | 103 | */ |
104 | - $minSupport = $config->get( 'controller/jobs/product/bought/min-support', 0.02 ); |
|
104 | + $minSupport = $config->get('controller/jobs/product/bought/min-support', 0.02); |
|
105 | 105 | |
106 | 106 | /** controller/jobs/product/bought/min-confidence |
107 | 107 | * Minimum confidence value for high quality suggestions |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * @see controller/jobs/product/bought/min-support |
127 | 127 | * @see controller/jobs/product/bought/limit-days |
128 | 128 | */ |
129 | - $minConfidence = $config->get( 'controller/jobs/product/bought/min-confidence', 0.66 ); |
|
129 | + $minConfidence = $config->get('controller/jobs/product/bought/min-confidence', 0.66); |
|
130 | 130 | |
131 | 131 | /** controller/jobs/product/bought/limit-days |
132 | 132 | * Only use orders placed in the past within the configured number of days for calculating bought together products |
@@ -150,45 +150,45 @@ discard block |
||
150 | 150 | * @see controller/jobs/product/bought/min-support |
151 | 151 | * @see controller/jobs/product/bought/min-confidence |
152 | 152 | */ |
153 | - $days = $config->get( 'controller/jobs/product/bought/limit-days', 180 ); |
|
154 | - $date = date( 'Y-m-d H:i:s', time() - $days * 86400 ); |
|
153 | + $days = $config->get('controller/jobs/product/bought/limit-days', 180); |
|
154 | + $date = date('Y-m-d H:i:s', time() - $days * 86400); |
|
155 | 155 | |
156 | 156 | |
157 | - $typeItem = $this->getTypeItem( 'product/lists/type', 'product', 'bought-together' ); |
|
157 | + $typeItem = $this->getTypeItem('product/lists/type', 'product', 'bought-together'); |
|
158 | 158 | |
159 | - $baseManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base' ); |
|
159 | + $baseManager = \Aimeos\MShop\Factory::createManager($context, 'order/base'); |
|
160 | 160 | $search = $baseManager->createSearch(); |
161 | - $search->setConditions( $search->compare( '>', 'order.base.ctime', $date ) ); |
|
162 | - $search->setSlice( 0, 0 ); |
|
161 | + $search->setConditions($search->compare('>', 'order.base.ctime', $date)); |
|
162 | + $search->setSlice(0, 0); |
|
163 | 163 | $totalOrders = 0; |
164 | - $baseManager->searchItems( $search, [], $totalOrders ); |
|
164 | + $baseManager->searchItems($search, [], $totalOrders); |
|
165 | 165 | |
166 | - $baseProductManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product' ); |
|
166 | + $baseProductManager = \Aimeos\MShop\Factory::createManager($context, 'order/base/product'); |
|
167 | 167 | $search = $baseProductManager->createSearch(); |
168 | - $search->setConditions( $search->compare( '>', 'order.base.product.ctime', $date ) ); |
|
168 | + $search->setConditions($search->compare('>', 'order.base.product.ctime', $date)); |
|
169 | 169 | $start = 0; |
170 | 170 | |
171 | 171 | do |
172 | 172 | { |
173 | - $totalCounts = $baseProductManager->aggregate( $search, 'order.base.product.productid' ); |
|
174 | - $prodIds = array_keys( $totalCounts ); |
|
173 | + $totalCounts = $baseProductManager->aggregate($search, 'order.base.product.productid'); |
|
174 | + $prodIds = array_keys($totalCounts); |
|
175 | 175 | |
176 | - foreach( $totalCounts as $id => $count ) |
|
176 | + foreach ($totalCounts as $id => $count) |
|
177 | 177 | { |
178 | - $this->removeListItems( $id, $typeItem->getId() ); |
|
178 | + $this->removeListItems($id, $typeItem->getId()); |
|
179 | 179 | |
180 | - if( $count / $totalOrders > $minSupport ) |
|
180 | + if ($count / $totalOrders > $minSupport) |
|
181 | 181 | { |
182 | - $productIds = $this->getSuggestions( $id, $prodIds, $count, $totalOrders, $maxItems, $minSupport, $minConfidence, $date ); |
|
183 | - $this->addListItems( $id, $typeItem->getId(), $productIds ); |
|
182 | + $productIds = $this->getSuggestions($id, $prodIds, $count, $totalOrders, $maxItems, $minSupport, $minConfidence, $date); |
|
183 | + $this->addListItems($id, $typeItem->getId(), $productIds); |
|
184 | 184 | } |
185 | 185 | } |
186 | 186 | |
187 | - $count = count( $totalCounts ); |
|
187 | + $count = count($totalCounts); |
|
188 | 188 | $start += $count; |
189 | - $search->setSlice( $start ); |
|
189 | + $search->setSlice($start); |
|
190 | 190 | } |
191 | - while( $count >= $search->getSliceSize() ); |
|
191 | + while ($count >= $search->getSliceSize()); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | |
@@ -205,59 +205,59 @@ discard block |
||
205 | 205 | * @param string $date Date in YYYY-MM-DD HH:mm:ss format after which orders should be used for calculations |
206 | 206 | * @return array List of suggested product IDs as key and their confidence as value |
207 | 207 | */ |
208 | - protected function getSuggestions( $id, $prodIds, $count, $total, $maxItems, $minSupport, $minConfidence, $date ) |
|
208 | + protected function getSuggestions($id, $prodIds, $count, $total, $maxItems, $minSupport, $minConfidence, $date) |
|
209 | 209 | { |
210 | 210 | $refIds = []; |
211 | 211 | $context = $this->getContext(); |
212 | 212 | |
213 | - $catalogListManager = \Aimeos\MShop\Factory::createManager( $context, 'catalog/lists' ); |
|
214 | - $baseProductManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product' ); |
|
213 | + $catalogListManager = \Aimeos\MShop\Factory::createManager($context, 'catalog/lists'); |
|
214 | + $baseProductManager = \Aimeos\MShop\Factory::createManager($context, 'order/base/product'); |
|
215 | 215 | |
216 | 216 | |
217 | 217 | $search = $baseProductManager->createSearch(); |
218 | - $func = $search->createFunction( 'order.base.product.count', array( (string) $id ) ); |
|
218 | + $func = $search->createFunction('order.base.product.count', array((string) $id)); |
|
219 | 219 | $expr = array( |
220 | - $search->compare( '==', 'order.base.product.productid', $prodIds ), |
|
221 | - $search->compare( '>', 'order.base.product.ctime', $date ), |
|
222 | - $search->compare( '==', $func, 1 ), |
|
220 | + $search->compare('==', 'order.base.product.productid', $prodIds), |
|
221 | + $search->compare('>', 'order.base.product.ctime', $date), |
|
222 | + $search->compare('==', $func, 1), |
|
223 | 223 | ); |
224 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
224 | + $search->setConditions($search->combine('&&', $expr)); |
|
225 | 225 | |
226 | - $relativeCounts = $baseProductManager->aggregate( $search, 'order.base.product.productid' ); |
|
226 | + $relativeCounts = $baseProductManager->aggregate($search, 'order.base.product.productid'); |
|
227 | 227 | |
228 | 228 | |
229 | 229 | $search = $catalogListManager->createSearch(); |
230 | 230 | $expr = array( |
231 | - $search->compare( '==', 'catalog.lists.refid', array_keys( $relativeCounts ) ), |
|
232 | - $search->compare( '==', 'catalog.lists.domain', 'product' ), |
|
231 | + $search->compare('==', 'catalog.lists.refid', array_keys($relativeCounts)), |
|
232 | + $search->compare('==', 'catalog.lists.domain', 'product'), |
|
233 | 233 | ); |
234 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
234 | + $search->setConditions($search->combine('&&', $expr)); |
|
235 | 235 | |
236 | - foreach( $catalogListManager->searchItems( $search ) as $listItem ) { |
|
236 | + foreach ($catalogListManager->searchItems($search) as $listItem) { |
|
237 | 237 | $refIds[$listItem->getRefId()] = true; |
238 | 238 | } |
239 | 239 | |
240 | 240 | |
241 | - unset( $relativeCounts[$id] ); |
|
241 | + unset($relativeCounts[$id]); |
|
242 | 242 | $supportA = $count / $total; |
243 | 243 | $products = []; |
244 | 244 | |
245 | - foreach( $relativeCounts as $prodId => $relCnt ) |
|
245 | + foreach ($relativeCounts as $prodId => $relCnt) |
|
246 | 246 | { |
247 | - if( !isset( $refIds[$prodId] ) ) { |
|
247 | + if (!isset($refIds[$prodId])) { |
|
248 | 248 | continue; |
249 | 249 | } |
250 | 250 | |
251 | 251 | $supportAB = $relCnt / $total; |
252 | 252 | |
253 | - if( $supportAB > $minSupport && ( $conf = ( $supportAB / $supportA ) ) > $minConfidence ) { |
|
253 | + if ($supportAB > $minSupport && ($conf = ($supportAB / $supportA)) > $minConfidence) { |
|
254 | 254 | $products[$prodId] = $conf; |
255 | 255 | } |
256 | 256 | } |
257 | 257 | |
258 | - arsort( $products ); |
|
258 | + arsort($products); |
|
259 | 259 | |
260 | - return array_keys( array_slice( $products, 0, $maxItems, true ) ); |
|
260 | + return array_keys(array_slice($products, 0, $maxItems, true)); |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | |
@@ -268,26 +268,26 @@ discard block |
||
268 | 268 | * @param integer $typeId Unique ID of the list type used for the referenced products |
269 | 269 | * @param array $productIds List of position as key and product ID as value |
270 | 270 | */ |
271 | - protected function addListItems( $productId, $typeId, array $productIds ) |
|
271 | + protected function addListItems($productId, $typeId, array $productIds) |
|
272 | 272 | { |
273 | - if( empty( $productIds ) ) { |
|
273 | + if (empty($productIds)) { |
|
274 | 274 | return; |
275 | 275 | } |
276 | 276 | |
277 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/lists' ); |
|
277 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/lists'); |
|
278 | 278 | $item = $manager->createItem(); |
279 | 279 | |
280 | - foreach( $productIds as $pos => $refid ) |
|
280 | + foreach ($productIds as $pos => $refid) |
|
281 | 281 | { |
282 | - $item->setId( null ); |
|
283 | - $item->setParentId( $productId ); |
|
284 | - $item->setDomain( 'product' ); |
|
285 | - $item->setTypeId( $typeId ); |
|
286 | - $item->setPosition( $pos ); |
|
287 | - $item->setRefId( $refid ); |
|
288 | - $item->setStatus( 1 ); |
|
289 | - |
|
290 | - $manager->saveItem( $item ); |
|
282 | + $item->setId(null); |
|
283 | + $item->setParentId($productId); |
|
284 | + $item->setDomain('product'); |
|
285 | + $item->setTypeId($typeId); |
|
286 | + $item->setPosition($pos); |
|
287 | + $item->setRefId($refid); |
|
288 | + $item->setStatus(1); |
|
289 | + |
|
290 | + $manager->saveItem($item); |
|
291 | 291 | } |
292 | 292 | } |
293 | 293 | |
@@ -298,20 +298,20 @@ discard block |
||
298 | 298 | * @param string $productId Unique ID of the product the references should be removed from |
299 | 299 | * @param integer $typeId Unique ID of the list type the referenced products should be removed from |
300 | 300 | */ |
301 | - protected function removeListItems( $productId, $typeId ) |
|
301 | + protected function removeListItems($productId, $typeId) |
|
302 | 302 | { |
303 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/lists' ); |
|
303 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/lists'); |
|
304 | 304 | |
305 | 305 | $search = $manager->createSearch(); |
306 | 306 | $expr = array( |
307 | - $search->compare( '==', 'product.lists.parentid', $productId ), |
|
308 | - $search->compare( '==', 'product.lists.domain', 'product' ), |
|
309 | - $search->compare( '==', 'product.lists.typeid', $typeId ), |
|
307 | + $search->compare('==', 'product.lists.parentid', $productId), |
|
308 | + $search->compare('==', 'product.lists.domain', 'product'), |
|
309 | + $search->compare('==', 'product.lists.typeid', $typeId), |
|
310 | 310 | ); |
311 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
311 | + $search->setConditions($search->combine('&&', $expr)); |
|
312 | 312 | |
313 | - $listItems = $manager->searchItems( $search ); |
|
313 | + $listItems = $manager->searchItems($search); |
|
314 | 314 | |
315 | - $manager->deleteItems( array_keys( $listItems ) ); |
|
315 | + $manager->deleteItems(array_keys($listItems)); |
|
316 | 316 | } |
317 | 317 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function getName() |
30 | 30 | { |
31 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Product import CSV' ); |
|
31 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Product import CSV'); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function getDescription() |
41 | 41 | { |
42 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Imports new and updates existing products from CSV files' ); |
|
42 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Imports new and updates existing products from CSV files'); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | $context = $this->getContext(); |
55 | 55 | $config = $context->getConfig(); |
56 | 56 | $logger = $context->getLogger(); |
57 | - $domains = array( 'attribute', 'media', 'price', 'product', 'text' ); |
|
57 | + $domains = array('attribute', 'media', 'price', 'product', 'text'); |
|
58 | 58 | $mappings = $this->getDefaultMapping(); |
59 | 59 | |
60 | 60 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * @see controller/common/product/import/csv/converter |
75 | 75 | * @see controller/common/product/import/csv/max-size |
76 | 76 | */ |
77 | - $domains = $config->get( 'controller/common/product/import/csv/domains', $domains ); |
|
77 | + $domains = $config->get('controller/common/product/import/csv/domains', $domains); |
|
78 | 78 | |
79 | 79 | /** controller/jobs/product/import/csv/domains |
80 | 80 | * List of item domain names that should be retrieved along with the product items |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | * @see controller/jobs/product/import/csv/backup |
95 | 95 | * @see controller/common/product/import/csv/max-size |
96 | 96 | */ |
97 | - $domains = $config->get( 'controller/jobs/product/import/csv/domains', $domains ); |
|
97 | + $domains = $config->get('controller/jobs/product/import/csv/domains', $domains); |
|
98 | 98 | |
99 | 99 | |
100 | 100 | /** controller/common/product/import/csv/mapping |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | * @see controller/common/product/import/csv/converter |
123 | 123 | * @see controller/common/product/import/csv/max-size |
124 | 124 | */ |
125 | - $mappings = $config->get( 'controller/common/product/import/csv/mapping', $mappings ); |
|
125 | + $mappings = $config->get('controller/common/product/import/csv/mapping', $mappings); |
|
126 | 126 | |
127 | 127 | /** controller/jobs/product/import/csv/mapping |
128 | 128 | * List of mappings between the position in the CSV file and item keys |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | * @see controller/jobs/product/import/csv/backup |
143 | 143 | * @see controller/common/product/import/csv/max-size |
144 | 144 | */ |
145 | - $mappings = $config->get( 'controller/jobs/product/import/csv/mapping', $mappings ); |
|
145 | + $mappings = $config->get('controller/jobs/product/import/csv/mapping', $mappings); |
|
146 | 146 | |
147 | 147 | |
148 | 148 | /** controller/common/product/import/csv/converter |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | * @see controller/common/product/import/csv/mapping |
185 | 185 | * @see controller/common/product/import/csv/max-size |
186 | 186 | */ |
187 | - $converters = $config->get( 'controller/common/product/import/csv/converter', [] ); |
|
187 | + $converters = $config->get('controller/common/product/import/csv/converter', []); |
|
188 | 188 | |
189 | 189 | /** controller/jobs/product/import/csv/converter |
190 | 190 | * List of converter names for the values at the position in the CSV file |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | * @see controller/jobs/product/import/csv/backup |
205 | 205 | * @see controller/common/product/import/csv/max-size |
206 | 206 | */ |
207 | - $converters = $config->get( 'controller/jobs/product/import/csv/converter', $converters ); |
|
207 | + $converters = $config->get('controller/jobs/product/import/csv/converter', $converters); |
|
208 | 208 | |
209 | 209 | |
210 | 210 | /** controller/common/product/import/csv/max-size |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | * @see controller/common/product/import/csv/mapping |
225 | 225 | * @see controller/common/product/import/csv/converter |
226 | 226 | */ |
227 | - $maxcnt = (int) $config->get( 'controller/common/product/import/csv/max-size', 1000 ); |
|
227 | + $maxcnt = (int) $config->get('controller/common/product/import/csv/max-size', 1000); |
|
228 | 228 | |
229 | 229 | |
230 | 230 | /** controller/jobs/product/import/csv/skip-lines |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | * @see controller/jobs/product/import/csv/backup |
247 | 247 | * @see controller/common/product/import/csv/max-size |
248 | 248 | */ |
249 | - $skiplines = (int) $config->get( 'controller/jobs/product/import/csv/skip-lines', 0 ); |
|
249 | + $skiplines = (int) $config->get('controller/jobs/product/import/csv/skip-lines', 0); |
|
250 | 250 | |
251 | 251 | |
252 | 252 | /** controller/jobs/product/import/csv/strict |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | * @see controller/jobs/product/import/csv/backup |
271 | 271 | * @see controller/common/product/import/csv/max-size |
272 | 272 | */ |
273 | - $strict = (bool) $config->get( 'controller/jobs/product/import/csv/strict', true ); |
|
273 | + $strict = (bool) $config->get('controller/jobs/product/import/csv/strict', true); |
|
274 | 274 | |
275 | 275 | |
276 | 276 | /** controller/jobs/product/import/csv/backup |
@@ -303,74 +303,74 @@ discard block |
||
303 | 303 | * @see controller/jobs/product/import/csv/strict |
304 | 304 | * @see controller/common/product/import/csv/max-size |
305 | 305 | */ |
306 | - $backup = $config->get( 'controller/jobs/product/import/csv/backup' ); |
|
306 | + $backup = $config->get('controller/jobs/product/import/csv/backup'); |
|
307 | 307 | |
308 | 308 | |
309 | - if( !isset( $mappings['item'] ) || !is_array( $mappings['item'] ) ) |
|
309 | + if (!isset($mappings['item']) || !is_array($mappings['item'])) |
|
310 | 310 | { |
311 | - $msg = sprintf( 'Required mapping key "%1$s" is missing or contains no array', 'item' ); |
|
312 | - throw new \Aimeos\Controller\Jobs\Exception( $msg ); |
|
311 | + $msg = sprintf('Required mapping key "%1$s" is missing or contains no array', 'item'); |
|
312 | + throw new \Aimeos\Controller\Jobs\Exception($msg); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | try |
316 | 316 | { |
317 | 317 | $procMappings = $mappings; |
318 | - unset( $procMappings['item'] ); |
|
318 | + unset($procMappings['item']); |
|
319 | 319 | |
320 | - $codePos = $this->getCodePosition( $mappings['item'] ); |
|
321 | - $convlist = $this->getConverterList( $converters ); |
|
322 | - $processor = $this->getProcessors( $procMappings ); |
|
320 | + $codePos = $this->getCodePosition($mappings['item']); |
|
321 | + $convlist = $this->getConverterList($converters); |
|
322 | + $processor = $this->getProcessors($procMappings); |
|
323 | 323 | $container = $this->getContainer(); |
324 | 324 | $path = $container->getName(); |
325 | 325 | |
326 | - $msg = sprintf( 'Started product import from "%1$s" (%2$s)', $path, __CLASS__ ); |
|
327 | - $logger->log( $msg, \Aimeos\MW\Logger\Base::NOTICE ); |
|
326 | + $msg = sprintf('Started product import from "%1$s" (%2$s)', $path, __CLASS__); |
|
327 | + $logger->log($msg, \Aimeos\MW\Logger\Base::NOTICE); |
|
328 | 328 | |
329 | - foreach( $container as $content ) |
|
329 | + foreach ($container as $content) |
|
330 | 330 | { |
331 | 331 | $name = $content->getName(); |
332 | 332 | |
333 | - for( $i = 0; $i < $skiplines; $i++ ) { |
|
333 | + for ($i = 0; $i < $skiplines; $i++) { |
|
334 | 334 | $content->next(); |
335 | 335 | } |
336 | 336 | |
337 | - while( ( $data = $this->getData( $content, $maxcnt, $codePos ) ) !== [] ) |
|
337 | + while (($data = $this->getData($content, $maxcnt, $codePos)) !== []) |
|
338 | 338 | { |
339 | - $data = $this->convertData( $convlist, $data ); |
|
340 | - $products = $this->getProducts( array_keys( $data ), $domains ); |
|
341 | - $errcnt = $this->import( $products, $data, $mappings['item'], $processor, $strict ); |
|
342 | - $chunkcnt = count( $data ); |
|
339 | + $data = $this->convertData($convlist, $data); |
|
340 | + $products = $this->getProducts(array_keys($data), $domains); |
|
341 | + $errcnt = $this->import($products, $data, $mappings['item'], $processor, $strict); |
|
342 | + $chunkcnt = count($data); |
|
343 | 343 | |
344 | 344 | $msg = 'Imported product lines from "%1$s": %2$d/%3$d (%4$s)'; |
345 | - $logger->log( sprintf( $msg, $name, $chunkcnt - $errcnt, $chunkcnt, __CLASS__ ), \Aimeos\MW\Logger\Base::NOTICE ); |
|
345 | + $logger->log(sprintf($msg, $name, $chunkcnt - $errcnt, $chunkcnt, __CLASS__), \Aimeos\MW\Logger\Base::NOTICE); |
|
346 | 346 | |
347 | 347 | $errors += $errcnt; |
348 | 348 | $total += $chunkcnt; |
349 | - unset( $products, $data ); |
|
349 | + unset($products, $data); |
|
350 | 350 | } |
351 | 351 | } |
352 | 352 | |
353 | 353 | $container->close(); |
354 | 354 | } |
355 | - catch( \Exception $e ) |
|
355 | + catch (\Exception $e) |
|
356 | 356 | { |
357 | - $logger->log( 'Product import error: ' . $e->getMessage() ); |
|
358 | - $logger->log( $e->getTraceAsString() ); |
|
357 | + $logger->log('Product import error: ' . $e->getMessage()); |
|
358 | + $logger->log($e->getTraceAsString()); |
|
359 | 359 | |
360 | - throw new \Aimeos\Controller\Jobs\Exception( $e->getMessage() ); |
|
360 | + throw new \Aimeos\Controller\Jobs\Exception($e->getMessage()); |
|
361 | 361 | } |
362 | 362 | |
363 | 363 | $msg = 'Finished product import from "%1$s": %2$d successful, %3$s errors, %4$s total (%5$s)'; |
364 | - $logger->log( sprintf( $msg, $path, $total - $errors, $errors, $total, __CLASS__ ), \Aimeos\MW\Logger\Base::NOTICE ); |
|
364 | + $logger->log(sprintf($msg, $path, $total - $errors, $errors, $total, __CLASS__), \Aimeos\MW\Logger\Base::NOTICE); |
|
365 | 365 | |
366 | - if( $errors > 0 ) |
|
366 | + if ($errors > 0) |
|
367 | 367 | { |
368 | - $msg = sprintf( 'Invalid product lines in "%1$s": %2$d/%3$d', $path, $errors, $total ); |
|
369 | - throw new \Aimeos\Controller\Jobs\Exception( $msg ); |
|
368 | + $msg = sprintf('Invalid product lines in "%1$s": %2$d/%3$d', $path, $errors, $total); |
|
369 | + throw new \Aimeos\Controller\Jobs\Exception($msg); |
|
370 | 370 | } |
371 | 371 | |
372 | - if( !empty( $backup ) && @rename( $path, strftime( $backup ) ) === false ) { |
|
373 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Unable to move imported file' ) ); |
|
372 | + if (!empty($backup) && @rename($path, strftime($backup)) === false) { |
|
373 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Unable to move imported file')); |
|
374 | 374 | } |
375 | 375 | } |
376 | 376 | |
@@ -382,16 +382,16 @@ discard block |
||
382 | 382 | * @return integer Position of the "product.code" column |
383 | 383 | * @throws \Aimeos\Controller\Jobs\Exception If no mapping for "product.code" is found |
384 | 384 | */ |
385 | - protected function getCodePosition( array $mapping ) |
|
385 | + protected function getCodePosition(array $mapping) |
|
386 | 386 | { |
387 | - foreach( $mapping as $pos => $key ) |
|
387 | + foreach ($mapping as $pos => $key) |
|
388 | 388 | { |
389 | - if( $key === 'product.code' ) { |
|
389 | + if ($key === 'product.code') { |
|
390 | 390 | return $pos; |
391 | 391 | } |
392 | 392 | } |
393 | 393 | |
394 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'No "product.code" column in CSV mapping found' ) ); |
|
394 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('No "product.code" column in CSV mapping found')); |
|
395 | 395 | } |
396 | 396 | |
397 | 397 | |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | * @see controller/jobs/product/import/csv/container/content |
427 | 427 | * @see controller/jobs/product/import/csv/container/options |
428 | 428 | */ |
429 | - $location = $config->get( 'controller/jobs/product/import/csv/location', '.' ); |
|
429 | + $location = $config->get('controller/jobs/product/import/csv/location', '.'); |
|
430 | 430 | |
431 | 431 | /** controller/jobs/product/import/csv/container/type |
432 | 432 | * Nave of the container type to read the data from |
@@ -449,7 +449,7 @@ discard block |
||
449 | 449 | * @see controller/jobs/product/import/csv/container/content |
450 | 450 | * @see controller/jobs/product/import/csv/container/options |
451 | 451 | */ |
452 | - $container = $config->get( 'controller/jobs/product/import/csv/container/type', 'Directory' ); |
|
452 | + $container = $config->get('controller/jobs/product/import/csv/container/type', 'Directory'); |
|
453 | 453 | |
454 | 454 | /** controller/jobs/product/import/csv/container/content |
455 | 455 | * Name of the content type inside the container to read the data from |
@@ -470,7 +470,7 @@ discard block |
||
470 | 470 | * @see controller/jobs/product/import/csv/container/type |
471 | 471 | * @see controller/jobs/product/import/csv/container/options |
472 | 472 | */ |
473 | - $content = $config->get( 'controller/jobs/product/import/csv/container/content', 'CSV' ); |
|
473 | + $content = $config->get('controller/jobs/product/import/csv/container/content', 'CSV'); |
|
474 | 474 | |
475 | 475 | /** controller/jobs/product/import/csv/container/options |
476 | 476 | * List of file container options for the product import files |
@@ -488,9 +488,9 @@ discard block |
||
488 | 488 | * @see controller/jobs/product/import/csv/container/content |
489 | 489 | * @see controller/jobs/product/import/csv/container/type |
490 | 490 | */ |
491 | - $options = $config->get( 'controller/jobs/product/import/csv/container/options', [] ); |
|
491 | + $options = $config->get('controller/jobs/product/import/csv/container/options', []); |
|
492 | 492 | |
493 | - return \Aimeos\MW\Container\Factory::getContainer( $location, $container, $content, $options ); |
|
493 | + return \Aimeos\MW\Container\Factory::getContainer($location, $container, $content, $options); |
|
494 | 494 | } |
495 | 495 | |
496 | 496 | |
@@ -505,54 +505,54 @@ discard block |
||
505 | 505 | * @return integer Number of products that couldn't be imported |
506 | 506 | * @throws \Aimeos\Controller\Jobs\Exception |
507 | 507 | */ |
508 | - protected function import( array $products, array $data, array $mapping, |
|
509 | - \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $processor, $strict ) |
|
508 | + protected function import(array $products, array $data, array $mapping, |
|
509 | + \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $processor, $strict) |
|
510 | 510 | { |
511 | 511 | $errors = 0; |
512 | 512 | $context = $this->getContext(); |
513 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'product' ); |
|
513 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'product'); |
|
514 | 514 | |
515 | - foreach( $data as $code => $list ) |
|
515 | + foreach ($data as $code => $list) |
|
516 | 516 | { |
517 | 517 | $manager->begin(); |
518 | 518 | |
519 | 519 | try |
520 | 520 | { |
521 | - if( isset( $products[$code] ) ) { |
|
521 | + if (isset($products[$code])) { |
|
522 | 522 | $product = $products[$code]; |
523 | 523 | } else { |
524 | 524 | $product = $manager->createItem(); |
525 | 525 | } |
526 | 526 | |
527 | - $map = $this->getMappedChunk( $list, $mapping ); |
|
527 | + $map = $this->getMappedChunk($list, $mapping); |
|
528 | 528 | |
529 | - if( isset( $map[0] ) ) |
|
529 | + if (isset($map[0])) |
|
530 | 530 | { |
531 | 531 | $map = $map[0]; // there can only be one chunk for the base product data |
532 | 532 | |
533 | - $typecode = ( isset( $map['product.type'] ) ? $map['product.type'] : 'default' ); |
|
534 | - $map['product.typeid'] = $this->getTypeId( 'product/type', 'product', $typecode ); |
|
533 | + $typecode = (isset($map['product.type']) ? $map['product.type'] : 'default'); |
|
534 | + $map['product.typeid'] = $this->getTypeId('product/type', 'product', $typecode); |
|
535 | 535 | |
536 | - $product->fromArray( $this->addItemDefaults( $map ) ); |
|
537 | - $manager->saveItem( $product ); |
|
536 | + $product->fromArray($this->addItemDefaults($map)); |
|
537 | + $manager->saveItem($product); |
|
538 | 538 | |
539 | - $list = $processor->process( $product, $list ); |
|
539 | + $list = $processor->process($product, $list); |
|
540 | 540 | } |
541 | 541 | |
542 | 542 | $manager->commit(); |
543 | 543 | } |
544 | - catch( \Exception $e ) |
|
544 | + catch (\Exception $e) |
|
545 | 545 | { |
546 | 546 | $manager->rollback(); |
547 | 547 | |
548 | - $msg = sprintf( 'Unable to import product with code "%1$s": %2$s', $code, $e->getMessage() ); |
|
549 | - $context->getLogger()->log( $msg ); |
|
548 | + $msg = sprintf('Unable to import product with code "%1$s": %2$s', $code, $e->getMessage()); |
|
549 | + $context->getLogger()->log($msg); |
|
550 | 550 | |
551 | 551 | $errors++; |
552 | 552 | } |
553 | 553 | |
554 | - if( $strict && !empty( $list ) ) { |
|
555 | - $context->getLogger()->log( 'Not imported: ' . print_r( $list, true ) ); |
|
554 | + if ($strict && !empty($list)) { |
|
555 | + $context->getLogger()->log('Not imported: ' . print_r($list, true)); |
|
556 | 556 | } |
557 | 557 | } |
558 | 558 | |
@@ -566,9 +566,9 @@ discard block |
||
566 | 566 | * @param array $list Associative list of domain item keys and their values, e.g. "product.status" => 1 |
567 | 567 | * @return array Given associative list enriched by default values if they were not already set |
568 | 568 | */ |
569 | - protected function addItemDefaults( array $list ) |
|
569 | + protected function addItemDefaults(array $list) |
|
570 | 570 | { |
571 | - if( !isset( $list['product.status'] ) ) { |
|
571 | + if (!isset($list['product.status'])) { |
|
572 | 572 | $list['product.status'] = 1; |
573 | 573 | } |
574 | 574 |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | */ |
30 | 30 | public function getName() |
31 | 31 | { |
32 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Log cleanup' ); |
|
32 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Log cleanup'); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public function getDescription() |
42 | 42 | { |
43 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Removes the old log entries from the database and archives them (optional)' ); |
|
43 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Removes the old log entries from the database and archives them (optional)'); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | * @see controller/jobs/admin/log/standard/container/format |
72 | 72 | * @see controller/jobs/admin/log/standard/container/options |
73 | 73 | */ |
74 | - $limit = $config->get( 'controller/jobs/admin/log/standard/limit-days', 30 ); |
|
75 | - $limitDate = date( 'Y-m-d H:i:s', time() - $limit * 86400 ); |
|
74 | + $limit = $config->get('controller/jobs/admin/log/standard/limit-days', 30); |
|
75 | + $limitDate = date('Y-m-d H:i:s', time() - $limit * 86400); |
|
76 | 76 | |
77 | 77 | /** controller/jobs/admin/log/standard/path |
78 | 78 | * Path to a writable directory where the log archive files should be stored |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * @see controller/jobs/admin/log/standard/container/options |
102 | 102 | * @see controller/jobs/admin/log/standard/limit-days |
103 | 103 | */ |
104 | - if( ( $path = $config->get( 'controller/jobs/admin/log/standard/path', null ) ) !== null ) |
|
104 | + if (($path = $config->get('controller/jobs/admin/log/standard/path', null)) !== null) |
|
105 | 105 | { |
106 | 106 | /** controller/jobs/admin/log/standard/container/type |
107 | 107 | * Container file type storing all coupon code files to import |
@@ -175,19 +175,19 @@ discard block |
||
175 | 175 | * @see controller/jobs/admin/log/standard/limit-days |
176 | 176 | */ |
177 | 177 | |
178 | - $type = $config->get( 'controller/jobs/admin/log/standard/container/type', 'Zip' ); |
|
179 | - $format = $config->get( 'controller/jobs/admin/log/standard/container/format', 'CSV' ); |
|
180 | - $options = $config->get( 'controller/jobs/admin/log/standard/container/options', [] ); |
|
178 | + $type = $config->get('controller/jobs/admin/log/standard/container/type', 'Zip'); |
|
179 | + $format = $config->get('controller/jobs/admin/log/standard/container/format', 'CSV'); |
|
180 | + $options = $config->get('controller/jobs/admin/log/standard/container/options', []); |
|
181 | 181 | |
182 | - $path .= DIRECTORY_SEPARATOR . str_replace( ' ', '_', $limitDate ); |
|
183 | - $container = \Aimeos\MW\Container\Factory::getContainer( $path, $type, $format, $options ); |
|
182 | + $path .= DIRECTORY_SEPARATOR . str_replace(' ', '_', $limitDate); |
|
183 | + $container = \Aimeos\MW\Container\Factory::getContainer($path, $type, $format, $options); |
|
184 | 184 | } |
185 | 185 | |
186 | - $manager = \Aimeos\MAdmin\Factory::createManager( $context, 'log' ); |
|
186 | + $manager = \Aimeos\MAdmin\Factory::createManager($context, 'log'); |
|
187 | 187 | |
188 | 188 | $search = $manager->createSearch(); |
189 | - $search->setConditions( $search->compare( '<=', 'log.timestamp', $limitDate ) ); |
|
190 | - $search->setSortations( array( $search->sort( '+', 'log.timestamp' ) ) ); |
|
189 | + $search->setConditions($search->compare('<=', 'log.timestamp', $limitDate)); |
|
190 | + $search->setSortations(array($search->sort('+', 'log.timestamp'))); |
|
191 | 191 | |
192 | 192 | $start = 0; |
193 | 193 | $contents = []; |
@@ -195,37 +195,37 @@ discard block |
||
195 | 195 | do |
196 | 196 | { |
197 | 197 | $ids = []; |
198 | - $items = $manager->searchItems( $search ); |
|
198 | + $items = $manager->searchItems($search); |
|
199 | 199 | |
200 | - foreach( $items as $id => $item ) |
|
200 | + foreach ($items as $id => $item) |
|
201 | 201 | { |
202 | - if( $container !== null ) |
|
202 | + if ($container !== null) |
|
203 | 203 | { |
204 | 204 | $facility = $item->getFacility(); |
205 | 205 | |
206 | - if( !isset( $contents[$facility] ) ) { |
|
207 | - $contents[$facility] = $container->create( $facility ); |
|
206 | + if (!isset($contents[$facility])) { |
|
207 | + $contents[$facility] = $container->create($facility); |
|
208 | 208 | } |
209 | 209 | |
210 | - $contents[$facility]->add( $item->toArray() ); |
|
210 | + $contents[$facility]->add($item->toArray()); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | $ids[] = $id; |
214 | 214 | } |
215 | 215 | |
216 | - $manager->deleteItems( $ids ); |
|
216 | + $manager->deleteItems($ids); |
|
217 | 217 | |
218 | - $count = count( $items ); |
|
218 | + $count = count($items); |
|
219 | 219 | $start += $count; |
220 | - $search->setSlice( $start ); |
|
220 | + $search->setSlice($start); |
|
221 | 221 | } |
222 | - while( $count >= $search->getSliceSize() ); |
|
222 | + while ($count >= $search->getSliceSize()); |
|
223 | 223 | |
224 | 224 | |
225 | - if( $container !== null && !empty( $contents ) ) |
|
225 | + if ($container !== null && !empty($contents)) |
|
226 | 226 | { |
227 | - foreach( $contents as $content ) { |
|
228 | - $container->add( $content ); |
|
227 | + foreach ($contents as $content) { |
|
228 | + $container->add($content); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | $container->close(); |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | */ |
30 | 30 | public function getName() |
31 | 31 | { |
32 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Capture authorized payments' ); |
|
32 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Capture authorized payments'); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public function getDescription() |
42 | 42 | { |
43 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Authorized payments of orders will be captured after dispatching or after a configurable amount of time' ); |
|
43 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Authorized payments of orders will be captured after dispatching or after a configurable amount of time'); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | * @category User |
69 | 69 | * @category Developer |
70 | 70 | */ |
71 | - $days = $config->get( 'controller/jobs/order/service/payment/limit-days', 90 ); |
|
72 | - $date = date( 'Y-m-d 00:00:00', time() - 86400 * $days ); |
|
71 | + $days = $config->get('controller/jobs/order/service/payment/limit-days', 90); |
|
72 | + $date = date('Y-m-d 00:00:00', time() - 86400 * $days); |
|
73 | 73 | |
74 | 74 | /** controller/jobs/order/service/payment/capture-days |
75 | 75 | * Automatically capture payments after the configured amount of days |
@@ -84,90 +84,90 @@ discard block |
||
84 | 84 | * @category User |
85 | 85 | * @category Developer |
86 | 86 | */ |
87 | - $capDays = $config->get( 'controller/jobs/order/service/payment/capture-days', null ); |
|
87 | + $capDays = $config->get('controller/jobs/order/service/payment/capture-days', null); |
|
88 | 88 | |
89 | 89 | |
90 | - $serviceManager = \Aimeos\MShop\Factory::createManager( $context, 'service' ); |
|
90 | + $serviceManager = \Aimeos\MShop\Factory::createManager($context, 'service'); |
|
91 | 91 | $serviceSearch = $serviceManager->createSearch(); |
92 | - $serviceSearch->setConditions( $serviceSearch->compare( '==', 'service.type.code', 'payment' ) ); |
|
92 | + $serviceSearch->setConditions($serviceSearch->compare('==', 'service.type.code', 'payment')); |
|
93 | 93 | |
94 | - $orderManager = \Aimeos\MShop\Factory::createManager( $context, 'order' ); |
|
94 | + $orderManager = \Aimeos\MShop\Factory::createManager($context, 'order'); |
|
95 | 95 | $orderSearch = $orderManager->createSearch(); |
96 | 96 | |
97 | - $status = array( \Aimeos\MShop\Order\Item\Base::STAT_DISPATCHED, \Aimeos\MShop\Order\Item\Base::STAT_DELIVERED ); |
|
97 | + $status = array(\Aimeos\MShop\Order\Item\Base::STAT_DISPATCHED, \Aimeos\MShop\Order\Item\Base::STAT_DELIVERED); |
|
98 | 98 | $start = 0; |
99 | 99 | |
100 | 100 | do |
101 | 101 | { |
102 | - $serviceItems = $serviceManager->searchItems( $serviceSearch ); |
|
102 | + $serviceItems = $serviceManager->searchItems($serviceSearch); |
|
103 | 103 | |
104 | - foreach( $serviceItems as $serviceItem ) |
|
104 | + foreach ($serviceItems as $serviceItem) |
|
105 | 105 | { |
106 | 106 | try |
107 | 107 | { |
108 | - $serviceProvider = $serviceManager->getProvider( $serviceItem ); |
|
108 | + $serviceProvider = $serviceManager->getProvider($serviceItem); |
|
109 | 109 | |
110 | - if( !$serviceProvider->isImplemented( \Aimeos\MShop\Service\Provider\Payment\Base::FEAT_CAPTURE ) ) { |
|
110 | + if (!$serviceProvider->isImplemented(\Aimeos\MShop\Service\Provider\Payment\Base::FEAT_CAPTURE)) { |
|
111 | 111 | continue; |
112 | 112 | } |
113 | 113 | |
114 | 114 | |
115 | 115 | $expr = []; |
116 | - $expr[] = $orderSearch->compare( '>', 'order.datepayment', $date ); |
|
116 | + $expr[] = $orderSearch->compare('>', 'order.datepayment', $date); |
|
117 | 117 | |
118 | - if( $capDays !== null ) |
|
118 | + if ($capDays !== null) |
|
119 | 119 | { |
120 | - $capdate = date( 'Y-m-d 00:00:00', time() - 86400 * $capDays ); |
|
121 | - $expr[] = $orderSearch->compare( '<=', 'order.datepayment', $capdate ); |
|
120 | + $capdate = date('Y-m-d 00:00:00', time() - 86400 * $capDays); |
|
121 | + $expr[] = $orderSearch->compare('<=', 'order.datepayment', $capdate); |
|
122 | 122 | } |
123 | 123 | else |
124 | 124 | { |
125 | - $expr[] = $orderSearch->compare( '==', 'order.statusdelivery', $status ); |
|
125 | + $expr[] = $orderSearch->compare('==', 'order.statusdelivery', $status); |
|
126 | 126 | } |
127 | 127 | |
128 | - $expr[] = $orderSearch->compare( '==', 'order.statuspayment', \Aimeos\MShop\Order\Item\Base::PAY_AUTHORIZED ); |
|
129 | - $expr[] = $orderSearch->compare( '==', 'order.base.service.code', $serviceItem->getCode() ); |
|
130 | - $expr[] = $orderSearch->compare( '==', 'order.base.service.type', 'payment' ); |
|
128 | + $expr[] = $orderSearch->compare('==', 'order.statuspayment', \Aimeos\MShop\Order\Item\Base::PAY_AUTHORIZED); |
|
129 | + $expr[] = $orderSearch->compare('==', 'order.base.service.code', $serviceItem->getCode()); |
|
130 | + $expr[] = $orderSearch->compare('==', 'order.base.service.type', 'payment'); |
|
131 | 131 | |
132 | - $orderSearch->setConditions( $orderSearch->combine( '&&', $expr ) ); |
|
132 | + $orderSearch->setConditions($orderSearch->combine('&&', $expr)); |
|
133 | 133 | |
134 | 134 | |
135 | 135 | $orderStart = 0; |
136 | 136 | |
137 | 137 | do |
138 | 138 | { |
139 | - $orderItems = $orderManager->searchItems( $orderSearch ); |
|
139 | + $orderItems = $orderManager->searchItems($orderSearch); |
|
140 | 140 | |
141 | - foreach( $orderItems as $orderItem ) |
|
141 | + foreach ($orderItems as $orderItem) |
|
142 | 142 | { |
143 | 143 | try |
144 | 144 | { |
145 | - $serviceProvider->capture( $orderItem ); |
|
145 | + $serviceProvider->capture($orderItem); |
|
146 | 146 | } |
147 | - catch( \Exception $e ) |
|
147 | + catch (\Exception $e) |
|
148 | 148 | { |
149 | 149 | $str = 'Error while capturing payment for order with ID "%1$s": %2$s'; |
150 | - $context->getLogger()->log( sprintf( $str, $orderItem->getId(), $e->getMessage() ) ); |
|
150 | + $context->getLogger()->log(sprintf($str, $orderItem->getId(), $e->getMessage())); |
|
151 | 151 | } |
152 | 152 | } |
153 | 153 | |
154 | - $orderCount = count( $orderItems ); |
|
154 | + $orderCount = count($orderItems); |
|
155 | 155 | $orderStart += $orderCount; |
156 | - $orderSearch->setSlice( $orderStart ); |
|
156 | + $orderSearch->setSlice($orderStart); |
|
157 | 157 | } |
158 | - while( $orderCount >= $orderSearch->getSliceSize() ); |
|
158 | + while ($orderCount >= $orderSearch->getSliceSize()); |
|
159 | 159 | } |
160 | - catch( \Exception $e ) |
|
160 | + catch (\Exception $e) |
|
161 | 161 | { |
162 | 162 | $str = 'Error while capturing payments for service with ID "%1$s": %2$s'; |
163 | - $context->getLogger()->log( sprintf( $str, $serviceItem->getId(), $e->getMessage() ) ); |
|
163 | + $context->getLogger()->log(sprintf($str, $serviceItem->getId(), $e->getMessage())); |
|
164 | 164 | } |
165 | 165 | } |
166 | 166 | |
167 | - $count = count( $serviceItems ); |
|
167 | + $count = count($serviceItems); |
|
168 | 168 | $start += $count; |
169 | - $serviceSearch->setSlice( $start ); |
|
169 | + $serviceSearch->setSlice($start); |
|
170 | 170 | } |
171 | - while( $count >= $serviceSearch->getSliceSize() ); |
|
171 | + while ($count >= $serviceSearch->getSliceSize()); |
|
172 | 172 | } |
173 | 173 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | */ |
30 | 30 | public function getName() |
31 | 31 | { |
32 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Removes unpaid orders' ); |
|
32 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Removes unpaid orders'); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public function getDescription() |
42 | 42 | { |
43 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Deletes unpaid orders to keep the database clean' ); |
|
43 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Deletes unpaid orders to keep the database clean'); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | |
@@ -52,9 +52,9 @@ discard block |
||
52 | 52 | public function run() |
53 | 53 | { |
54 | 54 | $context = $this->getContext(); |
55 | - $controller = \Aimeos\Controller\Common\Order\Factory::createController( $context ); |
|
56 | - $baseManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base' ); |
|
57 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'order' ); |
|
55 | + $controller = \Aimeos\Controller\Common\Order\Factory::createController($context); |
|
56 | + $baseManager = \Aimeos\MShop\Factory::createManager($context, 'order/base'); |
|
57 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'order'); |
|
58 | 58 | |
59 | 59 | /** controller/jobs/order/cleanup/unpaid/keep-days |
60 | 60 | * Removes all orders from the database that are unpaid |
@@ -71,35 +71,35 @@ discard block |
||
71 | 71 | * @since 2014.07 |
72 | 72 | * @category User |
73 | 73 | */ |
74 | - $days = $context->getConfig()->get( 'controller/jobs/order/cleanup/unpaid/keep-days', 3 ); |
|
75 | - $limit = date( 'Y-m-d H:i:s', time() - 86400 * $days ); |
|
74 | + $days = $context->getConfig()->get('controller/jobs/order/cleanup/unpaid/keep-days', 3); |
|
75 | + $limit = date('Y-m-d H:i:s', time() - 86400 * $days); |
|
76 | 76 | |
77 | 77 | $search = $manager->createSearch(); |
78 | 78 | $expr = array( |
79 | - $search->compare( '<', 'order.mtime', $limit ), |
|
80 | - $search->compare( '<', 'order.statuspayment', \Aimeos\MShop\Order\Item\Base::PAY_REFUND ), |
|
79 | + $search->compare('<', 'order.mtime', $limit), |
|
80 | + $search->compare('<', 'order.statuspayment', \Aimeos\MShop\Order\Item\Base::PAY_REFUND), |
|
81 | 81 | ); |
82 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
82 | + $search->setConditions($search->combine('&&', $expr)); |
|
83 | 83 | |
84 | 84 | $start = 0; |
85 | 85 | |
86 | 86 | do |
87 | 87 | { |
88 | 88 | $baseIds = []; |
89 | - $items = $manager->searchItems( $search ); |
|
89 | + $items = $manager->searchItems($search); |
|
90 | 90 | |
91 | - foreach( $items as $item ) |
|
91 | + foreach ($items as $item) |
|
92 | 92 | { |
93 | - $controller->unblock( $item ); |
|
93 | + $controller->unblock($item); |
|
94 | 94 | $baseIds[] = $item->getBaseId(); |
95 | 95 | } |
96 | 96 | |
97 | - $baseManager->deleteItems( $baseIds ); |
|
97 | + $baseManager->deleteItems($baseIds); |
|
98 | 98 | |
99 | - $count = count( $items ); |
|
99 | + $count = count($items); |
|
100 | 100 | $start += $count; |
101 | - $search->setSlice( $start ); |
|
101 | + $search->setSlice($start); |
|
102 | 102 | } |
103 | - while( $count >= $search->getSliceSize() ); |
|
103 | + while ($count >= $search->getSliceSize()); |
|
104 | 104 | } |
105 | 105 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | */ |
30 | 30 | public function getName() |
31 | 31 | { |
32 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Removes unfinished orders' ); |
|
32 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Removes unfinished orders'); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public function getDescription() |
42 | 42 | { |
43 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Deletes unfinished orders an makes their products and coupon codes available again' ); |
|
43 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Deletes unfinished orders an makes their products and coupon codes available again'); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | |
@@ -52,9 +52,9 @@ discard block |
||
52 | 52 | public function run() |
53 | 53 | { |
54 | 54 | $context = $this->getContext(); |
55 | - $controller = \Aimeos\Controller\Common\Order\Factory::createController( $context ); |
|
56 | - $baseManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base' ); |
|
57 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'order' ); |
|
55 | + $controller = \Aimeos\Controller\Common\Order\Factory::createController($context); |
|
56 | + $baseManager = \Aimeos\MShop\Factory::createManager($context, 'order/base'); |
|
57 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'order'); |
|
58 | 58 | |
59 | 59 | /** controller/jobs/order/cleanup/unfinished/keep-hours |
60 | 60 | * Release the ordered products after the configured time if no payment was confirmed |
@@ -74,35 +74,35 @@ discard block |
||
74 | 74 | * @since 2014.07 |
75 | 75 | * @category User |
76 | 76 | */ |
77 | - $hours = $context->getConfig()->get( 'controller/jobs/order/cleanup/unfinished/keep-hours', 24 ); |
|
78 | - $limit = date( 'Y-m-d H:i:s', time() - 3600 * $hours ); |
|
77 | + $hours = $context->getConfig()->get('controller/jobs/order/cleanup/unfinished/keep-hours', 24); |
|
78 | + $limit = date('Y-m-d H:i:s', time() - 3600 * $hours); |
|
79 | 79 | |
80 | 80 | $search = $manager->createSearch(); |
81 | 81 | $expr = array( |
82 | - $search->compare( '<', 'order.mtime', $limit ), |
|
83 | - $search->compare( '==', 'order.statuspayment', \Aimeos\MShop\Order\Item\Base::PAY_UNFINISHED ), |
|
82 | + $search->compare('<', 'order.mtime', $limit), |
|
83 | + $search->compare('==', 'order.statuspayment', \Aimeos\MShop\Order\Item\Base::PAY_UNFINISHED), |
|
84 | 84 | ); |
85 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
85 | + $search->setConditions($search->combine('&&', $expr)); |
|
86 | 86 | |
87 | 87 | $start = 0; |
88 | 88 | |
89 | 89 | do |
90 | 90 | { |
91 | 91 | $baseIds = []; |
92 | - $items = $manager->searchItems( $search ); |
|
92 | + $items = $manager->searchItems($search); |
|
93 | 93 | |
94 | - foreach( $items as $item ) |
|
94 | + foreach ($items as $item) |
|
95 | 95 | { |
96 | - $controller->unblock( $item ); |
|
96 | + $controller->unblock($item); |
|
97 | 97 | $baseIds[] = $item->getBaseId(); |
98 | 98 | } |
99 | 99 | |
100 | - $baseManager->deleteItems( $baseIds ); |
|
100 | + $baseManager->deleteItems($baseIds); |
|
101 | 101 | |
102 | - $count = count( $items ); |
|
102 | + $count = count($items); |
|
103 | 103 | $start += $count; |
104 | - $search->setSlice( $start ); |
|
104 | + $search->setSlice($start); |
|
105 | 105 | } |
106 | - while( $count >= $search->getSliceSize() ); |
|
106 | + while ($count >= $search->getSliceSize()); |
|
107 | 107 | } |
108 | 108 | } |