@@ -42,10 +42,10 @@ discard block |
||
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 | 50 | /** controller/common/product/import/csv/processor/text/listtypes |
51 | 51 | * Names of the product list types for texts that are updated or removed |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * @see controller/common/product/import/csv/processor/price/listtypes |
67 | 67 | * @see controller/common/product/import/csv/processor/product/listtypes |
68 | 68 | */ |
69 | - $this->listTypes = $context->getConfig()->get( 'controller/common/product/import/csv/processor/text/listtypes' ); |
|
69 | + $this->listTypes = $context->getConfig()->get('controller/common/product/import/csv/processor/text/listtypes'); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | |
@@ -77,53 +77,53 @@ discard block |
||
77 | 77 | * @param array $data List of CSV fields with position as key and data as value |
78 | 78 | * @return array List of data which hasn't been imported |
79 | 79 | */ |
80 | - public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data ) |
|
80 | + public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data) |
|
81 | 81 | { |
82 | - $listManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/lists' ); |
|
83 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'text' ); |
|
82 | + $listManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/lists'); |
|
83 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'text'); |
|
84 | 84 | |
85 | 85 | $listMap = []; |
86 | - $map = $this->getMappedChunk( $data, $this->getMapping() ); |
|
87 | - $listItems = $product->getListItems( 'text', $this->listTypes ); |
|
86 | + $map = $this->getMappedChunk($data, $this->getMapping()); |
|
87 | + $listItems = $product->getListItems('text', $this->listTypes); |
|
88 | 88 | |
89 | - foreach( $listItems as $listItem ) |
|
89 | + foreach ($listItems as $listItem) |
|
90 | 90 | { |
91 | - if( ( $refItem = $listItem->getRefItem() ) !== null ) { |
|
92 | - $listMap[ $refItem->getContent() ][ $refItem->getType() ][ $listItem->getType() ] = $listItem; |
|
91 | + if (($refItem = $listItem->getRefItem()) !== null) { |
|
92 | + $listMap[$refItem->getContent()][$refItem->getType()][$listItem->getType()] = $listItem; |
|
93 | 93 | } |
94 | 94 | } |
95 | 95 | |
96 | - foreach( $map as $pos => $list ) |
|
96 | + foreach ($map as $pos => $list) |
|
97 | 97 | { |
98 | - if( $this->checkEntry( $list ) === false ) { |
|
98 | + if ($this->checkEntry($list) === false) { |
|
99 | 99 | continue; |
100 | 100 | } |
101 | 101 | |
102 | - $content = trim( $list['text.content'] ); |
|
103 | - $type = trim( isset( $list['text.type'] ) ? $list['text.type'] : 'name' ); |
|
104 | - $typecode = trim( isset( $list['product.lists.type'] ) ? $list['product.lists.type'] : 'default' ); |
|
102 | + $content = trim($list['text.content']); |
|
103 | + $type = trim(isset($list['text.type']) ? $list['text.type'] : 'name'); |
|
104 | + $typecode = trim(isset($list['product.lists.type']) ? $list['product.lists.type'] : 'default'); |
|
105 | 105 | |
106 | - if( isset( $listMap[$content][$type][$typecode] ) ) |
|
106 | + if (isset($listMap[$content][$type][$typecode])) |
|
107 | 107 | { |
108 | 108 | $listItem = $listMap[$content][$type][$typecode]; |
109 | 109 | $refItem = $listItem->getRefItem(); |
110 | - unset( $listItems[ $listItem->getId() ] ); |
|
110 | + unset($listItems[$listItem->getId()]); |
|
111 | 111 | } |
112 | 112 | else |
113 | 113 | { |
114 | - $listItem = $listManager->createItem( $typecode, 'text' ); |
|
115 | - $refItem = $manager->createItem( $type, 'product' ); |
|
114 | + $listItem = $listManager->createItem($typecode, 'text'); |
|
115 | + $refItem = $manager->createItem($type, 'product'); |
|
116 | 116 | } |
117 | 117 | |
118 | - $refItem->fromArray( $this->addItemDefaults( $list ) ); |
|
119 | - $listItem->fromArray( $this->addListItemDefaults( $list, $pos ) ); |
|
118 | + $refItem->fromArray($this->addItemDefaults($list)); |
|
119 | + $listItem->fromArray($this->addListItemDefaults($list, $pos)); |
|
120 | 120 | |
121 | - $product->addListItem( 'text', $listItem, $refItem ); |
|
121 | + $product->addListItem('text', $listItem, $refItem); |
|
122 | 122 | } |
123 | 123 | |
124 | - $product->deleteListItems( $listItems, true ); |
|
124 | + $product->deleteListItems($listItems, true); |
|
125 | 125 | |
126 | - return $this->getObject()->process( $product, $data ); |
|
126 | + return $this->getObject()->process($product, $data); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | |
@@ -133,13 +133,13 @@ discard block |
||
133 | 133 | * @param array $list Associative list of domain item keys and their values, e.g. "text.status" => 1 |
134 | 134 | * @return array Given associative list enriched by default values if they were not already set |
135 | 135 | */ |
136 | - protected function addItemDefaults( array $list ) |
|
136 | + protected function addItemDefaults(array $list) |
|
137 | 137 | { |
138 | - if( !isset( $list['text.label'] ) ) { |
|
139 | - $list['text.label'] = mb_strcut( trim( $list['text.content'] ), 0, 255 ); |
|
138 | + if (!isset($list['text.label'])) { |
|
139 | + $list['text.label'] = mb_strcut(trim($list['text.content']), 0, 255); |
|
140 | 140 | } |
141 | 141 | |
142 | - if( !isset( $list['text.status'] ) ) { |
|
142 | + if (!isset($list['text.status'])) { |
|
143 | 143 | $list['text.status'] = 1; |
144 | 144 | } |
145 | 145 | |
@@ -153,10 +153,10 @@ discard block |
||
153 | 153 | * @param array $list Associative list of key/value pairs from the mapping |
154 | 154 | * @return boolean True if valid, false if not |
155 | 155 | */ |
156 | - protected function checkEntry( array $list ) |
|
156 | + protected function checkEntry(array $list) |
|
157 | 157 | { |
158 | - if( !isset( $list['text.content'] ) || trim( $list['text.content'] ) === '' || isset( $list['product.lists.type'] ) |
|
159 | - && $this->listTypes !== null && !in_array( trim( $list['product.lists.type'] ), (array) $this->listTypes ) |
|
158 | + if (!isset($list['text.content']) || trim($list['text.content']) === '' || isset($list['product.lists.type']) |
|
159 | + && $this->listTypes !== null && !in_array(trim($list['product.lists.type']), (array) $this->listTypes) |
|
160 | 160 | ) { |
161 | 161 | return false; |
162 | 162 | } |
@@ -43,10 +43,10 @@ discard block |
||
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/attribute/listtypes |
52 | 52 | * Names of the product list types for attributes that are updated or removed |
@@ -67,9 +67,9 @@ discard block |
||
67 | 67 | * @see controller/common/product/import/csv/processor/price/listtypes |
68 | 68 | * @see controller/common/product/import/csv/processor/text/listtypes |
69 | 69 | */ |
70 | - $this->listTypes = $context->getConfig()->get( 'controller/common/product/import/csv/processor/attribute/listtypes'); |
|
70 | + $this->listTypes = $context->getConfig()->get('controller/common/product/import/csv/processor/attribute/listtypes'); |
|
71 | 71 | |
72 | - $this->cache = $this->getCache( 'attribute' ); |
|
72 | + $this->cache = $this->getCache('attribute'); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | |
@@ -80,59 +80,59 @@ discard block |
||
80 | 80 | * @param array $data List of CSV fields with position as key and data as value |
81 | 81 | * @return array List of data which hasn't been imported |
82 | 82 | */ |
83 | - public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data ) |
|
83 | + public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data) |
|
84 | 84 | { |
85 | 85 | $context = $this->getContext(); |
86 | - $listManager = \Aimeos\MShop\Factory::createManager( $context, 'product/lists' ); |
|
87 | - $separator = $context->getConfig()->get( 'controller/common/product/import/csv/separator', "\n" ); |
|
86 | + $listManager = \Aimeos\MShop\Factory::createManager($context, 'product/lists'); |
|
87 | + $separator = $context->getConfig()->get('controller/common/product/import/csv/separator', "\n"); |
|
88 | 88 | |
89 | 89 | $listMap = []; |
90 | - $map = $this->getMappedChunk( $data, $this->getMapping() ); |
|
91 | - $listItems = $product->getListItems( 'attribute', $this->listTypes ); |
|
90 | + $map = $this->getMappedChunk($data, $this->getMapping()); |
|
91 | + $listItems = $product->getListItems('attribute', $this->listTypes); |
|
92 | 92 | |
93 | - foreach( $listItems as $listItem ) |
|
93 | + foreach ($listItems as $listItem) |
|
94 | 94 | { |
95 | - if( ( $refItem = $listItem->getRefItem() ) !== null ) { |
|
96 | - $listMap[ $refItem->getCode() ][ $listItem->getType() ] = $listItem; |
|
95 | + if (($refItem = $listItem->getRefItem()) !== null) { |
|
96 | + $listMap[$refItem->getCode()][$listItem->getType()] = $listItem; |
|
97 | 97 | } |
98 | 98 | } |
99 | 99 | |
100 | - foreach( $map as $pos => $list ) |
|
100 | + foreach ($map as $pos => $list) |
|
101 | 101 | { |
102 | - if( $this->checkEntry( $list ) === false ) { |
|
102 | + if ($this->checkEntry($list) === false) { |
|
103 | 103 | continue; |
104 | 104 | } |
105 | 105 | |
106 | - $codes = explode( $separator, trim( $list['attribute.code'] ) ); |
|
106 | + $codes = explode($separator, trim($list['attribute.code'])); |
|
107 | 107 | |
108 | - foreach( $codes as $code ) |
|
108 | + foreach ($codes as $code) |
|
109 | 109 | { |
110 | - $code = trim( $code ); |
|
111 | - $typecode = trim( $this->getValue( $list, 'product.lists.type', 'default' ) ); |
|
110 | + $code = trim($code); |
|
111 | + $typecode = trim($this->getValue($list, 'product.lists.type', 'default')); |
|
112 | 112 | |
113 | - if( isset( $listMap[$code][$typecode] ) ) |
|
113 | + if (isset($listMap[$code][$typecode])) |
|
114 | 114 | { |
115 | 115 | $listItem = $listMap[$code][$typecode]; |
116 | - unset( $listItems[ $listItem->getId() ] ); |
|
116 | + unset($listItems[$listItem->getId()]); |
|
117 | 117 | } |
118 | 118 | else |
119 | 119 | { |
120 | - $listItem = $listManager->createItem( $typecode, 'attribute' ); |
|
120 | + $listItem = $listManager->createItem($typecode, 'attribute'); |
|
121 | 121 | } |
122 | 122 | |
123 | - $attrItem = $this->getAttributeItem( $code, trim( $list['attribute.type'] ) ); |
|
124 | - $attrItem->fromArray( $list ); |
|
125 | - $attrItem->setCode( $code ); |
|
123 | + $attrItem = $this->getAttributeItem($code, trim($list['attribute.type'])); |
|
124 | + $attrItem->fromArray($list); |
|
125 | + $attrItem->setCode($code); |
|
126 | 126 | |
127 | - $listItem->fromArray( $this->addListItemDefaults( $list, $pos ) ); |
|
127 | + $listItem->fromArray($this->addListItemDefaults($list, $pos)); |
|
128 | 128 | |
129 | - $product->addListItem( 'attribute', $listItem, $attrItem ); |
|
129 | + $product->addListItem('attribute', $listItem, $attrItem); |
|
130 | 130 | } |
131 | 131 | } |
132 | 132 | |
133 | - $product->deleteListItems( $listItems ); |
|
133 | + $product->deleteListItems($listItems); |
|
134 | 134 | |
135 | - return $this->getObject()->process( $product, $data ); |
|
135 | + return $this->getObject()->process($product, $data); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | |
@@ -142,11 +142,11 @@ discard block |
||
142 | 142 | * @param array $list Associative list of key/value pairs from the mapped data |
143 | 143 | * @return boolean True if the entry is valid, false if not |
144 | 144 | */ |
145 | - protected function checkEntry( array $list ) |
|
145 | + protected function checkEntry(array $list) |
|
146 | 146 | { |
147 | - if( !isset( $list['attribute.code'] ) || trim( $list['attribute.code'] ) === '' |
|
148 | - || trim( $list['attribute.type'] ) === '' || isset( $list['product.lists.type'] ) |
|
149 | - && $this->listTypes !== null && !in_array( trim( $list['product.lists.type'] ), (array) $this->listTypes ) |
|
147 | + if (!isset($list['attribute.code']) || trim($list['attribute.code']) === '' |
|
148 | + || trim($list['attribute.type']) === '' || isset($list['product.lists.type']) |
|
149 | + && $this->listTypes !== null && !in_array(trim($list['product.lists.type']), (array) $this->listTypes) |
|
150 | 150 | ) { |
151 | 151 | return false; |
152 | 152 | } |
@@ -162,22 +162,22 @@ discard block |
||
162 | 162 | * @param string $type Attribute type |
163 | 163 | * @return \Aimeos\MShop\Attribute\Item\Iface Attribute item object |
164 | 164 | */ |
165 | - protected function getAttributeItem( $code, $type ) |
|
165 | + protected function getAttributeItem($code, $type) |
|
166 | 166 | { |
167 | - if( ( $item = $this->cache->get( $code, $type ) ) === null ) |
|
167 | + if (($item = $this->cache->get($code, $type)) === null) |
|
168 | 168 | { |
169 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' ); |
|
169 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute'); |
|
170 | 170 | |
171 | 171 | $item = $manager->createItem(); |
172 | - $item->setTypeId( $this->getTypeId( 'attribute/type', 'product', $type ) ); |
|
173 | - $item->setDomain( 'product' ); |
|
174 | - $item->setLabel( $code ); |
|
175 | - $item->setCode( $code ); |
|
176 | - $item->setStatus( 1 ); |
|
172 | + $item->setTypeId($this->getTypeId('attribute/type', 'product', $type)); |
|
173 | + $item->setDomain('product'); |
|
174 | + $item->setLabel($code); |
|
175 | + $item->setCode($code); |
|
176 | + $item->setStatus(1); |
|
177 | 177 | |
178 | - $item = $manager->saveItem( $item ); |
|
178 | + $item = $manager->saveItem($item); |
|
179 | 179 | |
180 | - $this->cache->set( $item ); |
|
180 | + $this->cache->set($item); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | return $item; |
@@ -28,7 +28,7 @@ discard block |
||
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 |
||
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 |
||
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 | |
@@ -131,25 +131,25 @@ discard block |
||
131 | 131 | * @param \Aimeos\MShop\Order\Item\Base\Iface $basket Order including product and addresses |
132 | 132 | * @return \Aimeos\MShop\Order\Item\Base\Iface Order with delivery service added |
133 | 133 | */ |
134 | - protected function addDeliveryService( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Order\Item\Base\Iface $basket ) |
|
134 | + protected function addDeliveryService(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Order\Item\Base\Iface $basket) |
|
135 | 135 | { |
136 | 136 | $type = \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_DELIVERY; |
137 | 137 | |
138 | - $serviceManager = \Aimeos\MShop\Factory::createManager( $context, 'service' ); |
|
139 | - $orderServiceManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base/service' ); |
|
138 | + $serviceManager = \Aimeos\MShop\Factory::createManager($context, 'service'); |
|
139 | + $orderServiceManager = \Aimeos\MShop\Factory::createManager($context, 'order/base/service'); |
|
140 | 140 | |
141 | - $search = $serviceManager->createSearch( true ); |
|
142 | - $search->setSortations( [$search->sort( '+', 'service.position' )] ); |
|
143 | - $search->setConditions( $search->compare( '==', 'service.type.code', $type ) ); |
|
141 | + $search = $serviceManager->createSearch(true); |
|
142 | + $search->setSortations([$search->sort('+', 'service.position')]); |
|
143 | + $search->setConditions($search->compare('==', 'service.type.code', $type)); |
|
144 | 144 | |
145 | - foreach( $serviceManager->searchItems( $search, ['media', 'price', 'text'] ) as $item ) |
|
145 | + foreach ($serviceManager->searchItems($search, ['media', 'price', 'text']) as $item) |
|
146 | 146 | { |
147 | - $provider = $serviceManager->getProvider( $item, $item->getType() ); |
|
147 | + $provider = $serviceManager->getProvider($item, $item->getType()); |
|
148 | 148 | |
149 | - if( $provider->isAvailable( $basket ) === true ) |
|
149 | + if ($provider->isAvailable($basket) === true) |
|
150 | 150 | { |
151 | - $orderServiceItem = $orderServiceManager->createItem()->copyFrom( $item ); |
|
152 | - $basket->addService( $orderServiceItem, $type ); |
|
151 | + $orderServiceItem = $orderServiceManager->createItem()->copyFrom($item); |
|
152 | + $basket->addService($orderServiceItem, $type); |
|
153 | 153 | |
154 | 154 | return $basket; |
155 | 155 | } |
@@ -165,30 +165,30 @@ discard block |
||
165 | 165 | * @param string $baseId Unique order base ID |
166 | 166 | * @return \Aimeos\MShop\Context\Item\Iface New context object |
167 | 167 | */ |
168 | - protected function createContext( $baseId ) |
|
168 | + protected function createContext($baseId) |
|
169 | 169 | { |
170 | 170 | $context = clone $this->getContext(); |
171 | 171 | |
172 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'order/base' ); |
|
173 | - $baseItem = $manager->getItem( $baseId ); |
|
172 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'order/base'); |
|
173 | + $baseItem = $manager->getItem($baseId); |
|
174 | 174 | |
175 | 175 | $locale = $baseItem->getLocale(); |
176 | 176 | $level = \Aimeos\MShop\Locale\Manager\Base::SITE_ALL; |
177 | 177 | |
178 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'locale' ); |
|
179 | - $locale = $manager->bootstrap( $baseItem->getSiteCode(), $locale->getLanguageId(), $locale->getCurrencyId(), false, $level ); |
|
178 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'locale'); |
|
179 | + $locale = $manager->bootstrap($baseItem->getSiteCode(), $locale->getLanguageId(), $locale->getCurrencyId(), false, $level); |
|
180 | 180 | |
181 | - $context->setLocale( $locale ); |
|
181 | + $context->setLocale($locale); |
|
182 | 182 | |
183 | 183 | try |
184 | 184 | { |
185 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'customer' ); |
|
186 | - $customerItem = $manager->getItem( $baseItem->getCustomerId(), ['customer/group'] ); |
|
185 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'customer'); |
|
186 | + $customerItem = $manager->getItem($baseItem->getCustomerId(), ['customer/group']); |
|
187 | 187 | |
188 | - $context->setUserId( $baseItem->getCustomerId() ); |
|
189 | - $context->setGroupIds( $customerItem->getGroups() ); |
|
188 | + $context->setUserId($baseItem->getCustomerId()); |
|
189 | + $context->setGroupIds($customerItem->getGroups()); |
|
190 | 190 | } |
191 | - catch( \Exception $e ) {} // Subscription without account |
|
191 | + catch (\Exception $e) {} // Subscription without account |
|
192 | 192 | |
193 | 193 | return $context; |
194 | 194 | } |
@@ -201,39 +201,39 @@ discard block |
||
201 | 201 | * @param \Aimeos\MShop\Subscription\Item\Iface $subscription Subscription item with order base ID and order product ID |
202 | 202 | * @return \Aimeos\MShop\Order\Item\Base\Iface Complete order with product, addresses and services saved to the storage |
203 | 203 | */ |
204 | - protected function createOrderBase( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Subscription\Item\Iface $subscription ) |
|
204 | + protected function createOrderBase(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Subscription\Item\Iface $subscription) |
|
205 | 205 | { |
206 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'order/base' ); |
|
206 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'order/base'); |
|
207 | 207 | |
208 | - $basket = $manager->load( $subscription->getOrderBaseId() ); |
|
208 | + $basket = $manager->load($subscription->getOrderBaseId()); |
|
209 | 209 | |
210 | 210 | $newBasket = $manager->createItem(); |
211 | - $newBasket->setCustomerId( $basket->getCustomerId() ); |
|
211 | + $newBasket->setCustomerId($basket->getCustomerId()); |
|
212 | 212 | |
213 | - foreach( $basket->getProducts() as $orderProduct ) |
|
213 | + foreach ($basket->getProducts() as $orderProduct) |
|
214 | 214 | { |
215 | - if( $orderProduct->getId() === $subscription->getOrderProductId() ) |
|
215 | + if ($orderProduct->getId() === $subscription->getOrderProductId()) |
|
216 | 216 | { |
217 | - foreach( $orderProduct->getAttributeItems() as $attrItem ) { |
|
218 | - $attrItem->setId( null ); |
|
217 | + foreach ($orderProduct->getAttributeItems() as $attrItem) { |
|
218 | + $attrItem->setId(null); |
|
219 | 219 | } |
220 | - $newBasket->addProduct( $orderProduct->setId( null ) ); |
|
220 | + $newBasket->addProduct($orderProduct->setId(null)); |
|
221 | 221 | } |
222 | 222 | } |
223 | 223 | |
224 | - foreach( $basket->getAddresses() as $type => $orderAddress ) { |
|
225 | - $newBasket->setAddress( $orderAddress, $type ); |
|
224 | + foreach ($basket->getAddresses() as $type => $orderAddress) { |
|
225 | + $newBasket->setAddress($orderAddress, $type); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | $type = \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_PAYMENT; |
229 | 229 | |
230 | - foreach( $basket->getService( $type ) as $orderService ) { |
|
231 | - $newBasket->addService( $orderService, $type ); |
|
230 | + foreach ($basket->getService($type) as $orderService) { |
|
231 | + $newBasket->addService($orderService, $type); |
|
232 | 232 | } |
233 | 233 | |
234 | - $newBasket = $this->addDeliveryService( $context, $newBasket ); |
|
234 | + $newBasket = $this->addDeliveryService($context, $newBasket); |
|
235 | 235 | |
236 | - return $manager->store( $newBasket ); |
|
236 | + return $manager->store($newBasket); |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | |
@@ -244,15 +244,15 @@ discard block |
||
244 | 244 | * @param \Aimeos\MShop\Order\Item\Base\Iface $basket Complete order with product, addresses and services saved to the storage |
245 | 245 | * @return \Aimeos\MShop\Order\Item\Iface New invoice item associated to the order saved to the storage |
246 | 246 | */ |
247 | - protected function createOrderInvoice( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Order\Item\Base\Iface $basket ) |
|
247 | + protected function createOrderInvoice(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Order\Item\Base\Iface $basket) |
|
248 | 248 | { |
249 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'order' ); |
|
249 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'order'); |
|
250 | 250 | |
251 | 251 | $item = $manager->createItem(); |
252 | - $item->setBaseId( $basket->getId() ); |
|
253 | - $item->setType( 'subscription' ); |
|
252 | + $item->setBaseId($basket->getId()); |
|
253 | + $item->setType('subscription'); |
|
254 | 254 | |
255 | - return $manager->saveItem( $item ); |
|
255 | + return $manager->saveItem($item); |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | |
@@ -263,17 +263,17 @@ discard block |
||
263 | 263 | * @param \Aimeos\MShop\Order\Item\Base\Iface $basket Complete order with product, addresses and services |
264 | 264 | * @param \Aimeos\MShop\Order\Item\Iface New invoice item associated to the order |
265 | 265 | */ |
266 | - protected function createPayment( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Order\Item\Base\Iface $basket, |
|
267 | - \Aimeos\MShop\Order\Item\Iface $invoice ) |
|
266 | + protected function createPayment(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Order\Item\Base\Iface $basket, |
|
267 | + \Aimeos\MShop\Order\Item\Iface $invoice) |
|
268 | 268 | { |
269 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'service' ); |
|
269 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'service'); |
|
270 | 270 | |
271 | - foreach( $basket->getService( \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_PAYMENT ) as $service ) |
|
271 | + foreach ($basket->getService(\Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_PAYMENT) as $service) |
|
272 | 272 | { |
273 | - $item = $manager->getItem( $service->getServiceId() ); |
|
274 | - $provider = $manager->getProvider( $item, 'payment' ); |
|
273 | + $item = $manager->getItem($service->getServiceId()); |
|
274 | + $provider = $manager->getProvider($item, 'payment'); |
|
275 | 275 | |
276 | - $provider->repay( $invoice ); |
|
276 | + $provider->repay($invoice); |
|
277 | 277 | } |
278 | 278 | } |
279 | 279 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function getName() |
30 | 30 | { |
31 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Order export CSV' ); |
|
31 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Order export CSV'); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function getDescription() |
41 | 41 | { |
42 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Exports orders to CSV file' ); |
|
42 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Exports orders to CSV file'); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * @category Developer |
74 | 74 | * @see controller/common/order/export/csv/max-size |
75 | 75 | */ |
76 | - $mappings = $config->get( 'controller/common/order/export/csv/mapping', $mappings ); |
|
76 | + $mappings = $config->get('controller/common/order/export/csv/mapping', $mappings); |
|
77 | 77 | |
78 | 78 | /** controller/jobs/order/export/csv/mapping |
79 | 79 | * List of mappings between the position in the CSV file and item keys |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | * @category Developer |
89 | 89 | * @see controller/common/order/export/csv/max-size |
90 | 90 | */ |
91 | - $mappings = $config->get( 'controller/jobs/order/export/csv/mapping', $mappings ); |
|
91 | + $mappings = $config->get('controller/jobs/order/export/csv/mapping', $mappings); |
|
92 | 92 | |
93 | 93 | |
94 | 94 | /** controller/common/order/export/csv/max-size |
@@ -106,29 +106,29 @@ discard block |
||
106 | 106 | * @category Developer |
107 | 107 | * @see controller/common/order/export/csv/mapping |
108 | 108 | */ |
109 | - $maxcnt = (int) $config->get( 'controller/common/order/export/csv/max-size', 1000 ); |
|
109 | + $maxcnt = (int) $config->get('controller/common/order/export/csv/max-size', 1000); |
|
110 | 110 | |
111 | 111 | |
112 | - $processors = $this->getProcessors( $mappings ); |
|
113 | - $mq = $context->getMessageQueueManager()->get( 'mq-admin' )->getQueue( 'order-export' ); |
|
112 | + $processors = $this->getProcessors($mappings); |
|
113 | + $mq = $context->getMessageQueueManager()->get('mq-admin')->getQueue('order-export'); |
|
114 | 114 | |
115 | - while( ( $msg = $mq->get() ) !== null ) |
|
115 | + while (($msg = $mq->get()) !== null) |
|
116 | 116 | { |
117 | 117 | try |
118 | 118 | { |
119 | - if( ( $data = json_decode( $msg->getBody(), true ) ) === null ) { |
|
120 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid message: %1$s', $msg->getBody() ) ); |
|
119 | + if (($data = json_decode($msg->getBody(), true)) === null) { |
|
120 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid message: %1$s', $msg->getBody())); |
|
121 | 121 | } |
122 | 122 | |
123 | - $this->export( $processors, $data, $maxcnt ); |
|
123 | + $this->export($processors, $data, $maxcnt); |
|
124 | 124 | } |
125 | - catch( \Exception $e ) |
|
125 | + catch (\Exception $e) |
|
126 | 126 | { |
127 | - $logger->log( 'Order export error: ' . $e->getMessage() ); |
|
128 | - $logger->log( $e->getTraceAsString() ); |
|
127 | + $logger->log('Order export error: ' . $e->getMessage()); |
|
128 | + $logger->log($e->getTraceAsString()); |
|
129 | 129 | } |
130 | 130 | |
131 | - $mq->del( $msg ); |
|
131 | + $mq->del($msg); |
|
132 | 132 | } |
133 | 133 | } |
134 | 134 | |
@@ -139,15 +139,15 @@ discard block |
||
139 | 139 | * @param \Aimeos\MShop\Context\Item\Iface $context Context item |
140 | 140 | * @param string $path Absolute path to the exported file |
141 | 141 | */ |
142 | - protected function addJob( $context, $path ) |
|
142 | + protected function addJob($context, $path) |
|
143 | 143 | { |
144 | - $manager = \Aimeos\MAdmin\Factory::createManager( $context, 'job' ); |
|
144 | + $manager = \Aimeos\MAdmin\Factory::createManager($context, 'job'); |
|
145 | 145 | |
146 | 146 | $item = $manager->createItem(); |
147 | - $item->setResult( ['file' => $path] ); |
|
148 | - $item->setLabel( $path ); |
|
147 | + $item->setResult(['file' => $path]); |
|
148 | + $item->setLabel($path); |
|
149 | 149 | |
150 | - $manager->saveItem( $item, false ); |
|
150 | + $manager->saveItem($item, false); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | * @see controller/jobs/order/export/csv/container/content |
178 | 178 | * @see controller/jobs/order/export/csv/container/options |
179 | 179 | */ |
180 | - $location = $config->get( 'controller/jobs/order/export/csv/location', sys_get_temp_dir() ); |
|
180 | + $location = $config->get('controller/jobs/order/export/csv/location', sys_get_temp_dir()); |
|
181 | 181 | |
182 | 182 | /** controller/jobs/order/export/csv/container/type |
183 | 183 | * Nave of the container type to read the data from |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | * @see controller/jobs/order/export/csv/container/content |
201 | 201 | * @see controller/jobs/order/export/csv/container/options |
202 | 202 | */ |
203 | - $container = $config->get( 'controller/jobs/order/export/csv/container/type', 'Directory' ); |
|
203 | + $container = $config->get('controller/jobs/order/export/csv/container/type', 'Directory'); |
|
204 | 204 | |
205 | 205 | /** controller/jobs/order/export/csv/container/content |
206 | 206 | * Name of the content type inside the container to read the data from |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | * @see controller/jobs/order/export/csv/container/type |
222 | 222 | * @see controller/jobs/order/export/csv/container/options |
223 | 223 | */ |
224 | - $content = $config->get( 'controller/jobs/order/export/csv/container/content', 'CSV' ); |
|
224 | + $content = $config->get('controller/jobs/order/export/csv/container/content', 'CSV'); |
|
225 | 225 | |
226 | 226 | /** controller/jobs/order/export/csv/container/options |
227 | 227 | * List of file container options for the order export files |
@@ -239,9 +239,9 @@ discard block |
||
239 | 239 | * @see controller/jobs/order/export/csv/container/content |
240 | 240 | * @see controller/jobs/order/export/csv/container/type |
241 | 241 | */ |
242 | - $options = $config->get( 'controller/jobs/order/export/csv/container/options', [] ); |
|
242 | + $options = $config->get('controller/jobs/order/export/csv/container/options', []); |
|
243 | 243 | |
244 | - return \Aimeos\MW\Container\Factory::getContainer( $location, $container, $content, $options ); |
|
244 | + return \Aimeos\MW\Container\Factory::getContainer($location, $container, $content, $options); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | |
@@ -253,56 +253,56 @@ discard block |
||
253 | 253 | * @param integer $maxcnt Maximum number of retrieved orders at once |
254 | 254 | * @return string Path of the file containing the exported data |
255 | 255 | */ |
256 | - protected function export( array $processors, $msg, $maxcnt ) |
|
256 | + protected function export(array $processors, $msg, $maxcnt) |
|
257 | 257 | { |
258 | - $lcontext = $this->getLocaleContext( $msg ); |
|
258 | + $lcontext = $this->getLocaleContext($msg); |
|
259 | 259 | $baseRef = ['order/base/address', 'order/base/coupon', 'order/base/product', 'order/base/service']; |
260 | 260 | |
261 | - $manager = \Aimeos\MShop\Factory::createManager( $lcontext, 'order' ); |
|
262 | - $baseManager = \Aimeos\MShop\Factory::createManager( $lcontext, 'order/base' ); |
|
261 | + $manager = \Aimeos\MShop\Factory::createManager($lcontext, 'order'); |
|
262 | + $baseManager = \Aimeos\MShop\Factory::createManager($lcontext, 'order/base'); |
|
263 | 263 | |
264 | 264 | $container = $this->getContainer(); |
265 | - $content = $container->create( 'order-export_' . date( 'Y-m-d_H-i-s' ) ); |
|
266 | - $search = $this->initCriteria( $manager->createSearch()->setSlice( 0, 0x7fffffff ), $msg ); |
|
265 | + $content = $container->create('order-export_' . date('Y-m-d_H-i-s')); |
|
266 | + $search = $this->initCriteria($manager->createSearch()->setSlice(0, 0x7fffffff), $msg); |
|
267 | 267 | $start = 0; |
268 | 268 | |
269 | 269 | do |
270 | 270 | { |
271 | 271 | $baseIds = []; |
272 | - $search->setSlice( $start, $maxcnt ); |
|
273 | - $items = $manager->searchItems( $search ); |
|
272 | + $search->setSlice($start, $maxcnt); |
|
273 | + $items = $manager->searchItems($search); |
|
274 | 274 | |
275 | - foreach( $items as $item ) { |
|
275 | + foreach ($items as $item) { |
|
276 | 276 | $baseIds[] = $item->getBaseId(); |
277 | 277 | } |
278 | 278 | |
279 | 279 | $baseSearch = $baseManager->createSearch(); |
280 | - $baseSearch->setConditions( $baseSearch->compare( '==', 'order.base.id', $baseIds ) ); |
|
281 | - $baseSearch->setSlice( 0, count( $baseIds ) ); |
|
280 | + $baseSearch->setConditions($baseSearch->compare('==', 'order.base.id', $baseIds)); |
|
281 | + $baseSearch->setSlice(0, count($baseIds)); |
|
282 | 282 | |
283 | - $baseItems = $baseManager->searchItems( $baseSearch, $baseRef ); |
|
283 | + $baseItems = $baseManager->searchItems($baseSearch, $baseRef); |
|
284 | 284 | |
285 | - foreach( $items as $id => $item ) |
|
285 | + foreach ($items as $id => $item) |
|
286 | 286 | { |
287 | - foreach( $processors as $type => $processor ) |
|
287 | + foreach ($processors as $type => $processor) |
|
288 | 288 | { |
289 | - foreach( $processor->process( $item, $baseItems[$item->getBaseId()] ) as $line ) { |
|
290 | - $content->add( [0 => $type, 1 => $id] + $line ); |
|
289 | + foreach ($processor->process($item, $baseItems[$item->getBaseId()]) as $line) { |
|
290 | + $content->add([0 => $type, 1 => $id] + $line); |
|
291 | 291 | } |
292 | 292 | } |
293 | 293 | } |
294 | 294 | |
295 | - $count = count( $items ); |
|
295 | + $count = count($items); |
|
296 | 296 | $start += $count; |
297 | 297 | } |
298 | - while( $count === $search->getSliceSize() ); |
|
298 | + while ($count === $search->getSliceSize()); |
|
299 | 299 | |
300 | 300 | $path = $content->getResource(); |
301 | - $container->add( $content ); |
|
301 | + $container->add($content); |
|
302 | 302 | $container->close(); |
303 | 303 | |
304 | - $path = $this->moveFile( $lcontext, $path ); |
|
305 | - $this->addJob( $lcontext, $path ); |
|
304 | + $path = $this->moveFile($lcontext, $path); |
|
305 | + $this->addJob($lcontext, $path); |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | |
@@ -312,15 +312,15 @@ discard block |
||
312 | 312 | * @param array $msg Message data including a "sitecode" value |
313 | 313 | * @return \Aimeos\MShop\Context\Item\Iface New context item with updated locale |
314 | 314 | */ |
315 | - protected function getLocaleContext( array $msg ) |
|
315 | + protected function getLocaleContext(array $msg) |
|
316 | 316 | { |
317 | 317 | $lcontext = clone $this->getContext(); |
318 | - $manager = \Aimeos\MShop\Factory::createManager( $lcontext, 'locale' ); |
|
318 | + $manager = \Aimeos\MShop\Factory::createManager($lcontext, 'locale'); |
|
319 | 319 | |
320 | - $sitecode = ( isset( $msg['sitecode'] ) ? $msg['sitecode'] : 'default' ); |
|
321 | - $localeItem = $manager->bootstrap( $sitecode, '', '', false, \Aimeos\MShop\Locale\Manager\Base::SITE_PATH ); |
|
320 | + $sitecode = (isset($msg['sitecode']) ? $msg['sitecode'] : 'default'); |
|
321 | + $localeItem = $manager->bootstrap($sitecode, '', '', false, \Aimeos\MShop\Locale\Manager\Base::SITE_PATH); |
|
322 | 322 | |
323 | - return $lcontext->setLocale( $localeItem ); |
|
323 | + return $lcontext->setLocale($localeItem); |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | |
@@ -331,14 +331,14 @@ discard block |
||
331 | 331 | * @param array $msg Message data |
332 | 332 | * @return \Aimeos\MW\Criteria\Iface Initialized criteria object |
333 | 333 | */ |
334 | - protected function initCriteria( \Aimeos\MW\Criteria\Iface $criteria, array $msg ) |
|
334 | + protected function initCriteria(\Aimeos\MW\Criteria\Iface $criteria, array $msg) |
|
335 | 335 | { |
336 | - if( isset( $msg['filter'] ) ) { |
|
337 | - $criteria->setConditions( $criteria->toConditions( $msg['filter'] ) ); |
|
336 | + if (isset($msg['filter'])) { |
|
337 | + $criteria->setConditions($criteria->toConditions($msg['filter'])); |
|
338 | 338 | } |
339 | 339 | |
340 | - if( isset( $msg['sort'] ) ) { |
|
341 | - $criteria->setSortations( $criteria->toSortations( $msg['sort'] ) ); |
|
340 | + if (isset($msg['sort'])) { |
|
341 | + $criteria->setSortations($criteria->toSortations($msg['sort'])); |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | return $criteria; |
@@ -352,12 +352,12 @@ discard block |
||
352 | 352 | * @param string $path Absolute path to the exported file |
353 | 353 | * @return string Relative path of the file in the storage |
354 | 354 | */ |
355 | - protected function moveFile( $context, $path ) |
|
355 | + protected function moveFile($context, $path) |
|
356 | 356 | { |
357 | - $filename = basename( $path ); |
|
358 | - $context->getFileSystemManager()->get( 'fs-admin' )->writef( $filename, $path ); |
|
357 | + $filename = basename($path); |
|
358 | + $context->getFileSystemManager()->get('fs-admin')->writef($filename, $path); |
|
359 | 359 | |
360 | - unlink( $path ); |
|
360 | + unlink($path); |
|
361 | 361 | return $filename; |
362 | 362 | } |
363 | 363 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function getName() |
30 | 30 | { |
31 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Subscription process start' ); |
|
31 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Subscription process start'); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function getDescription() |
41 | 41 | { |
42 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Process subscriptions initially' ); |
|
42 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Process subscriptions initially'); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * @see controller/common/subscription/process/payment-status |
68 | 68 | * @see controller/common/subscription/process/payment-days |
69 | 69 | */ |
70 | - $names = (array) $config->get( 'controller/common/subscription/process/processors', [] ); |
|
70 | + $names = (array) $config->get('controller/common/subscription/process/processors', []); |
|
71 | 71 | |
72 | 72 | /** controller/common/subscription/process/payment-status |
73 | 73 | * Minimum payment status that will activate the subscription |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * @see controller/common/subscription/process/payment-days |
87 | 87 | */ |
88 | 88 | $status = \Aimeos\MShop\Order\Item\Base::PAY_AUTHORIZED; |
89 | - $status = $config->get( 'controller/common/subscription/process/payment-status', $status ); |
|
89 | + $status = $config->get('controller/common/subscription/process/payment-status', $status); |
|
90 | 90 | |
91 | 91 | /** controller/common/subscription/process/payment-days |
92 | 92 | * Number of days to wait for the payment until subscription is removed |
@@ -104,74 +104,74 @@ discard block |
||
104 | 104 | * @see controller/common/subscription/process/processors |
105 | 105 | * @see controller/common/subscription/process/payment-status |
106 | 106 | */ |
107 | - $days = (float) $config->get( 'controller/common/subscription/process/payment-days', 3 ); |
|
107 | + $days = (float) $config->get('controller/common/subscription/process/payment-days', 3); |
|
108 | 108 | |
109 | 109 | |
110 | - $processors = $this->getProcessors( $names ); |
|
111 | - $orderManager = \Aimeos\MShop\Factory::createManager( $context, 'order' ); |
|
112 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'subscription' ); |
|
110 | + $processors = $this->getProcessors($names); |
|
111 | + $orderManager = \Aimeos\MShop\Factory::createManager($context, 'order'); |
|
112 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'subscription'); |
|
113 | 113 | |
114 | - $search = $manager->createSearch( true ); |
|
114 | + $search = $manager->createSearch(true); |
|
115 | 115 | $expr = [ |
116 | - $search->compare( '==', 'subscription.datenext', null ), |
|
116 | + $search->compare('==', 'subscription.datenext', null), |
|
117 | 117 | $search->getConditions(), |
118 | 118 | ]; |
119 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
120 | - $search->setSortations( [$search->sort( '+', 'subscription.id' )] ); |
|
119 | + $search->setConditions($search->combine('&&', $expr)); |
|
120 | + $search->setSortations([$search->sort('+', 'subscription.id')]); |
|
121 | 121 | |
122 | - $date = date( 'Y-m-d H:i:s', time() - 86400 * $days ); |
|
122 | + $date = date('Y-m-d H:i:s', time() - 86400 * $days); |
|
123 | 123 | $start = 0; |
124 | 124 | |
125 | 125 | do |
126 | 126 | { |
127 | 127 | $ordBaseIds = $payStatus = []; |
128 | 128 | |
129 | - $search->setSlice( $start, 100 ); |
|
130 | - $items = $manager->searchItems( $search ); |
|
129 | + $search->setSlice($start, 100); |
|
130 | + $items = $manager->searchItems($search); |
|
131 | 131 | |
132 | - foreach( $items as $item ) { |
|
132 | + foreach ($items as $item) { |
|
133 | 133 | $ordBaseIds[] = $item->getOrderBaseId(); |
134 | 134 | } |
135 | 135 | |
136 | - $orderSearch = $orderManager->createSearch()->setSlice( 0, $search->getSliceSize() ); |
|
137 | - $orderSearch->setConditions( $orderSearch->compare( '==', 'order.base.id', $ordBaseIds ) ); |
|
138 | - $orderSearch->setSortations( [$orderSearch->sort( '+', 'order.id' )] ); |
|
136 | + $orderSearch = $orderManager->createSearch()->setSlice(0, $search->getSliceSize()); |
|
137 | + $orderSearch->setConditions($orderSearch->compare('==', 'order.base.id', $ordBaseIds)); |
|
138 | + $orderSearch->setSortations([$orderSearch->sort('+', 'order.id')]); |
|
139 | 139 | |
140 | - foreach( $orderManager->searchItems( $orderSearch ) as $orderItem ) { |
|
140 | + foreach ($orderManager->searchItems($orderSearch) as $orderItem) { |
|
141 | 141 | $payStatus[$orderItem->getBaseId()] = $orderItem->getPaymentStatus(); |
142 | 142 | } |
143 | 143 | |
144 | - foreach( $items as $item ) |
|
144 | + foreach ($items as $item) |
|
145 | 145 | { |
146 | 146 | try |
147 | 147 | { |
148 | - if( isset( $payStatus[$item->getOrderBaseId()] ) && $payStatus[$item->getOrderBaseId()] >= $status ) |
|
148 | + if (isset($payStatus[$item->getOrderBaseId()]) && $payStatus[$item->getOrderBaseId()] >= $status) |
|
149 | 149 | { |
150 | - foreach( $processors as $processor ) { |
|
151 | - $processor->begin( $item ); |
|
150 | + foreach ($processors as $processor) { |
|
151 | + $processor->begin($item); |
|
152 | 152 | } |
153 | 153 | |
154 | - $interval = new \DateInterval( $item->getInterval() ); |
|
155 | - $item->setDateNext( date_create( $item->getTimeCreated() )->add( $interval )->format( 'Y-m-d' ) ); |
|
154 | + $interval = new \DateInterval($item->getInterval()); |
|
155 | + $item->setDateNext(date_create($item->getTimeCreated())->add($interval)->format('Y-m-d')); |
|
156 | 156 | } |
157 | - elseif( $item->getTimeCreated() < $date ) |
|
157 | + elseif ($item->getTimeCreated() < $date) |
|
158 | 158 | { |
159 | - $item->setStatus( 0 ); |
|
159 | + $item->setStatus(0); |
|
160 | 160 | } |
161 | 161 | |
162 | - $manager->saveItem( $item ); |
|
162 | + $manager->saveItem($item); |
|
163 | 163 | } |
164 | - catch( \Exception $e ) |
|
164 | + catch (\Exception $e) |
|
165 | 165 | { |
166 | 166 | $msg = 'Unable to process subscription with ID "%1$S": %2$s'; |
167 | - $logger->log( sprintf( $msg, $item->getId(), $e->getMessage() ) ); |
|
168 | - $logger->log( $e->getTraceAsString() ); |
|
167 | + $logger->log(sprintf($msg, $item->getId(), $e->getMessage())); |
|
168 | + $logger->log($e->getTraceAsString()); |
|
169 | 169 | } |
170 | 170 | } |
171 | 171 | |
172 | - $count = count( $items ); |
|
172 | + $count = count($items); |
|
173 | 173 | $start += $count; |
174 | 174 | } |
175 | - while( $count === $search->getSliceSize() ); |
|
175 | + while ($count === $search->getSliceSize()); |
|
176 | 176 | } |
177 | 177 | } |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | */ |
32 | 32 | public function getName() |
33 | 33 | { |
34 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Product import CSV' ); |
|
34 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Product import CSV'); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | */ |
43 | 43 | public function getDescription() |
44 | 44 | { |
45 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Imports new and updates existing products from CSV files' ); |
|
45 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Imports new and updates existing products from CSV files'); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | $context = $this->getContext(); |
58 | 58 | $config = $context->getConfig(); |
59 | 59 | $logger = $context->getLogger(); |
60 | - $domains = array( 'attribute', 'media', 'price', 'product', 'product/property', 'text' ); |
|
60 | + $domains = array('attribute', 'media', 'price', 'product', 'product/property', 'text'); |
|
61 | 61 | $mappings = $this->getDefaultMapping(); |
62 | 62 | |
63 | 63 | |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | * @see controller/common/product/import/csv/converter |
78 | 78 | * @see controller/common/product/import/csv/max-size |
79 | 79 | */ |
80 | - $domains = $config->get( 'controller/common/product/import/csv/domains', $domains ); |
|
80 | + $domains = $config->get('controller/common/product/import/csv/domains', $domains); |
|
81 | 81 | |
82 | 82 | /** controller/jobs/product/import/csv/domains |
83 | 83 | * List of item domain names that should be retrieved along with the product items |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * @see controller/jobs/product/import/csv/backup |
98 | 98 | * @see controller/common/product/import/csv/max-size |
99 | 99 | */ |
100 | - $domains = $config->get( 'controller/jobs/product/import/csv/domains', $domains ); |
|
100 | + $domains = $config->get('controller/jobs/product/import/csv/domains', $domains); |
|
101 | 101 | |
102 | 102 | |
103 | 103 | /** controller/common/product/import/csv/mapping |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | * @see controller/common/product/import/csv/converter |
126 | 126 | * @see controller/common/product/import/csv/max-size |
127 | 127 | */ |
128 | - $mappings = $config->get( 'controller/common/product/import/csv/mapping', $mappings ); |
|
128 | + $mappings = $config->get('controller/common/product/import/csv/mapping', $mappings); |
|
129 | 129 | |
130 | 130 | /** controller/jobs/product/import/csv/mapping |
131 | 131 | * List of mappings between the position in the CSV file and item keys |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | * @see controller/jobs/product/import/csv/backup |
146 | 146 | * @see controller/common/product/import/csv/max-size |
147 | 147 | */ |
148 | - $mappings = $config->get( 'controller/jobs/product/import/csv/mapping', $mappings ); |
|
148 | + $mappings = $config->get('controller/jobs/product/import/csv/mapping', $mappings); |
|
149 | 149 | |
150 | 150 | |
151 | 151 | /** controller/common/product/import/csv/converter |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | * @see controller/common/product/import/csv/mapping |
188 | 188 | * @see controller/common/product/import/csv/max-size |
189 | 189 | */ |
190 | - $converters = $config->get( 'controller/common/product/import/csv/converter', [] ); |
|
190 | + $converters = $config->get('controller/common/product/import/csv/converter', []); |
|
191 | 191 | |
192 | 192 | /** controller/jobs/product/import/csv/converter |
193 | 193 | * List of converter names for the values at the position in the CSV file |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | * @see controller/jobs/product/import/csv/backup |
208 | 208 | * @see controller/common/product/import/csv/max-size |
209 | 209 | */ |
210 | - $converters = $config->get( 'controller/jobs/product/import/csv/converter', $converters ); |
|
210 | + $converters = $config->get('controller/jobs/product/import/csv/converter', $converters); |
|
211 | 211 | |
212 | 212 | |
213 | 213 | /** controller/common/product/import/csv/max-size |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | * @see controller/common/product/import/csv/mapping |
228 | 228 | * @see controller/common/product/import/csv/converter |
229 | 229 | */ |
230 | - $maxcnt = (int) $config->get( 'controller/common/product/import/csv/max-size', 1000 ); |
|
230 | + $maxcnt = (int) $config->get('controller/common/product/import/csv/max-size', 1000); |
|
231 | 231 | |
232 | 232 | |
233 | 233 | /** controller/jobs/product/import/csv/skip-lines |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | * @see controller/jobs/product/import/csv/backup |
250 | 250 | * @see controller/common/product/import/csv/max-size |
251 | 251 | */ |
252 | - $skiplines = (int) $config->get( 'controller/jobs/product/import/csv/skip-lines', 0 ); |
|
252 | + $skiplines = (int) $config->get('controller/jobs/product/import/csv/skip-lines', 0); |
|
253 | 253 | |
254 | 254 | |
255 | 255 | /** controller/jobs/product/import/csv/strict |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | * @see controller/jobs/product/import/csv/backup |
274 | 274 | * @see controller/common/product/import/csv/max-size |
275 | 275 | */ |
276 | - $strict = (bool) $config->get( 'controller/jobs/product/import/csv/strict', true ); |
|
276 | + $strict = (bool) $config->get('controller/jobs/product/import/csv/strict', true); |
|
277 | 277 | |
278 | 278 | |
279 | 279 | /** controller/jobs/product/import/csv/backup |
@@ -306,74 +306,74 @@ discard block |
||
306 | 306 | * @see controller/jobs/product/import/csv/strict |
307 | 307 | * @see controller/common/product/import/csv/max-size |
308 | 308 | */ |
309 | - $backup = $config->get( 'controller/jobs/product/import/csv/backup' ); |
|
309 | + $backup = $config->get('controller/jobs/product/import/csv/backup'); |
|
310 | 310 | |
311 | 311 | |
312 | - if( !isset( $mappings['item'] ) || !is_array( $mappings['item'] ) ) |
|
312 | + if (!isset($mappings['item']) || !is_array($mappings['item'])) |
|
313 | 313 | { |
314 | - $msg = sprintf( 'Required mapping key "%1$s" is missing or contains no array', 'item' ); |
|
315 | - throw new \Aimeos\Controller\Jobs\Exception( $msg ); |
|
314 | + $msg = sprintf('Required mapping key "%1$s" is missing or contains no array', 'item'); |
|
315 | + throw new \Aimeos\Controller\Jobs\Exception($msg); |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | try |
319 | 319 | { |
320 | 320 | $procMappings = $mappings; |
321 | - unset( $procMappings['item'] ); |
|
321 | + unset($procMappings['item']); |
|
322 | 322 | |
323 | - $codePos = $this->getCodePosition( $mappings['item'] ); |
|
324 | - $convlist = $this->getConverterList( $converters ); |
|
325 | - $processor = $this->getProcessors( $procMappings ); |
|
323 | + $codePos = $this->getCodePosition($mappings['item']); |
|
324 | + $convlist = $this->getConverterList($converters); |
|
325 | + $processor = $this->getProcessors($procMappings); |
|
326 | 326 | $container = $this->getContainer(); |
327 | 327 | $path = $container->getName(); |
328 | 328 | |
329 | - $msg = sprintf( 'Started product import from "%1$s" (%2$s)', $path, __CLASS__ ); |
|
330 | - $logger->log( $msg, \Aimeos\MW\Logger\Base::NOTICE ); |
|
329 | + $msg = sprintf('Started product import from "%1$s" (%2$s)', $path, __CLASS__); |
|
330 | + $logger->log($msg, \Aimeos\MW\Logger\Base::NOTICE); |
|
331 | 331 | |
332 | - foreach( $container as $content ) |
|
332 | + foreach ($container as $content) |
|
333 | 333 | { |
334 | 334 | $name = $content->getName(); |
335 | 335 | |
336 | - for( $i = 0; $i < $skiplines; $i++ ) { |
|
336 | + for ($i = 0; $i < $skiplines; $i++) { |
|
337 | 337 | $content->next(); |
338 | 338 | } |
339 | 339 | |
340 | - while( ( $data = $this->getData( $content, $maxcnt, $codePos ) ) !== [] ) |
|
340 | + while (($data = $this->getData($content, $maxcnt, $codePos)) !== []) |
|
341 | 341 | { |
342 | - $data = $this->convertData( $convlist, $data ); |
|
343 | - $products = $this->getProducts( array_keys( $data ), $domains ); |
|
344 | - $errcnt = $this->import( $products, $data, $mappings['item'], $processor, $strict ); |
|
345 | - $chunkcnt = count( $data ); |
|
342 | + $data = $this->convertData($convlist, $data); |
|
343 | + $products = $this->getProducts(array_keys($data), $domains); |
|
344 | + $errcnt = $this->import($products, $data, $mappings['item'], $processor, $strict); |
|
345 | + $chunkcnt = count($data); |
|
346 | 346 | |
347 | 347 | $msg = 'Imported product lines from "%1$s": %2$d/%3$d (%4$s)'; |
348 | - $logger->log( sprintf( $msg, $name, $chunkcnt - $errcnt, $chunkcnt, __CLASS__ ), \Aimeos\MW\Logger\Base::NOTICE ); |
|
348 | + $logger->log(sprintf($msg, $name, $chunkcnt - $errcnt, $chunkcnt, __CLASS__), \Aimeos\MW\Logger\Base::NOTICE); |
|
349 | 349 | |
350 | 350 | $errors += $errcnt; |
351 | 351 | $total += $chunkcnt; |
352 | - unset( $products, $data ); |
|
352 | + unset($products, $data); |
|
353 | 353 | } |
354 | 354 | } |
355 | 355 | |
356 | 356 | $container->close(); |
357 | 357 | } |
358 | - catch( \Exception $e ) |
|
358 | + catch (\Exception $e) |
|
359 | 359 | { |
360 | - $logger->log( 'Product import error: ' . $e->getMessage() ); |
|
361 | - $logger->log( $e->getTraceAsString() ); |
|
360 | + $logger->log('Product import error: ' . $e->getMessage()); |
|
361 | + $logger->log($e->getTraceAsString()); |
|
362 | 362 | |
363 | - throw new \Aimeos\Controller\Jobs\Exception( $e->getMessage() ); |
|
363 | + throw new \Aimeos\Controller\Jobs\Exception($e->getMessage()); |
|
364 | 364 | } |
365 | 365 | |
366 | 366 | $msg = 'Finished product import from "%1$s": %2$d successful, %3$s errors, %4$s total (%5$s)'; |
367 | - $logger->log( sprintf( $msg, $path, $total - $errors, $errors, $total, __CLASS__ ), \Aimeos\MW\Logger\Base::NOTICE ); |
|
367 | + $logger->log(sprintf($msg, $path, $total - $errors, $errors, $total, __CLASS__), \Aimeos\MW\Logger\Base::NOTICE); |
|
368 | 368 | |
369 | - if( $errors > 0 ) |
|
369 | + if ($errors > 0) |
|
370 | 370 | { |
371 | - $msg = sprintf( 'Invalid product lines in "%1$s": %2$d/%3$d', $path, $errors, $total ); |
|
372 | - throw new \Aimeos\Controller\Jobs\Exception( $msg ); |
|
371 | + $msg = sprintf('Invalid product lines in "%1$s": %2$d/%3$d', $path, $errors, $total); |
|
372 | + throw new \Aimeos\Controller\Jobs\Exception($msg); |
|
373 | 373 | } |
374 | 374 | |
375 | - if( !empty( $backup ) && @rename( $path, strftime( $backup ) ) === false ) { |
|
376 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Unable to move imported file' ) ); |
|
375 | + if (!empty($backup) && @rename($path, strftime($backup)) === false) { |
|
376 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Unable to move imported file')); |
|
377 | 377 | } |
378 | 378 | } |
379 | 379 | |
@@ -385,16 +385,16 @@ discard block |
||
385 | 385 | * @return integer Position of the "product.code" column |
386 | 386 | * @throws \Aimeos\Controller\Jobs\Exception If no mapping for "product.code" is found |
387 | 387 | */ |
388 | - protected function getCodePosition( array $mapping ) |
|
388 | + protected function getCodePosition(array $mapping) |
|
389 | 389 | { |
390 | - foreach( $mapping as $pos => $key ) |
|
390 | + foreach ($mapping as $pos => $key) |
|
391 | 391 | { |
392 | - if( $key === 'product.code' ) { |
|
392 | + if ($key === 'product.code') { |
|
393 | 393 | return $pos; |
394 | 394 | } |
395 | 395 | } |
396 | 396 | |
397 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'No "product.code" column in CSV mapping found' ) ); |
|
397 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('No "product.code" column in CSV mapping found')); |
|
398 | 398 | } |
399 | 399 | |
400 | 400 | |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | * @see controller/jobs/product/import/csv/container/content |
430 | 430 | * @see controller/jobs/product/import/csv/container/options |
431 | 431 | */ |
432 | - $location = $config->get( 'controller/jobs/product/import/csv/location' ); |
|
432 | + $location = $config->get('controller/jobs/product/import/csv/location'); |
|
433 | 433 | |
434 | 434 | /** controller/jobs/product/import/csv/container/type |
435 | 435 | * Nave of the container type to read the data from |
@@ -452,7 +452,7 @@ discard block |
||
452 | 452 | * @see controller/jobs/product/import/csv/container/content |
453 | 453 | * @see controller/jobs/product/import/csv/container/options |
454 | 454 | */ |
455 | - $container = $config->get( 'controller/jobs/product/import/csv/container/type', 'Directory' ); |
|
455 | + $container = $config->get('controller/jobs/product/import/csv/container/type', 'Directory'); |
|
456 | 456 | |
457 | 457 | /** controller/jobs/product/import/csv/container/content |
458 | 458 | * Name of the content type inside the container to read the data from |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | * @see controller/jobs/product/import/csv/container/type |
474 | 474 | * @see controller/jobs/product/import/csv/container/options |
475 | 475 | */ |
476 | - $content = $config->get( 'controller/jobs/product/import/csv/container/content', 'CSV' ); |
|
476 | + $content = $config->get('controller/jobs/product/import/csv/container/content', 'CSV'); |
|
477 | 477 | |
478 | 478 | /** controller/jobs/product/import/csv/container/options |
479 | 479 | * List of file container options for the product import files |
@@ -491,15 +491,15 @@ discard block |
||
491 | 491 | * @see controller/jobs/product/import/csv/container/content |
492 | 492 | * @see controller/jobs/product/import/csv/container/type |
493 | 493 | */ |
494 | - $options = $config->get( 'controller/jobs/product/import/csv/container/options', [] ); |
|
494 | + $options = $config->get('controller/jobs/product/import/csv/container/options', []); |
|
495 | 495 | |
496 | - if( $location === null ) |
|
496 | + if ($location === null) |
|
497 | 497 | { |
498 | - $msg = sprintf( 'Required configuration for "%1$s" is missing', 'controller/jobs/product/import/csv/location' ); |
|
499 | - throw new \Aimeos\Controller\Jobs\Exception( $msg ); |
|
498 | + $msg = sprintf('Required configuration for "%1$s" is missing', 'controller/jobs/product/import/csv/location'); |
|
499 | + throw new \Aimeos\Controller\Jobs\Exception($msg); |
|
500 | 500 | } |
501 | 501 | |
502 | - return \Aimeos\MW\Container\Factory::getContainer( $location, $container, $content, $options ); |
|
502 | + return \Aimeos\MW\Container\Factory::getContainer($location, $container, $content, $options); |
|
503 | 503 | } |
504 | 504 | |
505 | 505 | |
@@ -514,65 +514,65 @@ discard block |
||
514 | 514 | * @return integer Number of products that couldn't be imported |
515 | 515 | * @throws \Aimeos\Controller\Jobs\Exception |
516 | 516 | */ |
517 | - protected function import( array $products, array $data, array $mapping, |
|
518 | - \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $processor, $strict ) |
|
517 | + protected function import(array $products, array $data, array $mapping, |
|
518 | + \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $processor, $strict) |
|
519 | 519 | { |
520 | 520 | $items = []; |
521 | 521 | $errors = 0; |
522 | 522 | $context = $this->getContext(); |
523 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'product' ); |
|
524 | - $indexManager = \Aimeos\MShop\Factory::createManager( $context, 'index' ); |
|
523 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'product'); |
|
524 | + $indexManager = \Aimeos\MShop\Factory::createManager($context, 'index'); |
|
525 | 525 | |
526 | - foreach( $data as $code => $list ) |
|
526 | + foreach ($data as $code => $list) |
|
527 | 527 | { |
528 | 528 | $manager->begin(); |
529 | 529 | |
530 | 530 | try |
531 | 531 | { |
532 | - $code = trim( $code ); |
|
532 | + $code = trim($code); |
|
533 | 533 | |
534 | - if( isset( $products[$code] ) ) { |
|
534 | + if (isset($products[$code])) { |
|
535 | 535 | $product = $products[$code]; |
536 | 536 | } else { |
537 | 537 | $product = $manager->createItem(); |
538 | 538 | } |
539 | 539 | |
540 | - $map = $this->getMappedChunk( $list, $mapping ); |
|
540 | + $map = $this->getMappedChunk($list, $mapping); |
|
541 | 541 | |
542 | - if( isset( $map[0] ) ) |
|
542 | + if (isset($map[0])) |
|
543 | 543 | { |
544 | 544 | $map = $map[0]; // there can only be one chunk for the base product data |
545 | 545 | |
546 | - $typecode = trim( isset( $map['product.type'] ) ? $map['product.type'] : 'default' ); |
|
547 | - $map['product.typeid'] = $this->getTypeId( 'product/type', 'product', $typecode ); |
|
546 | + $typecode = trim(isset($map['product.type']) ? $map['product.type'] : 'default'); |
|
547 | + $map['product.typeid'] = $this->getTypeId('product/type', 'product', $typecode); |
|
548 | 548 | |
549 | - $product->fromArray( $this->addItemDefaults( $map ) ); |
|
550 | - $product = $manager->saveItem( $product ); |
|
549 | + $product->fromArray($this->addItemDefaults($map)); |
|
550 | + $product = $manager->saveItem($product); |
|
551 | 551 | |
552 | - $list = $processor->process( $product, $list ); |
|
552 | + $list = $processor->process($product, $list); |
|
553 | 553 | |
554 | - $product = $manager->saveItem( $product ); |
|
554 | + $product = $manager->saveItem($product); |
|
555 | 555 | $items[$product->getId()] = $product; |
556 | 556 | } |
557 | 557 | |
558 | 558 | $manager->commit(); |
559 | 559 | } |
560 | - catch( \Exception $e ) |
|
560 | + catch (\Exception $e) |
|
561 | 561 | { |
562 | 562 | $manager->rollback(); |
563 | 563 | |
564 | - $msg = sprintf( 'Unable to import product with code "%1$s": %2$s', $code, $e->getMessage() ); |
|
565 | - $context->getLogger()->log( $msg ); |
|
564 | + $msg = sprintf('Unable to import product with code "%1$s": %2$s', $code, $e->getMessage()); |
|
565 | + $context->getLogger()->log($msg); |
|
566 | 566 | |
567 | 567 | $errors++; |
568 | 568 | } |
569 | 569 | |
570 | - if( $strict && !empty( $list ) ) { |
|
571 | - $context->getLogger()->log( 'Not imported: ' . print_r( $list, true ) ); |
|
570 | + if ($strict && !empty($list)) { |
|
571 | + $context->getLogger()->log('Not imported: ' . print_r($list, true)); |
|
572 | 572 | } |
573 | 573 | } |
574 | 574 | |
575 | - $indexManager->rebuildIndex( $items ); |
|
575 | + $indexManager->rebuildIndex($items); |
|
576 | 576 | |
577 | 577 | return $errors; |
578 | 578 | } |
@@ -584,9 +584,9 @@ discard block |
||
584 | 584 | * @param array $list Associative list of domain item keys and their values, e.g. "product.status" => 1 |
585 | 585 | * @return array Given associative list enriched by default values if they were not already set |
586 | 586 | */ |
587 | - protected function addItemDefaults( array $list ) |
|
587 | + protected function addItemDefaults(array $list) |
|
588 | 588 | { |
589 | - if( !isset( $list['product.status'] ) ) { |
|
589 | + if (!isset($list['product.status'])) { |
|
590 | 590 | $list['product.status'] = 1; |
591 | 591 | } |
592 | 592 |
@@ -15,14 +15,14 @@ discard block |
||
15 | 15 | public static function bootstrap() |
16 | 16 | { |
17 | 17 | self::getAimeos(); |
18 | - \Aimeos\MShop\Factory::setCache( false ); |
|
18 | + \Aimeos\MShop\Factory::setCache(false); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | |
22 | - public static function getContext( $site = 'unittest' ) |
|
22 | + public static function getContext($site = 'unittest') |
|
23 | 23 | { |
24 | - if( !isset( self::$context[$site] ) ) { |
|
25 | - self::$context[$site] = self::createContext( $site ); |
|
24 | + if (!isset(self::$context[$site])) { |
|
25 | + self::$context[$site] = self::createContext($site); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | return clone self::$context[$site]; |
@@ -31,13 +31,13 @@ discard block |
||
31 | 31 | |
32 | 32 | public static function getAimeos() |
33 | 33 | { |
34 | - if( !isset( self::$aimeos ) ) |
|
34 | + if (!isset(self::$aimeos)) |
|
35 | 35 | { |
36 | 36 | require_once 'Bootstrap.php'; |
37 | - spl_autoload_register( 'Aimeos\\Bootstrap::autoload' ); |
|
37 | + spl_autoload_register('Aimeos\\Bootstrap::autoload'); |
|
38 | 38 | |
39 | - $extdir = dirname( dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) ); |
|
40 | - self::$aimeos = new \Aimeos\Bootstrap( array( $extdir ), true ); |
|
39 | + $extdir = dirname(dirname(dirname(dirname(dirname(__FILE__))))); |
|
40 | + self::$aimeos = new \Aimeos\Bootstrap(array($extdir), true); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | return self::$aimeos; |
@@ -46,14 +46,14 @@ discard block |
||
46 | 46 | |
47 | 47 | public static function getControllerPaths() |
48 | 48 | { |
49 | - return self::getAimeos()->getCustomPaths( 'controller/jobs' ); |
|
49 | + return self::getAimeos()->getCustomPaths('controller/jobs'); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | |
53 | 53 | /** |
54 | 54 | * @param string $site |
55 | 55 | */ |
56 | - private static function createContext( $site ) |
|
56 | + private static function createContext($site) |
|
57 | 57 | { |
58 | 58 | $ctx = new \Aimeos\MShop\Context\Item\Standard(); |
59 | 59 | $aimeos = self::getAimeos(); |
@@ -63,80 +63,80 @@ discard block |
||
63 | 63 | $paths[] = __DIR__ . DIRECTORY_SEPARATOR . 'config'; |
64 | 64 | $file = __DIR__ . DIRECTORY_SEPARATOR . 'confdoc.ser'; |
65 | 65 | |
66 | - $conf = new \Aimeos\MW\Config\PHPArray( [], $paths ); |
|
67 | - $conf = new \Aimeos\MW\Config\Decorator\Memory( $conf ); |
|
68 | - $conf = new \Aimeos\MW\Config\Decorator\Documentor( $conf, $file ); |
|
69 | - $ctx->setConfig( $conf ); |
|
66 | + $conf = new \Aimeos\MW\Config\PHPArray([], $paths); |
|
67 | + $conf = new \Aimeos\MW\Config\Decorator\Memory($conf); |
|
68 | + $conf = new \Aimeos\MW\Config\Decorator\Documentor($conf, $file); |
|
69 | + $ctx->setConfig($conf); |
|
70 | 70 | |
71 | 71 | |
72 | - $logger = new \Aimeos\MW\Logger\File( $site . '.log', \Aimeos\MW\Logger\Base::DEBUG ); |
|
73 | - $ctx->setLogger( $logger ); |
|
72 | + $logger = new \Aimeos\MW\Logger\File($site . '.log', \Aimeos\MW\Logger\Base::DEBUG); |
|
73 | + $ctx->setLogger($logger); |
|
74 | 74 | |
75 | 75 | |
76 | - $dbm = new \Aimeos\MW\DB\Manager\PDO( $conf ); |
|
77 | - $ctx->setDatabaseManager( $dbm ); |
|
76 | + $dbm = new \Aimeos\MW\DB\Manager\PDO($conf); |
|
77 | + $ctx->setDatabaseManager($dbm); |
|
78 | 78 | |
79 | 79 | |
80 | - $fs = new \Aimeos\MW\Filesystem\Manager\Standard( $conf ); |
|
81 | - $ctx->setFilesystemManager( $fs ); |
|
80 | + $fs = new \Aimeos\MW\Filesystem\Manager\Standard($conf); |
|
81 | + $ctx->setFilesystemManager($fs); |
|
82 | 82 | |
83 | 83 | |
84 | - $mq = new \Aimeos\MW\MQueue\Manager\Standard( $conf ); |
|
85 | - $ctx->setMessageQueueManager( $mq ); |
|
84 | + $mq = new \Aimeos\MW\MQueue\Manager\Standard($conf); |
|
85 | + $ctx->setMessageQueueManager($mq); |
|
86 | 86 | |
87 | 87 | |
88 | 88 | $cache = new \Aimeos\MW\Cache\None(); |
89 | - $ctx->setCache( $cache ); |
|
89 | + $ctx->setCache($cache); |
|
90 | 90 | |
91 | 91 | |
92 | 92 | $session = new \Aimeos\MW\Session\None(); |
93 | - $ctx->setSession( $session ); |
|
93 | + $ctx->setSession($session); |
|
94 | 94 | |
95 | 95 | |
96 | - $i18n = new \Aimeos\MW\Translation\None( 'de' ); |
|
97 | - $ctx->setI18n( array( 'de' => $i18n ) ); |
|
96 | + $i18n = new \Aimeos\MW\Translation\None('de'); |
|
97 | + $ctx->setI18n(array('de' => $i18n)); |
|
98 | 98 | |
99 | 99 | |
100 | - $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager( $ctx ); |
|
101 | - $locale = $localeManager->bootstrap( $site, 'de', '', false ); |
|
102 | - $ctx->setLocale( $locale ); |
|
100 | + $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($ctx); |
|
101 | + $locale = $localeManager->bootstrap($site, 'de', '', false); |
|
102 | + $ctx->setLocale($locale); |
|
103 | 103 | |
104 | 104 | |
105 | - $view = self::createView( $conf ); |
|
106 | - $ctx->setView( $view ); |
|
105 | + $view = self::createView($conf); |
|
106 | + $ctx->setView($view); |
|
107 | 107 | |
108 | 108 | |
109 | - $ctx->setEditor( 'core:controller/jobs' ); |
|
109 | + $ctx->setEditor('core:controller/jobs'); |
|
110 | 110 | |
111 | 111 | return $ctx; |
112 | 112 | } |
113 | 113 | |
114 | 114 | |
115 | - protected static function createView( \Aimeos\MW\Config\Iface $config ) |
|
115 | + protected static function createView(\Aimeos\MW\Config\Iface $config) |
|
116 | 116 | { |
117 | 117 | $tmplpaths = array_merge_recursive( |
118 | - self::getAimeos()->getCustomPaths( 'client/html/templates' ), |
|
119 | - self::getAimeos()->getCustomPaths( 'controller/jobs/templates' ) |
|
118 | + self::getAimeos()->getCustomPaths('client/html/templates'), |
|
119 | + self::getAimeos()->getCustomPaths('controller/jobs/templates') |
|
120 | 120 | ); |
121 | 121 | |
122 | - $view = new \Aimeos\MW\View\Standard( $tmplpaths ); |
|
122 | + $view = new \Aimeos\MW\View\Standard($tmplpaths); |
|
123 | 123 | |
124 | - $trans = new \Aimeos\MW\Translation\None( 'de_DE' ); |
|
125 | - $helper = new \Aimeos\MW\View\Helper\Translate\Standard( $view, $trans ); |
|
126 | - $view->addHelper( 'translate', $helper ); |
|
124 | + $trans = new \Aimeos\MW\Translation\None('de_DE'); |
|
125 | + $helper = new \Aimeos\MW\View\Helper\Translate\Standard($view, $trans); |
|
126 | + $view->addHelper('translate', $helper); |
|
127 | 127 | |
128 | - $helper = new \Aimeos\MW\View\Helper\Url\Standard( $view, 'http://baseurl' ); |
|
129 | - $view->addHelper( 'url', $helper ); |
|
128 | + $helper = new \Aimeos\MW\View\Helper\Url\Standard($view, 'http://baseurl'); |
|
129 | + $view->addHelper('url', $helper); |
|
130 | 130 | |
131 | - $helper = new \Aimeos\MW\View\Helper\Number\Standard( $view, '.', '' ); |
|
132 | - $view->addHelper( 'number', $helper ); |
|
131 | + $helper = new \Aimeos\MW\View\Helper\Number\Standard($view, '.', ''); |
|
132 | + $view->addHelper('number', $helper); |
|
133 | 133 | |
134 | - $helper = new \Aimeos\MW\View\Helper\Date\Standard( $view, 'Y-m-d' ); |
|
135 | - $view->addHelper( 'date', $helper ); |
|
134 | + $helper = new \Aimeos\MW\View\Helper\Date\Standard($view, 'Y-m-d'); |
|
135 | + $view->addHelper('date', $helper); |
|
136 | 136 | |
137 | - $config = new \Aimeos\MW\Config\Decorator\Protect( $config, array( 'controller/jobs', 'client/html' ) ); |
|
138 | - $helper = new \Aimeos\MW\View\Helper\Config\Standard( $view, $config ); |
|
139 | - $view->addHelper( 'config', $helper ); |
|
137 | + $config = new \Aimeos\MW\Config\Decorator\Protect($config, array('controller/jobs', 'client/html')); |
|
138 | + $helper = new \Aimeos\MW\View\Helper\Config\Standard($view, $config); |
|
139 | + $view->addHelper('config', $helper); |
|
140 | 140 | |
141 | 141 | return $view; |
142 | 142 | } |