Completed
Push — master ( 475749...c0b163 )
by Aimeos
02:12
created
controller/jobs/templates/product/export/items-body-standard.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -9,10 +9,10 @@  discard block
 block discarded – undo
9 9
 
10 10
 ?>
11 11
 <productlist>
12
-    <?php foreach( $this->get( 'exportItems', [] ) as $id => $item ) : ?>
12
+    <?php foreach ($this->get('exportItems', []) as $id => $item) : ?>
13 13
 
14
-        <product-content id="<?php echo $enc->attr( $id ); ?>" >
15
-            <productitem id="<?php echo $enc->attr( $id ); ?>" siteid="<?php echo $enc->attr( $item->getSiteId() ); ?>" ctime="<?php echo $enc->attr( $item->getTimeCreated() ); ?>" mtime="<?php echo $enc->attr( $item->getTimeModified() ); ?>" editor="<?php echo $enc->attr( $item->getEditor() ); ?>">
14
+        <product-content id="<?php echo $enc->attr($id); ?>" >
15
+            <productitem id="<?php echo $enc->attr($id); ?>" siteid="<?php echo $enc->attr($item->getSiteId()); ?>" ctime="<?php echo $enc->attr($item->getTimeCreated()); ?>" mtime="<?php echo $enc->attr($item->getTimeModified()); ?>" editor="<?php echo $enc->attr($item->getEditor()); ?>">
16 16
                 <type><![CDATA[<?php echo $item->getType(); ?>]]></type>
17 17
                 <code><![CDATA[<?php echo $item->getCode(); ?>]]></code>
18 18
                 <label><![CDATA[<?php echo $item->getCode(); ?>]]></label>
@@ -22,10 +22,10 @@  discard block
 block discarded – undo
22 22
             </productitem>
23 23
             <list>
24 24
                 <text>
25
-                    <?php foreach( $item->getListItems( 'text' ) as $listItem ) : ?>
25
+                    <?php foreach ($item->getListItems('text') as $listItem) : ?>
26 26
                         <?php if ($refItem = $listItem->getRefItem()) { ?>
27 27
 
28
-                            <textitem id="<?php echo $enc->attr( $refItem->getId() ); ?>" siteid="<?php echo $enc->attr( $refItem->getSiteId() ); ?>" ctime="<?php echo $enc->attr( $refItem->getTimeCreated() ); ?>" mtime="<?php echo $enc->attr( $refItem->getTimeModified() ); ?>" editor="<?php echo $enc->attr( $refItem->getEditor() ); ?>" list.id="<?php echo $enc->attr( $listItem->getId() ); ?>" list.siteid="<?php echo $enc->attr( $listItem->getSiteId() ); ?>" list.parentid="<?php echo $enc->attr( $listItem->getParentId() ); ?>" list.type="<?php echo $enc->attr( $listItem->getType() ); ?>" list.domain="<?php echo $enc->attr( $listItem->getDomain() ); ?>" list.config="<?php echo $enc->attr( json_encode( $listItem->getConfig() ) ); ?>" list.start="<?php echo $enc->attr( $listItem->getDateStart() ); ?>" list.end="<?php echo $enc->attr( $listItem->getDateEnd() ); ?>" list.position="<?php echo $enc->attr( $listItem->getPosition() ); ?>" list.status="<?php echo $enc->attr( $listItem->getStatus() ); ?>" list.ctime="<?php echo $enc->attr( $listItem->getTimeCreated() ); ?>" list.mtime="<?php echo $enc->attr( $listItem->getTimeModified() ); ?>" list.editor="<?php echo $enc->attr( $listItem->getEditor() ); ?>">
28
+                            <textitem id="<?php echo $enc->attr($refItem->getId()); ?>" siteid="<?php echo $enc->attr($refItem->getSiteId()); ?>" ctime="<?php echo $enc->attr($refItem->getTimeCreated()); ?>" mtime="<?php echo $enc->attr($refItem->getTimeModified()); ?>" editor="<?php echo $enc->attr($refItem->getEditor()); ?>" list.id="<?php echo $enc->attr($listItem->getId()); ?>" list.siteid="<?php echo $enc->attr($listItem->getSiteId()); ?>" list.parentid="<?php echo $enc->attr($listItem->getParentId()); ?>" list.type="<?php echo $enc->attr($listItem->getType()); ?>" list.domain="<?php echo $enc->attr($listItem->getDomain()); ?>" list.config="<?php echo $enc->attr(json_encode($listItem->getConfig())); ?>" list.start="<?php echo $enc->attr($listItem->getDateStart()); ?>" list.end="<?php echo $enc->attr($listItem->getDateEnd()); ?>" list.position="<?php echo $enc->attr($listItem->getPosition()); ?>" list.status="<?php echo $enc->attr($listItem->getStatus()); ?>" list.ctime="<?php echo $enc->attr($listItem->getTimeCreated()); ?>" list.mtime="<?php echo $enc->attr($listItem->getTimeModified()); ?>" list.editor="<?php echo $enc->attr($listItem->getEditor()); ?>">
29 29
                                 <type><![CDATA[<?php echo $refItem->getType(); ?>]]></type>
30 30
                                 <languageid><![CDATA[<?php echo $refItem->getLanguageId(); ?>]]></languageid>
31 31
                                 <label><![CDATA[<?php echo $refItem->getLabel(); ?>]]></label>
@@ -37,10 +37,10 @@  discard block
 block discarded – undo
37 37
 
38 38
                 </text>
39 39
                 <media>
40
-                    <?php foreach( $item->getListItems( 'media' ) as $listItem ) : ?>
40
+                    <?php foreach ($item->getListItems('media') as $listItem) : ?>
41 41
                         <?php if ($refItem = $listItem->getRefItem()) { ?>
42 42
 
43
-                            <mediaitem id="<?php echo $enc->attr( $refItem->getId() ); ?>" siteid="<?php echo $enc->attr( $refItem->getSiteId() ); ?>" ctime="<?php echo $enc->attr( $refItem->getTimeCreated() ); ?>" mtime="<?php echo $enc->attr( $refItem->getTimeModified() ); ?>" editor="<?php echo $enc->attr( $refItem->getEditor() ); ?>" list.id="<?php echo $enc->attr( $listItem->getId() ); ?>" list.siteid="<?php echo $enc->attr( $listItem->getSiteId() ); ?>" list.parentid="<?php echo $enc->attr( $listItem->getParentId() ); ?>" list.type="<?php echo $enc->attr( $listItem->getType() ); ?>" list.config="<?php echo $enc->attr( json_encode( $listItem->getConfig() ) ); ?>" list.start="<?php echo $enc->attr( $listItem->getDateStart() ); ?>" list.end="<?php echo $enc->attr( $listItem->getDateEnd() ); ?>" list.position="<?php echo $enc->attr( $listItem->getPosition() ); ?>" list.status="<?php echo $enc->attr( $listItem->getStatus() ); ?>" list.ctime="<?php echo $enc->attr( $listItem->getTimeCreated() ); ?>" list.mtime="<?php echo $enc->attr( $listItem->getTimeModified() ); ?>" list.editor="<?php echo $enc->attr( $listItem->getEditor() ); ?>">
43
+                            <mediaitem id="<?php echo $enc->attr($refItem->getId()); ?>" siteid="<?php echo $enc->attr($refItem->getSiteId()); ?>" ctime="<?php echo $enc->attr($refItem->getTimeCreated()); ?>" mtime="<?php echo $enc->attr($refItem->getTimeModified()); ?>" editor="<?php echo $enc->attr($refItem->getEditor()); ?>" list.id="<?php echo $enc->attr($listItem->getId()); ?>" list.siteid="<?php echo $enc->attr($listItem->getSiteId()); ?>" list.parentid="<?php echo $enc->attr($listItem->getParentId()); ?>" list.type="<?php echo $enc->attr($listItem->getType()); ?>" list.config="<?php echo $enc->attr(json_encode($listItem->getConfig())); ?>" list.start="<?php echo $enc->attr($listItem->getDateStart()); ?>" list.end="<?php echo $enc->attr($listItem->getDateEnd()); ?>" list.position="<?php echo $enc->attr($listItem->getPosition()); ?>" list.status="<?php echo $enc->attr($listItem->getStatus()); ?>" list.ctime="<?php echo $enc->attr($listItem->getTimeCreated()); ?>" list.mtime="<?php echo $enc->attr($listItem->getTimeModified()); ?>" list.editor="<?php echo $enc->attr($listItem->getEditor()); ?>">
44 44
                                 <type><![CDATA[<?php echo $refItem->getType(); ?>]]></type>
45 45
                                 <languageid><![CDATA[<?php echo $refItem->getLanguageId(); ?>]]></languageid>
46 46
                                 <label><![CDATA[<?php echo $refItem->getLabel(); ?>]]></label>
@@ -54,10 +54,10 @@  discard block
 block discarded – undo
54 54
 
55 55
                 </media>
56 56
                 <price>
57
-                    <?php foreach( $item->getListItems( 'price' ) as $listItem ) : ?>
57
+                    <?php foreach ($item->getListItems('price') as $listItem) : ?>
58 58
                         <?php if ($refItem = $listItem->getRefItem()) { ?>
59 59
 
60
-                            <priceitem id="<?php echo $enc->attr( $refItem->getId() ); ?>" siteid="<?php echo $enc->attr( $refItem->getSiteId() ); ?>" ctime="<?php echo $enc->attr( $refItem->getTimeCreated() ); ?>" mtime="<?php echo $enc->attr( $refItem->getTimeModified() ); ?>" editor="<?php echo $enc->attr( $refItem->getEditor() ); ?>" list.id="<?php echo $enc->attr( $listItem->getId() ); ?>" list.siteid="<?php echo $enc->attr( $listItem->getSiteId() ); ?>" list.parentid="<?php echo $enc->attr( $listItem->getParentId() ); ?>" list.type="<?php echo $enc->attr( $listItem->getType() ); ?>" list.config="<?php echo $enc->attr( json_encode( $listItem->getConfig() ) ); ?>" list.start="<?php echo $enc->attr( $listItem->getDateStart() ); ?>" list.end="<?php echo $enc->attr( $listItem->getDateEnd() ); ?>" list.position="<?php echo $enc->attr( $listItem->getPosition() ); ?>" list.status="<?php echo $enc->attr( $listItem->getStatus() ); ?>" list.ctime="<?php echo $enc->attr( $listItem->getTimeCreated() ); ?>" list.mtime="<?php echo $enc->attr( $listItem->getTimeModified() ); ?>" list.editor="<?php echo $enc->attr( $listItem->getEditor() ); ?>">
60
+                            <priceitem id="<?php echo $enc->attr($refItem->getId()); ?>" siteid="<?php echo $enc->attr($refItem->getSiteId()); ?>" ctime="<?php echo $enc->attr($refItem->getTimeCreated()); ?>" mtime="<?php echo $enc->attr($refItem->getTimeModified()); ?>" editor="<?php echo $enc->attr($refItem->getEditor()); ?>" list.id="<?php echo $enc->attr($listItem->getId()); ?>" list.siteid="<?php echo $enc->attr($listItem->getSiteId()); ?>" list.parentid="<?php echo $enc->attr($listItem->getParentId()); ?>" list.type="<?php echo $enc->attr($listItem->getType()); ?>" list.config="<?php echo $enc->attr(json_encode($listItem->getConfig())); ?>" list.start="<?php echo $enc->attr($listItem->getDateStart()); ?>" list.end="<?php echo $enc->attr($listItem->getDateEnd()); ?>" list.position="<?php echo $enc->attr($listItem->getPosition()); ?>" list.status="<?php echo $enc->attr($listItem->getStatus()); ?>" list.ctime="<?php echo $enc->attr($listItem->getTimeCreated()); ?>" list.mtime="<?php echo $enc->attr($listItem->getTimeModified()); ?>" list.editor="<?php echo $enc->attr($listItem->getEditor()); ?>">
61 61
                                 <type><![CDATA[<?php echo $refItem->getType(); ?>]]></type>
62 62
                                 <currencyid><![CDATA[<?php echo $refItem->getCurrencyId(); ?>]]></currencyid>
63 63
                                 <quantity><![CDATA[<?php echo $refItem->getQuantity(); ?>]]></quantity>
@@ -73,10 +73,10 @@  discard block
 block discarded – undo
73 73
 
74 74
                 </price>
75 75
                 <attribute>
76
-                    <?php foreach( $item->getListItems( 'attribute' ) as $listItem ) : ?>
76
+                    <?php foreach ($item->getListItems('attribute') as $listItem) : ?>
77 77
                         <?php if ($refItem = $listItem->getRefItem()) { ?>
78 78
 
79
-                            <attributeitem id="<?php echo $enc->attr( $refItem->getId() ); ?>" siteid="<?php echo $enc->attr( $refItem->getSiteId() ); ?>" ctime="<?php echo $enc->attr( $refItem->getTimeCreated() ); ?>" mtime="<?php echo $enc->attr( $refItem->getTimeModified() ); ?>" editor="<?php echo $enc->attr( $refItem->getEditor() ); ?>" list.id="<?php echo $enc->attr( $listItem->getId() ); ?>" list.siteid="<?php echo $enc->attr( $listItem->getSiteId() ); ?>" list.parentid="<?php echo $enc->attr( $listItem->getParentId() ); ?>" list.type="<?php echo $enc->attr( $listItem->getType() ); ?>" list.config="<?php echo $enc->attr( json_encode( $listItem->getConfig() ) ); ?>" list.start="<?php echo $enc->attr( $listItem->getDateStart() ); ?>" list.end="<?php echo $enc->attr( $listItem->getDateEnd() ); ?>" list.position="<?php echo $enc->attr( $listItem->getPosition() ); ?>" list.status="<?php echo $enc->attr( $listItem->getStatus() ); ?>" list.ctime="<?php echo $enc->attr( $listItem->getTimeCreated() ); ?>" list.mtime="<?php echo $enc->attr( $listItem->getTimeModified() ); ?>" list.editor="<?php echo $enc->attr( $listItem->getEditor() ); ?>">
79
+                            <attributeitem id="<?php echo $enc->attr($refItem->getId()); ?>" siteid="<?php echo $enc->attr($refItem->getSiteId()); ?>" ctime="<?php echo $enc->attr($refItem->getTimeCreated()); ?>" mtime="<?php echo $enc->attr($refItem->getTimeModified()); ?>" editor="<?php echo $enc->attr($refItem->getEditor()); ?>" list.id="<?php echo $enc->attr($listItem->getId()); ?>" list.siteid="<?php echo $enc->attr($listItem->getSiteId()); ?>" list.parentid="<?php echo $enc->attr($listItem->getParentId()); ?>" list.type="<?php echo $enc->attr($listItem->getType()); ?>" list.config="<?php echo $enc->attr(json_encode($listItem->getConfig())); ?>" list.start="<?php echo $enc->attr($listItem->getDateStart()); ?>" list.end="<?php echo $enc->attr($listItem->getDateEnd()); ?>" list.position="<?php echo $enc->attr($listItem->getPosition()); ?>" list.status="<?php echo $enc->attr($listItem->getStatus()); ?>" list.ctime="<?php echo $enc->attr($listItem->getTimeCreated()); ?>" list.mtime="<?php echo $enc->attr($listItem->getTimeModified()); ?>" list.editor="<?php echo $enc->attr($listItem->getEditor()); ?>">
80 80
                                 <type><![CDATA[<?php echo $refItem->getType(); ?>]]></type>
81 81
                                 <code><![CDATA[<?php echo $refItem->getCode(); ?>]]></code>
82 82
                                 <label><![CDATA[<?php echo $refItem->getLabel(); ?>]]></label>
@@ -88,10 +88,10 @@  discard block
 block discarded – undo
88 88
 
89 89
                 </attribute>
90 90
                 <product>
91
-                    <?php foreach( $item->getListItems( 'product' ) as $listItem ) : ?>
91
+                    <?php foreach ($item->getListItems('product') as $listItem) : ?>
92 92
                         <?php if ($refItem = $listItem->getRefItem()) { ?>
93 93
 
94
-                            <productitem id="<?php echo $enc->attr( $refItem->getId() ); ?>" siteid="<?php echo $enc->attr( $refItem->getSiteId() ); ?>" ctime="<?php echo $enc->attr( $refItem->getTimeCreated() ); ?>" mtime="<?php echo $enc->attr( $refItem->getTimeModified() ); ?>" editor="<?php echo $enc->attr( $refItem->getEditor() ); ?>" list.id="<?php echo $enc->attr( $listItem->getId() ); ?>" list.siteid="<?php echo $enc->attr( $listItem->getSiteId() ); ?>" list.parentid="<?php echo $enc->attr( $listItem->getParentId() ); ?>" list.type="<?php echo $enc->attr( $listItem->getType() ); ?>" list.config="<?php echo $enc->attr( json_encode( $listItem->getConfig() ) ); ?>" list.start="<?php echo $enc->attr( $listItem->getDateStart() ); ?>" list.end="<?php echo $enc->attr( $listItem->getDateEnd() ); ?>" list.position="<?php echo $enc->attr( $listItem->getPosition() ); ?>" list.status="<?php echo $enc->attr( $listItem->getStatus() ); ?>" list.ctime="<?php echo $enc->attr( $listItem->getTimeCreated() ); ?>" list.mtime="<?php echo $enc->attr( $listItem->getTimeModified() ); ?>" list.editor="<?php echo $enc->attr( $listItem->getEditor() ); ?>">
94
+                            <productitem id="<?php echo $enc->attr($refItem->getId()); ?>" siteid="<?php echo $enc->attr($refItem->getSiteId()); ?>" ctime="<?php echo $enc->attr($refItem->getTimeCreated()); ?>" mtime="<?php echo $enc->attr($refItem->getTimeModified()); ?>" editor="<?php echo $enc->attr($refItem->getEditor()); ?>" list.id="<?php echo $enc->attr($listItem->getId()); ?>" list.siteid="<?php echo $enc->attr($listItem->getSiteId()); ?>" list.parentid="<?php echo $enc->attr($listItem->getParentId()); ?>" list.type="<?php echo $enc->attr($listItem->getType()); ?>" list.config="<?php echo $enc->attr(json_encode($listItem->getConfig())); ?>" list.start="<?php echo $enc->attr($listItem->getDateStart()); ?>" list.end="<?php echo $enc->attr($listItem->getDateEnd()); ?>" list.position="<?php echo $enc->attr($listItem->getPosition()); ?>" list.status="<?php echo $enc->attr($listItem->getStatus()); ?>" list.ctime="<?php echo $enc->attr($listItem->getTimeCreated()); ?>" list.mtime="<?php echo $enc->attr($listItem->getTimeModified()); ?>" list.editor="<?php echo $enc->attr($listItem->getEditor()); ?>">
95 95
                                 <type><![CDATA[<?php echo $item->getType(); ?>]]></type>
96 96
                                 <code><![CDATA[<?php echo $item->getCode(); ?>]]></code>
97 97
                                 <label><![CDATA[<?php echo $item->getCode(); ?>]]></label>
Please login to merge, or discard this patch.
controller/jobs/tests/Controller/Jobs/Product/Import/Csv/StandardTest.php 1 patch
Spacing   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -18,119 +18,119 @@  discard block
 block discarded – undo
18 18
 
19 19
 	protected function setUp()
20 20
 	{
21
-		\Aimeos\MShop\Factory::setCache( true );
21
+		\Aimeos\MShop\Factory::setCache(true);
22 22
 
23 23
 		$this->context = \TestHelperJobs::getContext();
24 24
 		$this->aimeos = \TestHelperJobs::getAimeos();
25 25
 		$config = $this->context->getConfig();
26 26
 
27
-		$config->set( 'controller/jobs/product/import/csv/skip-lines', 1 );
28
-		$config->set( 'controller/jobs/product/import/csv/location', __DIR__ . '/_testfiles/valid' );
27
+		$config->set('controller/jobs/product/import/csv/skip-lines', 1);
28
+		$config->set('controller/jobs/product/import/csv/location', __DIR__ . '/_testfiles/valid');
29 29
 
30
-		$this->object = new \Aimeos\Controller\Jobs\Product\Import\Csv\Standard( $this->context, $this->aimeos );
30
+		$this->object = new \Aimeos\Controller\Jobs\Product\Import\Csv\Standard($this->context, $this->aimeos);
31 31
 	}
32 32
 
33 33
 
34 34
 	protected function tearDown()
35 35
 	{
36
-		\Aimeos\MShop\Factory::setCache( false );
36
+		\Aimeos\MShop\Factory::setCache(false);
37 37
 		\Aimeos\MShop\Factory::clear();
38 38
 
39 39
 		$this->object = null;
40 40
 
41
-		if( file_exists( 'tmp/import.zip' ) ) {
42
-			unlink( 'tmp/import.zip' );
41
+		if (file_exists('tmp/import.zip')) {
42
+			unlink('tmp/import.zip');
43 43
 		}
44 44
 	}
45 45
 
46 46
 
47 47
 	public function testGetName()
48 48
 	{
49
-		$this->assertEquals( 'Product import CSV', $this->object->getName() );
49
+		$this->assertEquals('Product import CSV', $this->object->getName());
50 50
 	}
51 51
 
52 52
 
53 53
 	public function testGetDescription()
54 54
 	{
55 55
 		$text = 'Imports new and updates existing products from CSV files';
56
-		$this->assertEquals( $text, $this->object->getDescription() );
56
+		$this->assertEquals($text, $this->object->getDescription());
57 57
 	}
58 58
 
59 59
 
60 60
 	public function testRun()
61 61
 	{
62
-		$prodcodes = array( 'job_csv_test', 'job_csv_test2' );
63
-		$nondelete = array( 'attribute', 'product' );
64
-		$delete = array( 'media', 'price', 'text' );
62
+		$prodcodes = array('job_csv_test', 'job_csv_test2');
63
+		$nondelete = array('attribute', 'product');
64
+		$delete = array('media', 'price', 'text');
65 65
 
66 66
 		$convert = array(
67 67
 			1 => 'Text/LatinUTF8',
68 68
 		);
69 69
 
70
-		$this->context->getConfig()->set( 'controller/jobs/product/import/csv/converter', $convert );
70
+		$this->context->getConfig()->set('controller/jobs/product/import/csv/converter', $convert);
71 71
 
72 72
 		$this->object->run();
73 73
 
74
-		$result = $this->get( $prodcodes, array_merge( $delete, $nondelete ) );
75
-		$properties = $this->getProperties( array_keys( $result ) );
76
-		$this->delete( $prodcodes, $delete, $nondelete );
74
+		$result = $this->get($prodcodes, array_merge($delete, $nondelete));
75
+		$properties = $this->getProperties(array_keys($result));
76
+		$this->delete($prodcodes, $delete, $nondelete);
77 77
 
78
-		$this->assertEquals( 2, count( $result ) );
79
-		$this->assertEquals( 2, count( $properties ) );
78
+		$this->assertEquals(2, count($result));
79
+		$this->assertEquals(2, count($properties));
80 80
 
81
-		foreach( $result as $product ) {
82
-			$this->assertEquals( 5, count( $product->getListItems() ) );
81
+		foreach ($result as $product) {
82
+			$this->assertEquals(5, count($product->getListItems()));
83 83
 		}
84 84
 	}
85 85
 
86 86
 
87 87
 	public function testRunUpdate()
88 88
 	{
89
-		$prodcodes = array( 'job_csv_test', 'job_csv_test2' );
90
-		$nondelete = array( 'attribute', 'product' );
91
-		$delete = array( 'media', 'price', 'text' );
89
+		$prodcodes = array('job_csv_test', 'job_csv_test2');
90
+		$nondelete = array('attribute', 'product');
91
+		$delete = array('media', 'price', 'text');
92 92
 
93 93
 		$this->object->run();
94 94
 		$this->object->run();
95 95
 
96
-		$result = $this->get( $prodcodes, array_merge( $delete, $nondelete ) );
97
-		$properties = $this->getProperties( array_keys( $result ) );
98
-		$this->delete( $prodcodes, $delete, $nondelete );
96
+		$result = $this->get($prodcodes, array_merge($delete, $nondelete));
97
+		$properties = $this->getProperties(array_keys($result));
98
+		$this->delete($prodcodes, $delete, $nondelete);
99 99
 
100
-		$this->assertEquals( 2, count( $result ) );
101
-		$this->assertEquals( 2, count( $properties ) );
100
+		$this->assertEquals(2, count($result));
101
+		$this->assertEquals(2, count($properties));
102 102
 
103
-		foreach( $result as $product ) {
104
-			$this->assertEquals( 5, count( $product->getListItems() ) );
103
+		foreach ($result as $product) {
104
+			$this->assertEquals(5, count($product->getListItems()));
105 105
 		}
106 106
 	}
107 107
 
108 108
 
109 109
 	public function testRunPosition()
110 110
 	{
111
-		$prodcodes = array( 'job_csv_test', 'job_csv_test2' );
112
-		$nondelete = array( 'attribute', 'product' );
113
-		$delete = array( 'media', 'price', 'text' );
111
+		$prodcodes = array('job_csv_test', 'job_csv_test2');
112
+		$nondelete = array('attribute', 'product');
113
+		$delete = array('media', 'price', 'text');
114 114
 
115 115
 		$config = $this->context->getConfig();
116
-		$mapping = $config->set( 'controller/jobs/product/import/csv/mapping', [] );
117
-		$mapping['item'] = array( 0 => 'product.label', 1 => 'product.code' );
116
+		$mapping = $config->set('controller/jobs/product/import/csv/mapping', []);
117
+		$mapping['item'] = array(0 => 'product.label', 1 => 'product.code');
118 118
 
119
-		$config->set( 'controller/jobs/product/import/csv/mapping', $mapping );
120
-		$config->set( 'controller/jobs/product/import/csv/location', __DIR__ . '/_testfiles/position' );
119
+		$config->set('controller/jobs/product/import/csv/mapping', $mapping);
120
+		$config->set('controller/jobs/product/import/csv/location', __DIR__ . '/_testfiles/position');
121 121
 
122 122
 		$this->object->run();
123 123
 
124
-		$result = $this->get( $prodcodes, array_merge( $delete, $nondelete ) );
125
-		$this->delete( $prodcodes, $delete, $nondelete );
124
+		$result = $this->get($prodcodes, array_merge($delete, $nondelete));
125
+		$this->delete($prodcodes, $delete, $nondelete);
126 126
 
127
-		$this->assertEquals( 2, count( $result ) );
127
+		$this->assertEquals(2, count($result));
128 128
 	}
129 129
 
130 130
 
131 131
 	public function testRunProcessorInvalidPosition()
132 132
 	{
133
-		$prodcodes = array( 'job_csv_test', 'job_csv_test2' );
133
+		$prodcodes = array('job_csv_test', 'job_csv_test2');
134 134
 
135 135
 		$mapping = array(
136 136
 			'item' => array(
@@ -150,11 +150,11 @@  discard block
 block discarded – undo
150 150
 			),
151 151
 		);
152 152
 
153
-		$this->context->getConfig()->set( 'controller/jobs/product/import/csv/mapping', $mapping );
153
+		$this->context->getConfig()->set('controller/jobs/product/import/csv/mapping', $mapping);
154 154
 
155 155
 		$this->object->run();
156 156
 
157
-		$this->delete( $prodcodes, array( 'text', 'media' ), [] );
157
+		$this->delete($prodcodes, array('text', 'media'), []);
158 158
 	}
159 159
 
160 160
 
@@ -166,9 +166,9 @@  discard block
 block discarded – undo
166 166
 			),
167 167
 		);
168 168
 
169
-		$this->context->getConfig()->set( 'controller/jobs/product/import/csv/mapping', $mapping );
169
+		$this->context->getConfig()->set('controller/jobs/product/import/csv/mapping', $mapping);
170 170
 
171
-		$this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' );
171
+		$this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception');
172 172
 		$this->object->run();
173 173
 	}
174 174
 
@@ -208,15 +208,15 @@  discard block
 block discarded – undo
208 208
 			),
209 209
 		);
210 210
 
211
-		$this->context->getConfig()->set( 'controller/jobs/product/import/csv/mapping', $mapping );
211
+		$this->context->getConfig()->set('controller/jobs/product/import/csv/mapping', $mapping);
212 212
 
213 213
 		$config = $this->context->getConfig();
214
-		$config->set( 'controller/jobs/product/import/csv/skip-lines', 0 );
215
-		$config->set( 'controller/jobs/product/import/csv/location', __DIR__ . '/_testfiles/invalid' );
214
+		$config->set('controller/jobs/product/import/csv/skip-lines', 0);
215
+		$config->set('controller/jobs/product/import/csv/location', __DIR__ . '/_testfiles/invalid');
216 216
 
217
-		$this->object = new \Aimeos\Controller\Jobs\Product\Import\Csv\Standard( $this->context, $this->aimeos );
217
+		$this->object = new \Aimeos\Controller\Jobs\Product\Import\Csv\Standard($this->context, $this->aimeos);
218 218
 
219
-		$this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' );
219
+		$this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception');
220 220
 		$this->object->run();
221 221
 	}
222 222
 
@@ -224,104 +224,104 @@  discard block
 block discarded – undo
224 224
 	public function testRunBackup()
225 225
 	{
226 226
 		$config = $this->context->getConfig();
227
-		$config->set( 'controller/jobs/product/import/csv/container/type', 'Zip' );
228
-		$config->set( 'controller/jobs/product/import/csv/location', 'tmp/import.zip' );
229
-		$config->set( 'controller/jobs/product/import/csv/backup', 'tmp/test-%Y-%m-%d.zip' );
227
+		$config->set('controller/jobs/product/import/csv/container/type', 'Zip');
228
+		$config->set('controller/jobs/product/import/csv/location', 'tmp/import.zip');
229
+		$config->set('controller/jobs/product/import/csv/backup', 'tmp/test-%Y-%m-%d.zip');
230 230
 
231
-		if( copy( __DIR__ . '/_testfiles/import.zip', 'tmp/import.zip' ) === false ) {
232
-			throw new \RuntimeException( 'Unable to copy test file' );
231
+		if (copy(__DIR__ . '/_testfiles/import.zip', 'tmp/import.zip') === false) {
232
+			throw new \RuntimeException('Unable to copy test file');
233 233
 		}
234 234
 
235 235
 		$this->object->run();
236 236
 
237
-		$filename = strftime( 'tmp/test-%Y-%m-%d.zip' );
238
-		$this->assertTrue( file_exists( $filename ) );
237
+		$filename = strftime('tmp/test-%Y-%m-%d.zip');
238
+		$this->assertTrue(file_exists($filename));
239 239
 
240
-		unlink( $filename );
240
+		unlink($filename);
241 241
 	}
242 242
 
243 243
 
244 244
 	public function testRunBackupInvalid()
245 245
 	{
246 246
 		$config = $this->context->getConfig();
247
-		$config->set( 'controller/jobs/product/import/csv/container/type', 'Zip' );
248
-		$config->set( 'controller/jobs/product/import/csv/location', 'tmp/import.zip' );
249
-		$config->set( 'controller/jobs/product/import/csv/backup', 'tmp/notexist/import.zip' );
247
+		$config->set('controller/jobs/product/import/csv/container/type', 'Zip');
248
+		$config->set('controller/jobs/product/import/csv/location', 'tmp/import.zip');
249
+		$config->set('controller/jobs/product/import/csv/backup', 'tmp/notexist/import.zip');
250 250
 
251
-		if( copy( __DIR__ . '/_testfiles/import.zip', 'tmp/import.zip' ) === false ) {
252
-			throw new \RuntimeException( 'Unable to copy test file' );
251
+		if (copy(__DIR__ . '/_testfiles/import.zip', 'tmp/import.zip') === false) {
252
+			throw new \RuntimeException('Unable to copy test file');
253 253
 		}
254 254
 
255
-		$this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' );
255
+		$this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception');
256 256
 		$this->object->run();
257 257
 	}
258 258
 
259 259
 
260
-	protected function delete( array $prodcodes, array $delete, array $nondelete )
260
+	protected function delete(array $prodcodes, array $delete, array $nondelete)
261 261
 	{
262
-		$catListManager = \Aimeos\MShop\Catalog\Manager\Factory::createManager( $this->context )->getSubmanager( 'lists' );
263
-		$productManager = \Aimeos\MShop\Product\Manager\Factory::createManager( $this->context );
264
-		$listManager = $productManager->getSubManager( 'lists' );
262
+		$catListManager = \Aimeos\MShop\Catalog\Manager\Factory::createManager($this->context)->getSubmanager('lists');
263
+		$productManager = \Aimeos\MShop\Product\Manager\Factory::createManager($this->context);
264
+		$listManager = $productManager->getSubManager('lists');
265 265
 
266
-		foreach( $this->get( $prodcodes, $delete + $nondelete ) as $id => $product )
266
+		foreach ($this->get($prodcodes, $delete + $nondelete) as $id => $product)
267 267
 		{
268
-			foreach( $delete as $domain )
268
+			foreach ($delete as $domain)
269 269
 			{
270
-				$manager = \Aimeos\MShop\Factory::createManager( $this->context, $domain );
270
+				$manager = \Aimeos\MShop\Factory::createManager($this->context, $domain);
271 271
 
272
-				foreach( $product->getListItems( $domain ) as $listItem )
272
+				foreach ($product->getListItems($domain) as $listItem)
273 273
 				{
274
-					$manager->deleteItem( $listItem->getRefItem()->getId() );
275
-					$listManager->deleteItem( $listItem->getId() );
274
+					$manager->deleteItem($listItem->getRefItem()->getId());
275
+					$listManager->deleteItem($listItem->getId());
276 276
 				}
277 277
 			}
278 278
 
279
-			foreach( $nondelete as $domain )
279
+			foreach ($nondelete as $domain)
280 280
 			{
281
-				$ids = array_keys( $product->getListItems( $domain ) );
282
-				$listManager->deleteItems( $ids );
281
+				$ids = array_keys($product->getListItems($domain));
282
+				$listManager->deleteItems($ids);
283 283
 			}
284 284
 
285
-			$productManager->deleteItem( $product->getId() );
285
+			$productManager->deleteItem($product->getId());
286 286
 
287 287
 			$search = $catListManager->createSearch();
288
-			$search->setConditions( $search->compare( '==', 'catalog.lists.refid', $id ) );
289
-			$result = $catListManager->searchItems( $search );
288
+			$search->setConditions($search->compare('==', 'catalog.lists.refid', $id));
289
+			$result = $catListManager->searchItems($search);
290 290
 
291
-			$catListManager->deleteItems( array_keys( $result ) );
291
+			$catListManager->deleteItems(array_keys($result));
292 292
 		}
293 293
 
294 294
 
295
-		$attrManager = \Aimeos\MShop\Attribute\Manager\Factory::createManager( $this->context );
295
+		$attrManager = \Aimeos\MShop\Attribute\Manager\Factory::createManager($this->context);
296 296
 
297 297
 		$search = $attrManager->createSearch();
298
-		$search->setConditions( $search->compare( '==', 'attribute.code', 'import-test' ) );
298
+		$search->setConditions($search->compare('==', 'attribute.code', 'import-test'));
299 299
 
300
-		$result = $attrManager->searchItems( $search );
300
+		$result = $attrManager->searchItems($search);
301 301
 
302
-		$attrManager->deleteItems( array_keys( $result ) );
302
+		$attrManager->deleteItems(array_keys($result));
303 303
 	}
304 304
 
305 305
 
306
-	protected function get( array $prodcodes, array $domains )
306
+	protected function get(array $prodcodes, array $domains)
307 307
 	{
308
-		$productManager = \Aimeos\MShop\Product\Manager\Factory::createManager( $this->context );
308
+		$productManager = \Aimeos\MShop\Product\Manager\Factory::createManager($this->context);
309 309
 
310 310
 		$search = $productManager->createSearch();
311
-		$search->setConditions( $search->compare( '==', 'product.code', $prodcodes ) );
311
+		$search->setConditions($search->compare('==', 'product.code', $prodcodes));
312 312
 
313
-		return $productManager->searchItems( $search, $domains );
313
+		return $productManager->searchItems($search, $domains);
314 314
 	}
315 315
 
316 316
 
317
-	protected function getProperties( array $prodids )
317
+	protected function getProperties(array $prodids)
318 318
 	{
319
-		$manager = \Aimeos\MShop\Product\Manager\Factory::createManager( $this->context )->getSubManager( 'property' );
319
+		$manager = \Aimeos\MShop\Product\Manager\Factory::createManager($this->context)->getSubManager('property');
320 320
 
321 321
 		$search = $manager->createSearch();
322
-		$search->setConditions( $search->compare( '==', 'product.property.parentid', $prodids ) );
323
-		$search->setSortations( array( $search->sort( '+', 'product.property.type' ) ) );
322
+		$search->setConditions($search->compare('==', 'product.property.parentid', $prodids));
323
+		$search->setSortations(array($search->sort('+', 'product.property.type')));
324 324
 
325
-		return $manager->searchItems( $search );
325
+		return $manager->searchItems($search);
326 326
 	}
327 327
 }
328 328
\ No newline at end of file
Please login to merge, or discard this patch.
controller/jobs/src/Controller/Jobs/Subscription/Process/Renew/Standard.php 1 patch
Spacing   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 */
29 29
 	public function getName()
30 30
 	{
31
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Subscription process renew' );
31
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Subscription process renew');
32 32
 	}
33 33
 
34 34
 
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 */
40 40
 	public function getDescription()
41 41
 	{
42
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Renews subscriptions at next date' );
42
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Renews subscriptions at next date');
43 43
 	}
44 44
 
45 45
 
@@ -54,73 +54,73 @@  discard block
 block discarded – undo
54 54
 		$config = $context->getConfig();
55 55
 		$logger = $context->getLogger();
56 56
 
57
-		$names = (array) $config->get( 'controller/common/subscription/process/processors', [] );
57
+		$names = (array) $config->get('controller/common/subscription/process/processors', []);
58 58
 
59
-		$date = date( 'Y-m-d' );
60
-		$processors = $this->getProcessors( $names );
61
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'subscription' );
59
+		$date = date('Y-m-d');
60
+		$processors = $this->getProcessors($names);
61
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'subscription');
62 62
 
63
-		$search = $manager->createSearch( true );
63
+		$search = $manager->createSearch(true);
64 64
 		$expr = [
65
-			$search->compare( '<=', 'subscription.datenext', $date ),
66
-			$search->combine( '||', [
67
-				$search->compare( '==', 'subscription.dateend', null ),
68
-				$search->compare( '>', 'subscription.dateend', $date ),
69
-			] ),
65
+			$search->compare('<=', 'subscription.datenext', $date),
66
+			$search->combine('||', [
67
+				$search->compare('==', 'subscription.dateend', null),
68
+				$search->compare('>', 'subscription.dateend', $date),
69
+			]),
70 70
 			$search->getConditions(),
71 71
 		];
72
-		$search->setConditions( $search->combine( '&&', $expr ) );
73
-		$search->setSortations( [$search->sort( '+', 'subscription.id' )] );
72
+		$search->setConditions($search->combine('&&', $expr));
73
+		$search->setSortations([$search->sort('+', 'subscription.id')]);
74 74
 
75 75
 		$start = 0;
76 76
 
77 77
 		do
78 78
 		{
79
-			$search->setSlice( $start, 100 );
80
-			$items = $manager->searchItems( $search );
79
+			$search->setSlice($start, 100);
80
+			$items = $manager->searchItems($search);
81 81
 
82
-			foreach( $items as $item )
82
+			foreach ($items as $item)
83 83
 			{
84 84
 				try
85 85
 				{
86
-					$context = $this->createContext( $item->getOrderBaseId() );
87
-					$newOrder = $this->createOrderBase( $context, $item );
88
-					$newInvoice = $this->createOrderInvoice( $context, $newOrder );
86
+					$context = $this->createContext($item->getOrderBaseId());
87
+					$newOrder = $this->createOrderBase($context, $item);
88
+					$newInvoice = $this->createOrderInvoice($context, $newOrder);
89 89
 
90 90
 					try
91 91
 					{
92
-						$this->createPayment( $context, $newOrder, $newInvoice );
92
+						$this->createPayment($context, $newOrder, $newInvoice);
93 93
 
94
-						$interval = new \DateInterval( $item->getInterval() );
95
-						$item->setDateNext( date_create()->add( $interval )->format( 'Y-m-d' ) );
94
+						$interval = new \DateInterval($item->getInterval());
95
+						$item->setDateNext(date_create()->add($interval)->format('Y-m-d'));
96 96
 					}
97
-					catch( \Exception $e )
97
+					catch (\Exception $e)
98 98
 					{
99
-						$item->setReason( \Aimeos\MShop\Subscription\Item\Iface::REASON_PAYMENT );
100
-						$item->setDateEnd( date_create()->format( 'Y-m-d' ) );
101
-						$manager->saveItem( $item );
99
+						$item->setReason(\Aimeos\MShop\Subscription\Item\Iface::REASON_PAYMENT);
100
+						$item->setDateEnd(date_create()->format('Y-m-d'));
101
+						$manager->saveItem($item);
102 102
 
103 103
 						throw $e;
104 104
 					}
105 105
 
106
-					$manager->saveItem( $item );
106
+					$manager->saveItem($item);
107 107
 
108
-					foreach( $processors as $processor ) {
109
-						$processor->renew( $item, $newInvoice );
108
+					foreach ($processors as $processor) {
109
+						$processor->renew($item, $newInvoice);
110 110
 					}
111 111
 				}
112
-				catch( \Exception $e )
112
+				catch (\Exception $e)
113 113
 				{
114 114
 					$msg = 'Unable to process subscription with ID "%1$s": %2$s';
115
-					$logger->log( sprintf( $msg, $item->getId(), $e->getMessage() ) );
116
-					$logger->log( $e->getTraceAsString() );
115
+					$logger->log(sprintf($msg, $item->getId(), $e->getMessage()));
116
+					$logger->log($e->getTraceAsString());
117 117
 				}
118 118
 			}
119 119
 
120
-			$count = count( $items );
120
+			$count = count($items);
121 121
 			$start += $count;
122 122
 		}
123
-		while( $count === $search->getSliceSize() );
123
+		while ($count === $search->getSliceSize());
124 124
 	}
125 125
 
126 126
 
@@ -132,11 +132,11 @@  discard block
 block discarded – undo
132 132
 	 * @param array $addresses Associative list of type as key and address object implementing \Aimeos\MShop\Order\Item\Base\Address\Iface as value
133 133
 	 * @return \Aimeos\MShop\Order\Item\Base\Iface Order with addresses added
134 134
 	 */
135
-	protected function addBasketAddresses( \Aimeos\MShop\Context\Item\Iface $context,
136
-		\Aimeos\MShop\Order\Item\Base\Iface $newBasket, array $addresses )
135
+	protected function addBasketAddresses(\Aimeos\MShop\Context\Item\Iface $context,
136
+		\Aimeos\MShop\Order\Item\Base\Iface $newBasket, array $addresses)
137 137
 	{
138
-		foreach( $addresses as $type => $orderAddress ) {
139
-			$newBasket->setAddress( $orderAddress, $type );
138
+		foreach ($addresses as $type => $orderAddress) {
139
+			$newBasket->setAddress($orderAddress, $type);
140 140
 		}
141 141
 
142 142
 		return $newBasket;
@@ -151,8 +151,8 @@  discard block
 block discarded – undo
151 151
 	 * @param array $codes List of coupon codes that should be added to the given basket
152 152
 	 * @return \Aimeos\MShop\Order\Item\Base\Iface Basket, maybe with coupons added
153 153
 	 */
154
-	protected function addBasketCoupons( \Aimeos\MShop\Context\Item\Iface $context,
155
-		\Aimeos\MShop\Order\Item\Base\Iface $basket, array $codes )
154
+	protected function addBasketCoupons(\Aimeos\MShop\Context\Item\Iface $context,
155
+		\Aimeos\MShop\Order\Item\Base\Iface $basket, array $codes)
156 156
 	{
157 157
 		/** controller/jobs/subcription/process/renew/standard/use-coupons
158 158
 		 *
@@ -166,34 +166,34 @@  discard block
 block discarded – undo
166 166
 		 * @category User
167 167
 		 * @since 2018.10
168 168
 		 */
169
-		if( $context->getConfig()->get( 'controller/jobs/subcription/process/renew/standard/use-coupons', false ) )
169
+		if ($context->getConfig()->get('controller/jobs/subcription/process/renew/standard/use-coupons', false))
170 170
 		{
171
-			$manager = \Aimeos\MShop\Factory::createManager( $context, 'coupon' );
172
-			$codeManager = \Aimeos\MShop\Factory::createManager( $context, 'coupon/code' );
171
+			$manager = \Aimeos\MShop\Factory::createManager($context, 'coupon');
172
+			$codeManager = \Aimeos\MShop\Factory::createManager($context, 'coupon/code');
173 173
 
174
-			foreach( $codes as $code )
174
+			foreach ($codes as $code)
175 175
 			{
176
-				$search = $manager->createSearch( true )->setSlice( 0, 1 );
176
+				$search = $manager->createSearch(true)->setSlice(0, 1);
177 177
 				$expr = [
178
-					$search->compare( '==', 'coupon.code.code', $code ),
179
-					$codeManager->createSearch( true )->getConditions(),
178
+					$search->compare('==', 'coupon.code.code', $code),
179
+					$codeManager->createSearch(true)->getConditions(),
180 180
 					$search->getConditions(),
181 181
 				];
182
-				$search->setConditions( $search->combine( '&&', $expr ) );
182
+				$search->setConditions($search->combine('&&', $expr));
183 183
 
184
-				$result = $manager->searchItems( $search );
184
+				$result = $manager->searchItems($search);
185 185
 
186
-				if( ( $item = reset( $result ) ) === false ) {
186
+				if (($item = reset($result)) === false) {
187 187
 					continue;
188 188
 				}
189 189
 
190
-				$provider = $manager->getProvider( $item, strtolower( $code ) );
190
+				$provider = $manager->getProvider($item, strtolower($code));
191 191
 
192
-				if( $provider->isAvailable( $basket ) !== true ) {
192
+				if ($provider->isAvailable($basket) !== true) {
193 193
 					continue;
194 194
 				}
195 195
 
196
-				$provider->addCoupon( $basket );
196
+				$provider->addCoupon($basket);
197 197
 			}
198 198
 		}
199 199
 
@@ -210,17 +210,17 @@  discard block
 block discarded – undo
210 210
 	 * @param string $orderProductId Unique ID of the ordered subscription product
211 211
 	 * @return \Aimeos\MShop\Order\Item\Base\Iface Order with products added
212 212
 	 */
213
-	protected function addBasketProducts( \Aimeos\MShop\Context\Item\Iface $context,
214
-		\Aimeos\MShop\Order\Item\Base\Iface $newBasket, array $orderProducts, $orderProductId )
213
+	protected function addBasketProducts(\Aimeos\MShop\Context\Item\Iface $context,
214
+		\Aimeos\MShop\Order\Item\Base\Iface $newBasket, array $orderProducts, $orderProductId)
215 215
 	{
216
-		foreach( $orderProducts as $orderProduct )
216
+		foreach ($orderProducts as $orderProduct)
217 217
 		{
218
-			if( $orderProduct->getId() == $orderProductId )
218
+			if ($orderProduct->getId() == $orderProductId)
219 219
 			{
220
-				foreach( $orderProduct->getAttributeItems() as $attrItem ) {
221
-					$attrItem->setId( null );
220
+				foreach ($orderProduct->getAttributeItems() as $attrItem) {
221
+					$attrItem->setId(null);
222 222
 				}
223
-				$newBasket->addProduct( $orderProduct->setId( null ) );
223
+				$newBasket->addProduct($orderProduct->setId(null));
224 224
 			}
225 225
 		}
226 226
 
@@ -236,35 +236,35 @@  discard block
 block discarded – undo
236 236
 	 * @param array $services Associative list of type as key and list of service objects implementing \Aimeos\MShop\Order\Item\Base\Service\Iface as values
237 237
 	 * @return \Aimeos\MShop\Order\Item\Base\Iface Order with delivery and payment service added
238 238
 	 */
239
-	protected function addBasketServices( \Aimeos\MShop\Context\Item\Iface $context,
240
-		\Aimeos\MShop\Order\Item\Base\Iface $newBasket, array $services )
239
+	protected function addBasketServices(\Aimeos\MShop\Context\Item\Iface $context,
240
+		\Aimeos\MShop\Order\Item\Base\Iface $newBasket, array $services)
241 241
 	{
242 242
 		$type = \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_PAYMENT;
243 243
 
244
-		if( isset( $services[$type] ) )
244
+		if (isset($services[$type]))
245 245
 		{
246
-			foreach( $services[$type] as $orderService ) {
247
-				$newBasket->addService( $orderService, $type );
246
+			foreach ($services[$type] as $orderService) {
247
+				$newBasket->addService($orderService, $type);
248 248
 			}
249 249
 		}
250 250
 
251 251
 		$type = \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_DELIVERY;
252 252
 
253
-		$serviceManager = \Aimeos\MShop\Factory::createManager( $context, 'service' );
254
-		$orderServiceManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base/service' );
253
+		$serviceManager = \Aimeos\MShop\Factory::createManager($context, 'service');
254
+		$orderServiceManager = \Aimeos\MShop\Factory::createManager($context, 'order/base/service');
255 255
 
256
-		$search = $serviceManager->createSearch( true );
257
-		$search->setSortations( [$search->sort( '+', 'service.position' )] );
258
-		$search->setConditions( $search->compare( '==', 'service.type', $type ) );
256
+		$search = $serviceManager->createSearch(true);
257
+		$search->setSortations([$search->sort('+', 'service.position')]);
258
+		$search->setConditions($search->compare('==', 'service.type', $type));
259 259
 
260
-		foreach( $serviceManager->searchItems( $search, ['media', 'price', 'text'] ) as $item )
260
+		foreach ($serviceManager->searchItems($search, ['media', 'price', 'text']) as $item)
261 261
 		{
262
-			$provider = $serviceManager->getProvider( $item, $item->getType() );
262
+			$provider = $serviceManager->getProvider($item, $item->getType());
263 263
 
264
-			if( $provider->isAvailable( $newBasket ) === true )
264
+			if ($provider->isAvailable($newBasket) === true)
265 265
 			{
266
-				$orderServiceItem = $orderServiceManager->createItem()->copyFrom( $item );
267
-				return $newBasket->addService( $orderServiceItem, $type );
266
+				$orderServiceItem = $orderServiceManager->createItem()->copyFrom($item);
267
+				return $newBasket->addService($orderServiceItem, $type);
268 268
 			}
269 269
 		}
270 270
 
@@ -278,30 +278,30 @@  discard block
 block discarded – undo
278 278
 	 * @param string $baseId Unique order base ID
279 279
 	 * @return \Aimeos\MShop\Context\Item\Iface New context object
280 280
 	 */
281
-	protected function createContext( $baseId )
281
+	protected function createContext($baseId)
282 282
 	{
283 283
 		$context = clone $this->getContext();
284 284
 
285
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'order/base' );
286
-		$baseItem = $manager->getItem( $baseId );
285
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'order/base');
286
+		$baseItem = $manager->getItem($baseId);
287 287
 
288 288
 		$locale = $baseItem->getLocale();
289 289
 		$level = \Aimeos\MShop\Locale\Manager\Base::SITE_ALL;
290 290
 
291
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'locale' );
292
-		$locale = $manager->bootstrap( $baseItem->getSiteCode(), $locale->getLanguageId(), $locale->getCurrencyId(), false, $level );
291
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'locale');
292
+		$locale = $manager->bootstrap($baseItem->getSiteCode(), $locale->getLanguageId(), $locale->getCurrencyId(), false, $level);
293 293
 
294
-		$context->setLocale( $locale );
294
+		$context->setLocale($locale);
295 295
 
296 296
 		try
297 297
 		{
298
-			$manager = \Aimeos\MShop\Factory::createManager( $context, 'customer' );
299
-			$customerItem = $manager->getItem( $baseItem->getCustomerId(), ['customer/group'] );
298
+			$manager = \Aimeos\MShop\Factory::createManager($context, 'customer');
299
+			$customerItem = $manager->getItem($baseItem->getCustomerId(), ['customer/group']);
300 300
 
301
-			$context->setUserId( $baseItem->getCustomerId() );
302
-			$context->setGroupIds( $customerItem->getGroups() );
301
+			$context->setUserId($baseItem->getCustomerId());
302
+			$context->setGroupIds($customerItem->getGroups());
303 303
 		}
304
-		catch( \Exception $e ) {} // Subscription without account
304
+		catch (\Exception $e) {} // Subscription without account
305 305
 
306 306
 		return $context;
307 307
 	}
@@ -314,19 +314,19 @@  discard block
 block discarded – undo
314 314
 	 * @param \Aimeos\MShop\Subscription\Item\Iface $subscription Subscription item with order base ID and order product ID
315 315
 	 * @return \Aimeos\MShop\Order\Item\Base\Iface Complete order with product, addresses and services saved to the storage
316 316
 	 */
317
-	protected function createOrderBase( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Subscription\Item\Iface $subscription )
317
+	protected function createOrderBase(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Subscription\Item\Iface $subscription)
318 318
 	{
319
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'order/base' );
319
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'order/base');
320 320
 
321
-		$basket = $manager->load( $subscription->getOrderBaseId() );
322
-		$newBasket = $manager->createItem()->setCustomerId( $basket->getCustomerId() );
321
+		$basket = $manager->load($subscription->getOrderBaseId());
322
+		$newBasket = $manager->createItem()->setCustomerId($basket->getCustomerId());
323 323
 
324
-		$newBasket = $this->addBasketProducts( $context, $newBasket, $basket->getProducts(), $subscription->getOrderProductId() );
325
-		$newBasket = $this->addBasketAddresses( $context, $newBasket, $basket->getAddresses() );
326
-		$newBasket = $this->addBasketServices( $context, $newBasket, $basket->getServices() );
327
-		$newBasket = $this->addBasketCoupons( $context, $newBasket, array_keys( $basket->getCoupons() ) );
324
+		$newBasket = $this->addBasketProducts($context, $newBasket, $basket->getProducts(), $subscription->getOrderProductId());
325
+		$newBasket = $this->addBasketAddresses($context, $newBasket, $basket->getAddresses());
326
+		$newBasket = $this->addBasketServices($context, $newBasket, $basket->getServices());
327
+		$newBasket = $this->addBasketCoupons($context, $newBasket, array_keys($basket->getCoupons()));
328 328
 
329
-		return $manager->store( $newBasket );
329
+		return $manager->store($newBasket);
330 330
 	}
331 331
 
332 332
 
@@ -337,15 +337,15 @@  discard block
 block discarded – undo
337 337
 	 * @param \Aimeos\MShop\Order\Item\Base\Iface $basket Complete order with product, addresses and services saved to the storage
338 338
 	 * @return \Aimeos\MShop\Order\Item\Iface New invoice item associated to the order saved to the storage
339 339
 	 */
340
-	protected function createOrderInvoice( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Order\Item\Base\Iface $basket )
340
+	protected function createOrderInvoice(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Order\Item\Base\Iface $basket)
341 341
 	{
342
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'order' );
342
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'order');
343 343
 
344 344
 		$item = $manager->createItem();
345
-		$item->setBaseId( $basket->getId() );
346
-		$item->setType( 'subscription' );
345
+		$item->setBaseId($basket->getId());
346
+		$item->setType('subscription');
347 347
 
348
-		return $manager->saveItem( $item );
348
+		return $manager->saveItem($item);
349 349
 	}
350 350
 
351 351
 
@@ -356,17 +356,17 @@  discard block
 block discarded – undo
356 356
 	 * @param \Aimeos\MShop\Order\Item\Base\Iface $basket Complete order with product, addresses and services
357 357
 	 * @param \Aimeos\MShop\Order\Item\Iface New invoice item associated to the order
358 358
 	 */
359
-	protected function createPayment( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Order\Item\Base\Iface $basket,
360
-		\Aimeos\MShop\Order\Item\Iface $invoice )
359
+	protected function createPayment(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Order\Item\Base\Iface $basket,
360
+		\Aimeos\MShop\Order\Item\Iface $invoice)
361 361
 	{
362
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'service' );
362
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'service');
363 363
 
364
-		foreach( $basket->getService( \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_PAYMENT ) as $service )
364
+		foreach ($basket->getService(\Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_PAYMENT) as $service)
365 365
 		{
366
-			$item = $manager->getItem( $service->getServiceId() );
367
-			$provider = $manager->getProvider( $item, 'payment' );
366
+			$item = $manager->getItem($service->getServiceId());
367
+			$provider = $manager->getProvider($item, 'payment');
368 368
 
369
-			$provider->repay( $invoice );
369
+			$provider->repay($invoice);
370 370
 		}
371 371
 	}
372 372
 }
Please login to merge, or discard this patch.
controller/jobs/src/Controller/Jobs/Order/Service/Payment/Standard.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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', 'payment' ) );
92
+		$serviceSearch->setConditions($serviceSearch->compare('==', 'service.type', '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, $serviceItem->getType() );
108
+					$serviceProvider = $serviceManager->getProvider($serviceItem, $serviceItem->getType());
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
 }
Please login to merge, or discard this patch.
controller/jobs/src/Controller/Jobs/Order/Service/Delivery/Standard.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	 */
30 30
 	public function getName()
31 31
 	{
32
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Process order delivery services' );
32
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Process order delivery services');
33 33
 	}
34 34
 
35 35
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	 */
41 41
 	public function getDescription()
42 42
 	{
43
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Sends paid orders to the ERP system or logistic partner' );
43
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Sends paid orders to the ERP system or logistic partner');
44 44
 	}
45 45
 
46 46
 
@@ -69,8 +69,8 @@  discard block
 block discarded – undo
69 69
 		 * @see controller/jobs/order/email/delivery/standard/limit-days
70 70
 		 * @see controller/jobs/order/service/delivery/batch-max
71 71
 		 */
72
-		$days = $context->getConfig()->get( 'controller/jobs/order/service/delivery/limit-days', 90 );
73
-		$date = date( 'Y-m-d 00:00:00', time() - 86400 * $days );
72
+		$days = $context->getConfig()->get('controller/jobs/order/service/delivery/limit-days', 90);
73
+		$date = date('Y-m-d 00:00:00', time() - 86400 * $days);
74 74
 
75 75
 		/** controller/jobs/order/service/delivery/batch-max
76 76
 		 * Maximum number of orders processed at once by the delivery service provider
@@ -85,71 +85,71 @@  discard block
 block discarded – undo
85 85
 		 * @category Developer
86 86
 		 * @see controller/jobs/order/service/delivery/limit-days
87 87
 		 */
88
-		$maxItems = $context->getConfig()->get( 'controller/jobs/order/service/delivery/batch-max', 100 );
88
+		$maxItems = $context->getConfig()->get('controller/jobs/order/service/delivery/batch-max', 100);
89 89
 
90 90
 
91
-		$serviceManager = \Aimeos\MShop\Service\Manager\Factory::createManager( $context );
91
+		$serviceManager = \Aimeos\MShop\Service\Manager\Factory::createManager($context);
92 92
 		$serviceSearch = $serviceManager->createSearch();
93
-		$serviceSearch->setConditions( $serviceSearch->compare( '==', 'service.type', 'delivery' ) );
93
+		$serviceSearch->setConditions($serviceSearch->compare('==', 'service.type', 'delivery'));
94 94
 
95
-		$orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager( $context );
95
+		$orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager($context);
96 96
 		$orderSearch = $orderManager->createSearch();
97 97
 
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, $serviceItem->getType() );
108
+					$serviceProvider = $serviceManager->getProvider($serviceItem, $serviceItem->getType());
109 109
 
110 110
 					$expr = array(
111
-						$orderSearch->compare( '>', 'order.datepayment', $date ),
112
-						$orderSearch->compare( '>', 'order.statuspayment', \Aimeos\MShop\Order\Item\Base::PAY_PENDING ),
113
-						$orderSearch->compare( '==', 'order.statusdelivery', \Aimeos\MShop\Order\Item\Base::STAT_UNFINISHED ),
114
-						$orderSearch->compare( '==', 'order.base.service.code', $serviceItem->getCode() ),
115
-						$orderSearch->compare( '==', 'order.base.service.type', 'delivery' ),
111
+						$orderSearch->compare('>', 'order.datepayment', $date),
112
+						$orderSearch->compare('>', 'order.statuspayment', \Aimeos\MShop\Order\Item\Base::PAY_PENDING),
113
+						$orderSearch->compare('==', 'order.statusdelivery', \Aimeos\MShop\Order\Item\Base::STAT_UNFINISHED),
114
+						$orderSearch->compare('==', 'order.base.service.code', $serviceItem->getCode()),
115
+						$orderSearch->compare('==', 'order.base.service.type', 'delivery'),
116 116
 					);
117
-					$orderSearch->setConditions( $orderSearch->combine( '&&', $expr ) );
117
+					$orderSearch->setConditions($orderSearch->combine('&&', $expr));
118 118
 
119 119
 					$orderStart = 0;
120 120
 
121 121
 					do
122 122
 					{
123
-						$orderSearch->setSlice( $orderStart, $maxItems );
124
-						$orderItems = $orderManager->searchItems( $orderSearch );
123
+						$orderSearch->setSlice($orderStart, $maxItems);
124
+						$orderItems = $orderManager->searchItems($orderSearch);
125 125
 
126 126
 						try
127 127
 						{
128
-							$serviceProvider->processBatch( $orderItems );
129
-							$orderManager->saveItems( $orderItems );
128
+							$serviceProvider->processBatch($orderItems);
129
+							$orderManager->saveItems($orderItems);
130 130
 						}
131
-						catch( \Exception $e )
131
+						catch (\Exception $e)
132 132
 						{
133 133
 							$str = 'Error while processing orders by delivery service "%1$s": %2$s';
134
-							$context->getLogger()->log( sprintf( $str, $serviceItem->getLabel(), $e->getMessage() ) );
134
+							$context->getLogger()->log(sprintf($str, $serviceItem->getLabel(), $e->getMessage()));
135 135
 						}
136 136
 
137
-						$orderCount = count( $orderItems );
137
+						$orderCount = count($orderItems);
138 138
 						$orderStart += $orderCount;
139 139
 					}
140
-					while( $orderCount >= $orderSearch->getSliceSize() );
140
+					while ($orderCount >= $orderSearch->getSliceSize());
141 141
 				}
142
-				catch( \Exception $e )
142
+				catch (\Exception $e)
143 143
 				{
144 144
 					$str = 'Error while processing service with ID "%1$s": %2$s';
145
-					$context->getLogger()->log( sprintf( $str, $serviceItem->getId(), $e->getMessage() ) );
145
+					$context->getLogger()->log(sprintf($str, $serviceItem->getId(), $e->getMessage()));
146 146
 				}
147 147
 			}
148 148
 
149
-			$count = count( $serviceItems );
149
+			$count = count($serviceItems);
150 150
 			$start += $count;
151
-			$serviceSearch->setSlice( $start );
151
+			$serviceSearch->setSlice($start);
152 152
 		}
153
-		while( $count >= $serviceSearch->getSliceSize() );
153
+		while ($count >= $serviceSearch->getSliceSize());
154 154
 	}
155 155
 }
Please login to merge, or discard this patch.
controller/jobs/src/Controller/Jobs/Product/Bought/Standard.php 1 patch
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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,43 +150,43 @@  discard block
 block discarded – undo
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
-		$baseManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base' );
157
+		$baseManager = \Aimeos\MShop\Factory::createManager($context, 'order/base');
158 158
 		$search = $baseManager->createSearch();
159
-		$search->setConditions( $search->compare( '>', 'order.base.ctime', $date ) );
160
-		$search->setSlice( 0, 0 );
159
+		$search->setConditions($search->compare('>', 'order.base.ctime', $date));
160
+		$search->setSlice(0, 0);
161 161
 		$totalOrders = 0;
162
-		$baseManager->searchItems( $search, [], $totalOrders );
162
+		$baseManager->searchItems($search, [], $totalOrders);
163 163
 
164
-		$baseProductManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product' );
164
+		$baseProductManager = \Aimeos\MShop\Factory::createManager($context, 'order/base/product');
165 165
 		$search = $baseProductManager->createSearch();
166
-		$search->setConditions( $search->compare( '>', 'order.base.product.ctime', $date ) );
166
+		$search->setConditions($search->compare('>', 'order.base.product.ctime', $date));
167 167
 		$start = 0;
168 168
 
169 169
 		do
170 170
 		{
171
-			$totalCounts = $baseProductManager->aggregate( $search, 'order.base.product.productid' );
172
-			$prodIds = array_keys( $totalCounts );
171
+			$totalCounts = $baseProductManager->aggregate($search, 'order.base.product.productid');
172
+			$prodIds = array_keys($totalCounts);
173 173
 
174
-			foreach( $totalCounts as $id => $count )
174
+			foreach ($totalCounts as $id => $count)
175 175
 			{
176
-				$this->removeListItems( $id );
176
+				$this->removeListItems($id);
177 177
 
178
-				if( $count / $totalOrders > $minSupport )
178
+				if ($count / $totalOrders > $minSupport)
179 179
 				{
180
-					$productIds = $this->getSuggestions( $id, $prodIds, $count, $totalOrders, $maxItems, $minSupport, $minConfidence, $date );
181
-					$this->addListItems( $id, $productIds );
180
+					$productIds = $this->getSuggestions($id, $prodIds, $count, $totalOrders, $maxItems, $minSupport, $minConfidence, $date);
181
+					$this->addListItems($id, $productIds);
182 182
 				}
183 183
 			}
184 184
 
185
-			$count = count( $totalCounts );
185
+			$count = count($totalCounts);
186 186
 			$start += $count;
187
-			$search->setSlice( $start );
187
+			$search->setSlice($start);
188 188
 		}
189
-		while( $count >= $search->getSliceSize() );
189
+		while ($count >= $search->getSliceSize());
190 190
 	}
191 191
 
192 192
 
@@ -203,59 +203,59 @@  discard block
 block discarded – undo
203 203
 	 * @param string $date Date in YYYY-MM-DD HH:mm:ss format after which orders should be used for calculations
204 204
 	 * @return array List of suggested product IDs as key and their confidence as value
205 205
 	 */
206
-	protected function getSuggestions( $id, $prodIds, $count, $total, $maxItems, $minSupport, $minConfidence, $date )
206
+	protected function getSuggestions($id, $prodIds, $count, $total, $maxItems, $minSupport, $minConfidence, $date)
207 207
 	{
208 208
 		$refIds = [];
209 209
 		$context = $this->getContext();
210 210
 
211
-		$catalogListManager = \Aimeos\MShop\Factory::createManager( $context, 'catalog/lists' );
212
-		$baseProductManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product' );
211
+		$catalogListManager = \Aimeos\MShop\Factory::createManager($context, 'catalog/lists');
212
+		$baseProductManager = \Aimeos\MShop\Factory::createManager($context, 'order/base/product');
213 213
 
214 214
 
215 215
 		$search = $baseProductManager->createSearch();
216
-		$func = $search->createFunction( 'order.base.product.count', array( (string) $id ) );
216
+		$func = $search->createFunction('order.base.product.count', array((string) $id));
217 217
 		$expr = array(
218
-			$search->compare( '==', 'order.base.product.productid', $prodIds ),
219
-			$search->compare( '>', 'order.base.product.ctime', $date ),
220
-			$search->compare( '==', $func, 1 ),
218
+			$search->compare('==', 'order.base.product.productid', $prodIds),
219
+			$search->compare('>', 'order.base.product.ctime', $date),
220
+			$search->compare('==', $func, 1),
221 221
 		);
222
-		$search->setConditions( $search->combine( '&&', $expr ) );
222
+		$search->setConditions($search->combine('&&', $expr));
223 223
 
224
-		$relativeCounts = $baseProductManager->aggregate( $search, 'order.base.product.productid' );
224
+		$relativeCounts = $baseProductManager->aggregate($search, 'order.base.product.productid');
225 225
 
226 226
 
227 227
 		$search = $catalogListManager->createSearch();
228 228
 		$expr = array(
229
-			$search->compare( '==', 'catalog.lists.refid', array_keys( $relativeCounts ) ),
230
-			$search->compare( '==', 'catalog.lists.domain', 'product' ),
229
+			$search->compare('==', 'catalog.lists.refid', array_keys($relativeCounts)),
230
+			$search->compare('==', 'catalog.lists.domain', 'product'),
231 231
 		);
232
-		$search->setConditions( $search->combine( '&&', $expr ) );
232
+		$search->setConditions($search->combine('&&', $expr));
233 233
 
234
-		foreach( $catalogListManager->searchItems( $search ) as $listItem ) {
234
+		foreach ($catalogListManager->searchItems($search) as $listItem) {
235 235
 			$refIds[$listItem->getRefId()] = true;
236 236
 		}
237 237
 
238 238
 
239
-		unset( $relativeCounts[$id] );
239
+		unset($relativeCounts[$id]);
240 240
 		$supportA = $count / $total;
241 241
 		$products = [];
242 242
 
243
-		foreach( $relativeCounts as $prodId => $relCnt )
243
+		foreach ($relativeCounts as $prodId => $relCnt)
244 244
 		{
245
-			if( !isset( $refIds[$prodId] ) ) {
245
+			if (!isset($refIds[$prodId])) {
246 246
 				continue;
247 247
 			}
248 248
 
249 249
 			$supportAB = $relCnt / $total;
250 250
 
251
-			if( $supportAB > $minSupport && ( $conf = ( $supportAB / $supportA ) ) > $minConfidence ) {
251
+			if ($supportAB > $minSupport && ($conf = ($supportAB / $supportA)) > $minConfidence) {
252 252
 				$products[$prodId] = $conf;
253 253
 			}
254 254
 		}
255 255
 
256
-		arsort( $products );
256
+		arsort($products);
257 257
 
258
-		return array_keys( array_slice( $products, 0, $maxItems, true ) );
258
+		return array_keys(array_slice($products, 0, $maxItems, true));
259 259
 	}
260 260
 
261 261
 
@@ -265,26 +265,26 @@  discard block
 block discarded – undo
265 265
 	 * @param string $productId Unique ID of the product the given products should be referenced to
266 266
 	 * @param array $productIds List of position as key and product ID as value
267 267
 	 */
268
-	protected function addListItems( $productId, array $productIds )
268
+	protected function addListItems($productId, array $productIds)
269 269
 	{
270
-		if( empty( $productIds ) ) {
270
+		if (empty($productIds)) {
271 271
 			return;
272 272
 		}
273 273
 
274
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/lists' );
274
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/lists');
275 275
 		$item = $manager->createItem();
276 276
 
277
-		foreach( $productIds as $pos => $refid )
277
+		foreach ($productIds as $pos => $refid)
278 278
 		{
279
-			$item->setId( null );
280
-			$item->setParentId( $productId );
281
-			$item->setDomain( 'product' );
282
-			$item->setType( 'bought-together' );
283
-			$item->setPosition( $pos );
284
-			$item->setRefId( $refid );
285
-			$item->setStatus( 1 );
286
-
287
-			$manager->saveItem( $item, false );
279
+			$item->setId(null);
280
+			$item->setParentId($productId);
281
+			$item->setDomain('product');
282
+			$item->setType('bought-together');
283
+			$item->setPosition($pos);
284
+			$item->setRefId($refid);
285
+			$item->setStatus(1);
286
+
287
+			$manager->saveItem($item, false);
288 288
 		}
289 289
 	}
290 290
 
@@ -294,20 +294,20 @@  discard block
 block discarded – undo
294 294
 	 *
295 295
 	 * @param string $productId Unique ID of the product the references should be removed from
296 296
 	 */
297
-	protected function removeListItems( $productId )
297
+	protected function removeListItems($productId)
298 298
 	{
299
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/lists' );
299
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/lists');
300 300
 
301 301
 		$search = $manager->createSearch();
302 302
 		$expr = array(
303
-			$search->compare( '==', 'product.lists.parentid', $productId ),
304
-			$search->compare( '==', 'product.lists.domain', 'product' ),
305
-			$search->compare( '==', 'product.lists.type', 'bought-together' ),
303
+			$search->compare('==', 'product.lists.parentid', $productId),
304
+			$search->compare('==', 'product.lists.domain', 'product'),
305
+			$search->compare('==', 'product.lists.type', 'bought-together'),
306 306
 		);
307
-		$search->setConditions( $search->combine( '&&', $expr ) );
307
+		$search->setConditions($search->combine('&&', $expr));
308 308
 
309
-		$listItems = $manager->searchItems( $search );
309
+		$listItems = $manager->searchItems($search);
310 310
 
311
-		$manager->deleteItems( array_keys( $listItems ) );
311
+		$manager->deleteItems(array_keys($listItems));
312 312
 	}
313 313
 }
Please login to merge, or discard this patch.
src/Controller/Common/Product/Import/Csv/Processor/Stock/Standard.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -42,15 +42,15 @@  discard block
 block discarded – undo
42 42
 	 * @param array $mapping Associative list of field position in CSV as key and domain item key as value
43 43
 	 * @param \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object Decorated processor
44 44
 	 */
45
-	public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping,
46
-		\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null )
45
+	public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping,
46
+		\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null)
47 47
 	{
48
-		parent::__construct( $context, $mapping, $object );
48
+		parent::__construct($context, $mapping, $object);
49 49
 
50
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'stock/type' );
51
-		$search = $manager->createSearch()->setSlice( 0, 0x7fffffff );
50
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'stock/type');
51
+		$search = $manager->createSearch()->setSlice(0, 0x7fffffff);
52 52
 
53
-		foreach( $manager->searchItems( $search ) as $item ) {
53
+		foreach ($manager->searchItems($search) as $item) {
54 54
 			$this->types[$item->getCode()] = $item->getCode();
55 55
 		}
56 56
 	}
@@ -63,48 +63,48 @@  discard block
 block discarded – undo
63 63
 	 * @param array $data List of CSV fields with position as key and data as value
64 64
 	 * @return array List of data which hasn't been imported
65 65
 	 */
66
-	public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data )
66
+	public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data)
67 67
 	{
68
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'stock' );
68
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'stock');
69 69
 		$manager->begin();
70 70
 
71 71
 		try
72 72
 		{
73
-			$map = $this->getMappedChunk( $data, $this->getMapping() );
74
-			$items = $this->getStockItems( $product->getCode() );
73
+			$map = $this->getMappedChunk($data, $this->getMapping());
74
+			$items = $this->getStockItems($product->getCode());
75 75
 
76
-			foreach( $map as $pos => $list )
76
+			foreach ($map as $pos => $list)
77 77
 			{
78
-				if( !array_key_exists( 'stock.stocklevel', $list ) ) {
78
+				if (!array_key_exists('stock.stocklevel', $list)) {
79 79
 					continue;
80 80
 				}
81 81
 
82 82
 				$list['stock.productcode'] = $product->getCode();
83
-				$list['stock.dateback'] = $this->getValue( $list, 'stock.dateback' );
84
-				$list['stock.stocklevel'] = $this->getValue( $list, 'stock.stocklevel' );
85
-				$list['stock.type'] = $this->getValue( $list, 'stock.type', 'default' );
83
+				$list['stock.dateback'] = $this->getValue($list, 'stock.dateback');
84
+				$list['stock.stocklevel'] = $this->getValue($list, 'stock.stocklevel');
85
+				$list['stock.type'] = $this->getValue($list, 'stock.type', 'default');
86 86
 
87
-				if( !in_array( $list['stock.type'], $this->types ) )
87
+				if (!in_array($list['stock.type'], $this->types))
88 88
 				{
89
-					$msg = sprintf( 'Invalid type "%1$s" (%2$s)', $list['stock.type'], 'stock' );
90
-					throw new \Aimeos\Controller\Common\Exception( $msg );
89
+					$msg = sprintf('Invalid type "%1$s" (%2$s)', $list['stock.type'], 'stock');
90
+					throw new \Aimeos\Controller\Common\Exception($msg);
91 91
 				}
92 92
 
93
-				if( ( $item = array_pop( $items ) ) === null ) {
93
+				if (($item = array_pop($items)) === null) {
94 94
 					$item = $manager->createItem();
95 95
 				}
96 96
 
97
-				$item->fromArray( $list );
98
-				$manager->saveItem( $item, false );
97
+				$item->fromArray($list);
98
+				$manager->saveItem($item, false);
99 99
 			}
100 100
 
101
-			$manager->deleteItems( array_keys( $items ) );
101
+			$manager->deleteItems(array_keys($items));
102 102
 
103
-			$data = $this->getObject()->process( $product, $data );
103
+			$data = $this->getObject()->process($product, $data);
104 104
 
105 105
 			$manager->commit();
106 106
 		}
107
-		catch( \Exception $e )
107
+		catch (\Exception $e)
108 108
 		{
109 109
 			$manager->rollback();
110 110
 			throw $e;
@@ -120,13 +120,13 @@  discard block
 block discarded – undo
120 120
 	 * @param string $code Unique product code
121 121
 	 * @return \Aimeos\MShop\Stock\Item\Iface[] Associative list of stock items
122 122
 	 */
123
-	protected function getStockItems( $code )
123
+	protected function getStockItems($code)
124 124
 	{
125
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'stock' );
125
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'stock');
126 126
 
127 127
 		$search = $manager->createSearch();
128
-		$search->setConditions( $search->compare( '==', 'stock.productcode', $code ) );
128
+		$search->setConditions($search->compare('==', 'stock.productcode', $code));
129 129
 
130
-		return $manager->searchItems( $search );
130
+		return $manager->searchItems($search);
131 131
 	}
132 132
 }
Please login to merge, or discard this patch.
controller/jobs/src/Controller/Jobs/Product/Import/Csv/Standard.php 1 patch
Spacing   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -30,14 +30,14 @@  discard block
 block discarded – undo
30 30
 	 * @param \Aimeos\MShop\Context\Item\Iface $context MShop context object
31 31
 	 * @param \Aimeos\Bootstrap $aimeos \Aimeos\Bootstrap main object
32 32
 	 */
33
-	public function __construct( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\Bootstrap $aimeos )
33
+	public function __construct(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\Bootstrap $aimeos)
34 34
 	{
35
-		parent::__construct( $context, $aimeos );
35
+		parent::__construct($context, $aimeos);
36 36
 
37
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'product/type' );
38
-		$search = $manager->createSearch()->setSlice( 0, 0x7fffffff );
37
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'product/type');
38
+		$search = $manager->createSearch()->setSlice(0, 0x7fffffff);
39 39
 
40
-		foreach( $manager->searchItems( $search ) as $item ) {
40
+		foreach ($manager->searchItems($search) as $item) {
41 41
 			$this->types[$item->getCode()] = $item->getCode();
42 42
 		}
43 43
 	}
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	 */
51 51
 	public function getName()
52 52
 	{
53
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Product import CSV' );
53
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Product import CSV');
54 54
 	}
55 55
 
56 56
 
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 	 */
62 62
 	public function getDescription()
63 63
 	{
64
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Imports new and updates existing products from CSV files' );
64
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Imports new and updates existing products from CSV files');
65 65
 	}
66 66
 
67 67
 
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 		$context = $this->getContext();
77 77
 		$config = $context->getConfig();
78 78
 		$logger = $context->getLogger();
79
-		$domains = array( 'attribute', 'media', 'price', 'product', 'product/property', 'text' );
79
+		$domains = array('attribute', 'media', 'price', 'product', 'product/property', 'text');
80 80
 		$mappings = $this->getDefaultMapping();
81 81
 
82 82
 
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 		 * @see controller/common/product/import/csv/converter
97 97
 		 * @see controller/common/product/import/csv/max-size
98 98
 		 */
99
-		$domains = $config->get( 'controller/common/product/import/csv/domains', $domains );
99
+		$domains = $config->get('controller/common/product/import/csv/domains', $domains);
100 100
 
101 101
 		/** controller/jobs/product/import/csv/domains
102 102
 		 * List of item domain names that should be retrieved along with the product items
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 		 * @see controller/jobs/product/import/csv/backup
117 117
 		 * @see controller/common/product/import/csv/max-size
118 118
 		 */
119
-		$domains = $config->get( 'controller/jobs/product/import/csv/domains', $domains );
119
+		$domains = $config->get('controller/jobs/product/import/csv/domains', $domains);
120 120
 
121 121
 
122 122
 		/** controller/common/product/import/csv/mapping
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 		 * @see controller/common/product/import/csv/converter
142 142
 		 * @see controller/common/product/import/csv/max-size
143 143
 		 */
144
-		$mappings = $config->get( 'controller/common/product/import/csv/mapping', $mappings );
144
+		$mappings = $config->get('controller/common/product/import/csv/mapping', $mappings);
145 145
 
146 146
 		/** controller/jobs/product/import/csv/mapping
147 147
 		 * List of mappings between the position in the CSV file and item keys
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 		 * @see controller/jobs/product/import/csv/backup
162 162
 		 * @see controller/common/product/import/csv/max-size
163 163
 		 */
164
-		$mappings = $config->get( 'controller/jobs/product/import/csv/mapping', $mappings );
164
+		$mappings = $config->get('controller/jobs/product/import/csv/mapping', $mappings);
165 165
 
166 166
 
167 167
 		/** controller/common/product/import/csv/converter
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 		 * @see controller/common/product/import/csv/mapping
204 204
 		 * @see controller/common/product/import/csv/max-size
205 205
 		 */
206
-		$converters = $config->get( 'controller/common/product/import/csv/converter', [] );
206
+		$converters = $config->get('controller/common/product/import/csv/converter', []);
207 207
 
208 208
 		/** controller/jobs/product/import/csv/converter
209 209
 		 * List of converter names for the values at the position in the CSV file
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 		 * @see controller/jobs/product/import/csv/backup
224 224
 		 * @see controller/common/product/import/csv/max-size
225 225
 		 */
226
-		$converters = $config->get( 'controller/jobs/product/import/csv/converter', $converters );
226
+		$converters = $config->get('controller/jobs/product/import/csv/converter', $converters);
227 227
 
228 228
 
229 229
 		/** controller/common/product/import/csv/max-size
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 		 * @see controller/common/product/import/csv/mapping
244 244
 		 * @see controller/common/product/import/csv/converter
245 245
 		 */
246
-		$maxcnt = (int) $config->get( 'controller/common/product/import/csv/max-size', 1000 );
246
+		$maxcnt = (int) $config->get('controller/common/product/import/csv/max-size', 1000);
247 247
 
248 248
 
249 249
 		/** controller/jobs/product/import/csv/skip-lines
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
 		 * @see controller/jobs/product/import/csv/backup
266 266
 		 * @see controller/common/product/import/csv/max-size
267 267
 		 */
268
-		$skiplines = (int) $config->get( 'controller/jobs/product/import/csv/skip-lines', 0 );
268
+		$skiplines = (int) $config->get('controller/jobs/product/import/csv/skip-lines', 0);
269 269
 
270 270
 
271 271
 		/** controller/jobs/product/import/csv/strict
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 		 * @see controller/jobs/product/import/csv/backup
290 290
 		 * @see controller/common/product/import/csv/max-size
291 291
 		 */
292
-		$strict = (bool) $config->get( 'controller/jobs/product/import/csv/strict', true );
292
+		$strict = (bool) $config->get('controller/jobs/product/import/csv/strict', true);
293 293
 
294 294
 
295 295
 		/** controller/jobs/product/import/csv/backup
@@ -322,74 +322,74 @@  discard block
 block discarded – undo
322 322
 		 * @see controller/jobs/product/import/csv/strict
323 323
 		 * @see controller/common/product/import/csv/max-size
324 324
 		 */
325
-		$backup = $config->get( 'controller/jobs/product/import/csv/backup' );
325
+		$backup = $config->get('controller/jobs/product/import/csv/backup');
326 326
 
327 327
 
328
-		if( !isset( $mappings['item'] ) || !is_array( $mappings['item'] ) )
328
+		if (!isset($mappings['item']) || !is_array($mappings['item']))
329 329
 		{
330
-			$msg = sprintf( 'Required mapping key "%1$s" is missing or contains no array', 'item' );
331
-			throw new \Aimeos\Controller\Jobs\Exception( $msg );
330
+			$msg = sprintf('Required mapping key "%1$s" is missing or contains no array', 'item');
331
+			throw new \Aimeos\Controller\Jobs\Exception($msg);
332 332
 		}
333 333
 
334 334
 		try
335 335
 		{
336 336
 			$procMappings = $mappings;
337
-			unset( $procMappings['item'] );
337
+			unset($procMappings['item']);
338 338
 
339
-			$codePos = $this->getCodePosition( $mappings['item'] );
340
-			$convlist = $this->getConverterList( $converters );
341
-			$processor = $this->getProcessors( $procMappings );
339
+			$codePos = $this->getCodePosition($mappings['item']);
340
+			$convlist = $this->getConverterList($converters);
341
+			$processor = $this->getProcessors($procMappings);
342 342
 			$container = $this->getContainer();
343 343
 			$path = $container->getName();
344 344
 
345
-			$msg = sprintf( 'Started product import from "%1$s" (%2$s)', $path, __CLASS__ );
346
-			$logger->log( $msg, \Aimeos\MW\Logger\Base::NOTICE );
345
+			$msg = sprintf('Started product import from "%1$s" (%2$s)', $path, __CLASS__);
346
+			$logger->log($msg, \Aimeos\MW\Logger\Base::NOTICE);
347 347
 
348
-			foreach( $container as $content )
348
+			foreach ($container as $content)
349 349
 			{
350 350
 				$name = $content->getName();
351 351
 
352
-				for( $i = 0; $i < $skiplines; $i++ ) {
352
+				for ($i = 0; $i < $skiplines; $i++) {
353 353
 					$content->next();
354 354
 				}
355 355
 
356
-				while( ( $data = $this->getData( $content, $maxcnt, $codePos ) ) !== [] )
356
+				while (($data = $this->getData($content, $maxcnt, $codePos)) !== [])
357 357
 				{
358
-					$data = $this->convertData( $convlist, $data );
359
-					$products = $this->getProducts( array_keys( $data ), $domains );
360
-					$errcnt = $this->import( $products, $data, $mappings['item'], $processor, $strict );
361
-					$chunkcnt = count( $data );
358
+					$data = $this->convertData($convlist, $data);
359
+					$products = $this->getProducts(array_keys($data), $domains);
360
+					$errcnt = $this->import($products, $data, $mappings['item'], $processor, $strict);
361
+					$chunkcnt = count($data);
362 362
 
363 363
 					$msg = 'Imported product lines from "%1$s": %2$d/%3$d (%4$s)';
364
-					$logger->log( sprintf( $msg, $name, $chunkcnt - $errcnt, $chunkcnt, __CLASS__ ), \Aimeos\MW\Logger\Base::NOTICE );
364
+					$logger->log(sprintf($msg, $name, $chunkcnt - $errcnt, $chunkcnt, __CLASS__), \Aimeos\MW\Logger\Base::NOTICE);
365 365
 
366 366
 					$errors += $errcnt;
367 367
 					$total += $chunkcnt;
368
-					unset( $products, $data );
368
+					unset($products, $data);
369 369
 				}
370 370
 			}
371 371
 
372 372
 			$container->close();
373 373
 		}
374
-		catch( \Exception $e )
374
+		catch (\Exception $e)
375 375
 		{
376
-			$logger->log( 'Product import error: ' . $e->getMessage() );
377
-			$logger->log( $e->getTraceAsString() );
376
+			$logger->log('Product import error: ' . $e->getMessage());
377
+			$logger->log($e->getTraceAsString());
378 378
 
379
-			throw new \Aimeos\Controller\Jobs\Exception( $e->getMessage() );
379
+			throw new \Aimeos\Controller\Jobs\Exception($e->getMessage());
380 380
 		}
381 381
 
382 382
 		$msg = 'Finished product import from "%1$s": %2$d successful, %3$s errors, %4$s total (%5$s)';
383
-		$logger->log( sprintf( $msg, $path, $total - $errors, $errors, $total, __CLASS__ ), \Aimeos\MW\Logger\Base::NOTICE );
383
+		$logger->log(sprintf($msg, $path, $total - $errors, $errors, $total, __CLASS__), \Aimeos\MW\Logger\Base::NOTICE);
384 384
 
385
-		if( $errors > 0 )
385
+		if ($errors > 0)
386 386
 		{
387
-			$msg = sprintf( 'Invalid product lines in "%1$s": %2$d/%3$d', $path, $errors, $total );
388
-			throw new \Aimeos\Controller\Jobs\Exception( $msg );
387
+			$msg = sprintf('Invalid product lines in "%1$s": %2$d/%3$d', $path, $errors, $total);
388
+			throw new \Aimeos\Controller\Jobs\Exception($msg);
389 389
 		}
390 390
 
391
-		if( !empty( $backup ) && @rename( $path, strftime( $backup ) ) === false ) {
392
-			throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Unable to move imported file' ) );
391
+		if (!empty($backup) && @rename($path, strftime($backup)) === false) {
392
+			throw new \Aimeos\Controller\Jobs\Exception(sprintf('Unable to move imported file'));
393 393
 		}
394 394
 	}
395 395
 
@@ -401,16 +401,16 @@  discard block
 block discarded – undo
401 401
 	 * @return integer Position of the "product.code" column
402 402
 	 * @throws \Aimeos\Controller\Jobs\Exception If no mapping for "product.code" is found
403 403
 	 */
404
-	protected function getCodePosition( array $mapping )
404
+	protected function getCodePosition(array $mapping)
405 405
 	{
406
-		foreach( $mapping as $pos => $key )
406
+		foreach ($mapping as $pos => $key)
407 407
 		{
408
-			if( $key === 'product.code' ) {
408
+			if ($key === 'product.code') {
409 409
 				return $pos;
410 410
 			}
411 411
 		}
412 412
 
413
-		throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'No "product.code" column in CSV mapping found' ) );
413
+		throw new \Aimeos\Controller\Jobs\Exception(sprintf('No "product.code" column in CSV mapping found'));
414 414
 	}
415 415
 
416 416
 
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
 		 * @see controller/jobs/product/import/csv/container/content
446 446
 		 * @see controller/jobs/product/import/csv/container/options
447 447
 		 */
448
-		$location = $config->get( 'controller/jobs/product/import/csv/location' );
448
+		$location = $config->get('controller/jobs/product/import/csv/location');
449 449
 
450 450
 		/** controller/jobs/product/import/csv/container/type
451 451
 		 * Nave of the container type to read the data from
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
 		 * @see controller/jobs/product/import/csv/container/content
469 469
 		 * @see controller/jobs/product/import/csv/container/options
470 470
 		 */
471
-		$container = $config->get( 'controller/jobs/product/import/csv/container/type', 'Directory' );
471
+		$container = $config->get('controller/jobs/product/import/csv/container/type', 'Directory');
472 472
 
473 473
 		/** controller/jobs/product/import/csv/container/content
474 474
 		 * Name of the content type inside the container to read the data from
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
 		 * @see controller/jobs/product/import/csv/container/type
490 490
 		 * @see controller/jobs/product/import/csv/container/options
491 491
 		 */
492
-		$content = $config->get( 'controller/jobs/product/import/csv/container/content', 'CSV' );
492
+		$content = $config->get('controller/jobs/product/import/csv/container/content', 'CSV');
493 493
 
494 494
 		/** controller/jobs/product/import/csv/container/options
495 495
 		 * List of file container options for the product import files
@@ -507,15 +507,15 @@  discard block
 block discarded – undo
507 507
 		 * @see controller/jobs/product/import/csv/container/content
508 508
 		 * @see controller/jobs/product/import/csv/container/type
509 509
 		 */
510
-		$options = $config->get( 'controller/jobs/product/import/csv/container/options', [] );
510
+		$options = $config->get('controller/jobs/product/import/csv/container/options', []);
511 511
 
512
-		if( $location === null )
512
+		if ($location === null)
513 513
 		{
514
-			$msg = sprintf( 'Required configuration for "%1$s" is missing', 'controller/jobs/product/import/csv/location' );
515
-			throw new \Aimeos\Controller\Jobs\Exception( $msg );
514
+			$msg = sprintf('Required configuration for "%1$s" is missing', 'controller/jobs/product/import/csv/location');
515
+			throw new \Aimeos\Controller\Jobs\Exception($msg);
516 516
 		}
517 517
 
518
-		return \Aimeos\MW\Container\Factory::getContainer( $location, $container, $content, $options );
518
+		return \Aimeos\MW\Container\Factory::getContainer($location, $container, $content, $options);
519 519
 	}
520 520
 
521 521
 
@@ -530,69 +530,69 @@  discard block
 block discarded – undo
530 530
 	 * @return integer Number of products that couldn't be imported
531 531
 	 * @throws \Aimeos\Controller\Jobs\Exception
532 532
 	 */
533
-	protected function import( array $products, array $data, array $mapping,
534
-		\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $processor, $strict )
533
+	protected function import(array $products, array $data, array $mapping,
534
+		\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $processor, $strict)
535 535
 	{
536 536
 		$items = [];
537 537
 		$errors = 0;
538 538
 		$context = $this->getContext();
539
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'product' );
540
-		$indexManager = \Aimeos\MShop\Factory::createManager( $context, 'index' );
539
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'product');
540
+		$indexManager = \Aimeos\MShop\Factory::createManager($context, 'index');
541 541
 
542
-		foreach( $data as $code => $list )
542
+		foreach ($data as $code => $list)
543 543
 		{
544 544
 			$manager->begin();
545 545
 
546 546
 			try
547 547
 			{
548
-				$code = trim( $code );
548
+				$code = trim($code);
549 549
 
550
-				if( isset( $products[$code] ) ) {
550
+				if (isset($products[$code])) {
551 551
 					$product = $products[$code];
552 552
 				} else {
553 553
 					$product = $manager->createItem();
554 554
 				}
555 555
 
556
-				$map = $this->getMappedChunk( $list, $mapping );
556
+				$map = $this->getMappedChunk($list, $mapping);
557 557
 
558
-				if( isset( $map[0] ) )
558
+				if (isset($map[0]))
559 559
 				{
560 560
 					$map = $map[0]; // there can only be one chunk for the base product data
561
-					$map['product.type'] = $this->getValue( $map, 'product.type', 'default' );
561
+					$map['product.type'] = $this->getValue($map, 'product.type', 'default');
562 562
 
563
-					if( !in_array( $map['product.type'], $this->types ) )
563
+					if (!in_array($map['product.type'], $this->types))
564 564
 					{
565
-						$msg = sprintf( 'Invalid product type "%1$s"', $map['product.type'] );
566
-						throw new \Aimeos\Controller\Jobs\Exception( $msg );
565
+						$msg = sprintf('Invalid product type "%1$s"', $map['product.type']);
566
+						throw new \Aimeos\Controller\Jobs\Exception($msg);
567 567
 					}
568 568
 
569
-					$product->fromArray( $this->addItemDefaults( $map ) );
570
-					$product = $manager->saveItem( $product );
569
+					$product->fromArray($this->addItemDefaults($map));
570
+					$product = $manager->saveItem($product);
571 571
 
572
-					$list = $processor->process( $product, $list );
572
+					$list = $processor->process($product, $list);
573 573
 
574
-					$product = $manager->saveItem( $product );
574
+					$product = $manager->saveItem($product);
575 575
 					$items[$product->getId()] = $product;
576 576
 				}
577 577
 
578 578
 				$manager->commit();
579 579
 			}
580
-			catch( \Exception $e )
580
+			catch (\Exception $e)
581 581
 			{
582 582
 				$manager->rollback();
583 583
 
584
-				$msg = sprintf( 'Unable to import product with code "%1$s": %2$s', $code, $e->getMessage() );
585
-				$context->getLogger()->log( $msg );
584
+				$msg = sprintf('Unable to import product with code "%1$s": %2$s', $code, $e->getMessage());
585
+				$context->getLogger()->log($msg);
586 586
 
587 587
 				$errors++;
588 588
 			}
589 589
 
590
-			if( $strict && !empty( $list ) ) {
591
-				$context->getLogger()->log( 'Not imported: ' . print_r( $list, true ) );
590
+			if ($strict && !empty($list)) {
591
+				$context->getLogger()->log('Not imported: ' . print_r($list, true));
592 592
 			}
593 593
 		}
594 594
 
595
-		$indexManager->rebuildIndex( $items );
595
+		$indexManager->rebuildIndex($items);
596 596
 
597 597
 		return $errors;
598 598
 	}
@@ -604,9 +604,9 @@  discard block
 block discarded – undo
604 604
 	 * @param array $list Associative list of domain item keys and their values, e.g. "product.status" => 1
605 605
 	 * @return array Given associative list enriched by default values if they were not already set
606 606
 	 */
607
-	protected function addItemDefaults( array $list )
607
+	protected function addItemDefaults(array $list)
608 608
 	{
609
-		if( !isset( $list['product.status'] ) ) {
609
+		if (!isset($list['product.status'])) {
610 610
 			$list['product.status'] = 1;
611 611
 		}
612 612
 
Please login to merge, or discard this patch.
src/Controller/Common/Product/Import/Csv/Processor/Product/Standard.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -43,10 +43,10 @@  discard block
 block discarded – undo
43 43
 	 * @param array $mapping Associative list of field position in CSV as key and domain item key as value
44 44
 	 * @param \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object Decorated processor
45 45
 	 */
46
-	public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping,
47
-		\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null )
46
+	public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping,
47
+		\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null)
48 48
 	{
49
-		parent::__construct( $context, $mapping, $object );
49
+		parent::__construct($context, $mapping, $object);
50 50
 
51 51
 		/** controller/common/product/import/csv/processor/product/listtypes
52 52
 		 * Names of the product list types that are updated or removed
@@ -74,26 +74,26 @@  discard block
 block discarded – undo
74 74
 		 * @see controller/common/product/import/csv/processor/text/listtypes
75 75
 		 */
76 76
 		$key = 'controller/common/product/import/csv/processor/product/listtypes';
77
-		$this->listTypes = $context->getConfig()->get( $key, ['default', 'suggestion'] );
77
+		$this->listTypes = $context->getConfig()->get($key, ['default', 'suggestion']);
78 78
 
79
-		if( $this->listTypes === null )
79
+		if ($this->listTypes === null)
80 80
 		{
81 81
 			$this->listTypes = [];
82
-			$manager = \Aimeos\MShop\Factory::createManager( $context, 'product/lists/type' );
82
+			$manager = \Aimeos\MShop\Factory::createManager($context, 'product/lists/type');
83 83
 
84
-			$search = $manager->createSearch()->setSlice( 0, 0x7fffffff );
85
-			$search->setConditions( $search->compare( '==', 'product.lists.type.domain', 'product' ) );
84
+			$search = $manager->createSearch()->setSlice(0, 0x7fffffff);
85
+			$search->setConditions($search->compare('==', 'product.lists.type.domain', 'product'));
86 86
 
87
-			foreach( $manager->searchItems( $search ) as $item ) {
87
+			foreach ($manager->searchItems($search) as $item) {
88 88
 				$this->listTypes[$item->getCode()] = $item->getCode();
89 89
 			}
90 90
 		}
91 91
 		else
92 92
 		{
93
-			$this->listTypes = array_flip( $this->listTypes );
93
+			$this->listTypes = array_flip($this->listTypes);
94 94
 		}
95 95
 
96
-		$this->cache = $this->getCache( 'product' );
96
+		$this->cache = $this->getCache('product');
97 97
 	}
98 98
 
99 99
 
@@ -104,49 +104,49 @@  discard block
 block discarded – undo
104 104
 	 * @param array $data List of CSV fields with position as key and data as value
105 105
 	 * @return array List of data which has not been imported
106 106
 	 */
107
-	public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data )
107
+	public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data)
108 108
 	{
109 109
 		$context = $this->getContext();
110
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'product/lists' );
111
-		$separator = $context->getConfig()->get( 'controller/common/product/import/csv/separator', "\n" );
110
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'product/lists');
111
+		$separator = $context->getConfig()->get('controller/common/product/import/csv/separator', "\n");
112 112
 
113
-		$listItems = $product->getListItems( 'product', null, null, false );
114
-		$this->cache->set( $product );
113
+		$listItems = $product->getListItems('product', null, null, false);
114
+		$this->cache->set($product);
115 115
 
116
-		foreach( $this->getMappedChunk( $data, $this->getMapping() ) as $list )
116
+		foreach ($this->getMappedChunk($data, $this->getMapping()) as $list)
117 117
 		{
118
-			if( $this->checkEntry( $list ) === false ) {
118
+			if ($this->checkEntry($list) === false) {
119 119
 				continue;
120 120
 			}
121 121
 
122
-			$listtype = $this->getValue( $list, 'product.lists.type', 'default' );
122
+			$listtype = $this->getValue($list, 'product.lists.type', 'default');
123 123
 
124
-			foreach( explode( $separator, $this->getValue( $list, 'product.code', '' ) ) as $code )
124
+			foreach (explode($separator, $this->getValue($list, 'product.code', '')) as $code)
125 125
 			{
126
-				$code = trim( $code );
126
+				$code = trim($code);
127 127
 
128
-				if( ( $prodid = $this->cache->get( $code ) ) === null )
128
+				if (($prodid = $this->cache->get($code)) === null)
129 129
 				{
130 130
 					$msg = 'No product for code "%1$s" available when importing product with code "%2$s"';
131
-					throw new \Aimeos\Controller\Jobs\Exception( sprintf( $msg, $code, $product->getCode() ) );
131
+					throw new \Aimeos\Controller\Jobs\Exception(sprintf($msg, $code, $product->getCode()));
132 132
 				}
133 133
 
134
-				if( ( $listItem = $product->getListItem( 'product', $listtype, $prodid ) ) === null ) {
135
-					$listItem = $manager->createItem()->setType( $listtype );
134
+				if (($listItem = $product->getListItem('product', $listtype, $prodid)) === null) {
135
+					$listItem = $manager->createItem()->setType($listtype);
136 136
 				} else {
137
-					unset( $listItems[$listItem->getId()] );
137
+					unset($listItems[$listItem->getId()]);
138 138
 				}
139 139
 
140
-				$listItem->fromArray( $list );
141
-				$listItem->setRefId( $prodid );
140
+				$listItem->fromArray($list);
141
+				$listItem->setRefId($prodid);
142 142
 
143
-				$product->addListItem( 'product', $listItem );
143
+				$product->addListItem('product', $listItem);
144 144
 			}
145 145
 		}
146 146
 
147
-		$product->deleteListItems( $listItems );
147
+		$product->deleteListItems($listItems);
148 148
 
149
-		return $this->getObject()->process( $product, $data );
149
+		return $this->getObject()->process($product, $data);
150 150
 	}
151 151
 
152 152
 
@@ -156,16 +156,16 @@  discard block
 block discarded – undo
156 156
 	 * @param array $list Associative list of key/value pairs from the mapping
157 157
 	 * @return boolean True if valid, false if not
158 158
 	 */
159
-	protected function checkEntry( array $list )
159
+	protected function checkEntry(array $list)
160 160
 	{
161
-		if( $this->getValue( $list, 'product.code' ) === null ) {
161
+		if ($this->getValue($list, 'product.code') === null) {
162 162
 			return false;
163 163
 		}
164 164
 
165
-		if( ( $type = $this->getValue( $list, 'product.lists.type' ) ) && !isset( $this->listTypes[$type] ) )
165
+		if (($type = $this->getValue($list, 'product.lists.type')) && !isset($this->listTypes[$type]))
166 166
 		{
167
-			$msg = sprintf( 'Invalid type "%1$s" (%2$s)', $type, 'product list' );
168
-			throw new \Aimeos\Controller\Common\Exception( $msg );
167
+			$msg = sprintf('Invalid type "%1$s" (%2$s)', $type, 'product list');
168
+			throw new \Aimeos\Controller\Common\Exception($msg);
169 169
 		}
170 170
 
171 171
 		return true;
Please login to merge, or discard this patch.