@@ -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\Catalog\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\Catalog\Import\Csv\Processor\Iface $object = null ) |
|
| 46 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
| 47 | + \Aimeos\Controller\Common\Catalog\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/catalog/import/csv/processor/media/listtypes |
| 52 | 52 | * Names of the catalog list types for media that are updated or removed |
@@ -68,32 +68,32 @@ discard block |
||
| 68 | 68 | * @see controller/common/catalog/import/csv/processor/text/listtypes |
| 69 | 69 | */ |
| 70 | 70 | $key = 'controller/common/catalog/import/csv/processor/media/listtypes'; |
| 71 | - $this->listTypes = $context->getConfig()->get( $key ); |
|
| 71 | + $this->listTypes = $context->getConfig()->get($key); |
|
| 72 | 72 | |
| 73 | - if( $this->listTypes === null ) |
|
| 73 | + if ($this->listTypes === null) |
|
| 74 | 74 | { |
| 75 | 75 | $this->listTypes = []; |
| 76 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'catalog/lists/type' ); |
|
| 76 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'catalog/lists/type'); |
|
| 77 | 77 | |
| 78 | - $search = $manager->createSearch()->setSlice( 0, 0x7fffffff ); |
|
| 79 | - $search->setConditions( $search->compare( '==', 'catalog.lists.type.domain', 'media' ) ); |
|
| 78 | + $search = $manager->createSearch()->setSlice(0, 0x7fffffff); |
|
| 79 | + $search->setConditions($search->compare('==', 'catalog.lists.type.domain', 'media')); |
|
| 80 | 80 | |
| 81 | - foreach( $manager->searchItems( $search ) as $item ) { |
|
| 81 | + foreach ($manager->searchItems($search) as $item) { |
|
| 82 | 82 | $this->listTypes[$item->getCode()] = $item->getCode(); |
| 83 | 83 | } |
| 84 | 84 | } |
| 85 | 85 | else |
| 86 | 86 | { |
| 87 | - $this->listTypes = array_flip( $this->listTypes ); |
|
| 87 | + $this->listTypes = array_flip($this->listTypes); |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | |
| 91 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'media/type' ); |
|
| 91 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'media/type'); |
|
| 92 | 92 | |
| 93 | - $search = $manager->createSearch()->setSlice( 0, 0x7fffffff ); |
|
| 94 | - $search->setConditions( $search->compare( '==', 'media.type.domain', 'catalog' ) ); |
|
| 93 | + $search = $manager->createSearch()->setSlice(0, 0x7fffffff); |
|
| 94 | + $search->setConditions($search->compare('==', 'media.type.domain', 'catalog')); |
|
| 95 | 95 | |
| 96 | - foreach( $manager->searchItems( $search ) as $item ) { |
|
| 96 | + foreach ($manager->searchItems($search) as $item) { |
|
| 97 | 97 | $this->types[$item->getCode()] = $item->getCode(); |
| 98 | 98 | } |
| 99 | 99 | } |
@@ -106,60 +106,60 @@ discard block |
||
| 106 | 106 | * @param array $data List of CSV fields with position as key and data as value |
| 107 | 107 | * @return array List of data which hasn't been imported |
| 108 | 108 | */ |
| 109 | - public function process( \Aimeos\MShop\Catalog\Item\Iface $catalog, array $data ) |
|
| 109 | + public function process(\Aimeos\MShop\Catalog\Item\Iface $catalog, array $data) |
|
| 110 | 110 | { |
| 111 | 111 | $context = $this->getContext(); |
| 112 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'media' ); |
|
| 113 | - $listManager = \Aimeos\MShop\Factory::createManager( $context, 'catalog/lists' ); |
|
| 114 | - $separator = $context->getConfig()->get( 'controller/common/catalog/import/csv/separator', "\n" ); |
|
| 112 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'media'); |
|
| 113 | + $listManager = \Aimeos\MShop\Factory::createManager($context, 'catalog/lists'); |
|
| 114 | + $separator = $context->getConfig()->get('controller/common/catalog/import/csv/separator', "\n"); |
|
| 115 | 115 | |
| 116 | 116 | $listMap = []; |
| 117 | - $map = $this->getMappedChunk( $data, $this->getMapping() ); |
|
| 118 | - $listItems = $catalog->getListItems( 'media', $this->listTypes ); |
|
| 117 | + $map = $this->getMappedChunk($data, $this->getMapping()); |
|
| 118 | + $listItems = $catalog->getListItems('media', $this->listTypes); |
|
| 119 | 119 | |
| 120 | - foreach( $listItems as $listItem ) |
|
| 120 | + foreach ($listItems as $listItem) |
|
| 121 | 121 | { |
| 122 | - if( ( $refItem = $listItem->getRefItem() ) !== null ) { |
|
| 123 | - $listMap[ $refItem->getUrl() ][ $refItem->getType() ][ $listItem->getType() ] = $listItem; |
|
| 122 | + if (($refItem = $listItem->getRefItem()) !== null) { |
|
| 123 | + $listMap[$refItem->getUrl()][$refItem->getType()][$listItem->getType()] = $listItem; |
|
| 124 | 124 | } |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - foreach( $map as $pos => $list ) |
|
| 127 | + foreach ($map as $pos => $list) |
|
| 128 | 128 | { |
| 129 | - if( $this->checkEntry( $list ) === false ) { |
|
| 129 | + if ($this->checkEntry($list) === false) { |
|
| 130 | 130 | continue; |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - $type = $this->getValue( $list, 'media.type', 'default' ); |
|
| 134 | - $listtype = $this->getValue( $list, 'catalog.lists.type', 'default' ); |
|
| 135 | - $urls = explode( $separator, $this->getValue( $list, 'media.url', '' ) ); |
|
| 133 | + $type = $this->getValue($list, 'media.type', 'default'); |
|
| 134 | + $listtype = $this->getValue($list, 'catalog.lists.type', 'default'); |
|
| 135 | + $urls = explode($separator, $this->getValue($list, 'media.url', '')); |
|
| 136 | 136 | |
| 137 | - foreach( $urls as $url ) |
|
| 137 | + foreach ($urls as $url) |
|
| 138 | 138 | { |
| 139 | - if( isset( $listMap[$url][$type][$listtype] ) ) |
|
| 139 | + if (isset($listMap[$url][$type][$listtype])) |
|
| 140 | 140 | { |
| 141 | 141 | $listItem = $listMap[$url][$type][$listtype]; |
| 142 | 142 | $refItem = $listItem->getRefItem(); |
| 143 | - unset( $listItems[ $listItem->getId() ] ); |
|
| 143 | + unset($listItems[$listItem->getId()]); |
|
| 144 | 144 | } |
| 145 | 145 | else |
| 146 | 146 | { |
| 147 | - $listItem = $listManager->createItem( $listtype, 'media' ); |
|
| 148 | - $refItem = $manager->createItem( $type, 'catalog' ); |
|
| 147 | + $listItem = $listManager->createItem($listtype, 'media'); |
|
| 148 | + $refItem = $manager->createItem($type, 'catalog'); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | $list['media.url'] = $url; |
| 152 | 152 | |
| 153 | - $list = $refItem->fromArray( $this->addItemDefaults( $list ) ); |
|
| 154 | - $list = $listItem->fromArray( $this->addListItemDefaults( $list, $pos++ ) ); |
|
| 153 | + $list = $refItem->fromArray($this->addItemDefaults($list)); |
|
| 154 | + $list = $listItem->fromArray($this->addListItemDefaults($list, $pos++)); |
|
| 155 | 155 | |
| 156 | - $catalog->addListItem( 'media', $listItem, $refItem ); |
|
| 156 | + $catalog->addListItem('media', $listItem, $refItem); |
|
| 157 | 157 | } |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | - $catalog->deleteListItems( $listItems, true ); |
|
| 160 | + $catalog->deleteListItems($listItems, true); |
|
| 161 | 161 | |
| 162 | - return $this->getObject()->process( $catalog, $data ); |
|
| 162 | + return $this->getObject()->process($catalog, $data); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | |
@@ -169,17 +169,17 @@ discard block |
||
| 169 | 169 | * @param array $list Associative list of domain item keys and their values, e.g. "media.status" => 1 |
| 170 | 170 | * @return array Given associative list enriched by default values if they were not already set |
| 171 | 171 | */ |
| 172 | - protected function addItemDefaults( array $list ) |
|
| 172 | + protected function addItemDefaults(array $list) |
|
| 173 | 173 | { |
| 174 | - if( !isset( $list['media.label'] ) ) { |
|
| 174 | + if (!isset($list['media.label'])) { |
|
| 175 | 175 | $list['media.label'] = $list['media.url']; |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | - if( !isset( $list['media.preview'] ) ) { |
|
| 178 | + if (!isset($list['media.preview'])) { |
|
| 179 | 179 | $list['media.preview'] = $list['media.url']; |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | - if( !isset( $list['media.status'] ) ) { |
|
| 182 | + if (!isset($list['media.status'])) { |
|
| 183 | 183 | $list['media.status'] = 1; |
| 184 | 184 | } |
| 185 | 185 | |
@@ -193,22 +193,22 @@ discard block |
||
| 193 | 193 | * @param array $list Associative list of key/value pairs from the mapping |
| 194 | 194 | * @return boolean True if valid, false if not |
| 195 | 195 | */ |
| 196 | - protected function checkEntry( array $list ) |
|
| 196 | + protected function checkEntry(array $list) |
|
| 197 | 197 | { |
| 198 | - if( $this->getValue( $list, 'media.url' ) === null ) { |
|
| 198 | + if ($this->getValue($list, 'media.url') === null) { |
|
| 199 | 199 | return false; |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | - if( ( $type = $this->getValue( $list, 'catalog.lists.type' ) ) && !isset( $this->listTypes[$type] ) ) |
|
| 202 | + if (($type = $this->getValue($list, 'catalog.lists.type')) && !isset($this->listTypes[$type])) |
|
| 203 | 203 | { |
| 204 | - $msg = sprintf( 'Invalid type "%1$s" (%2$s)', $type, 'catalog list' ); |
|
| 205 | - throw new \Aimeos\Controller\Common\Exception( $msg ); |
|
| 204 | + $msg = sprintf('Invalid type "%1$s" (%2$s)', $type, 'catalog list'); |
|
| 205 | + throw new \Aimeos\Controller\Common\Exception($msg); |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | - if( ( $type = $this->getValue( $list, 'media.type' ) ) && !isset( $this->types[$type] ) ) |
|
| 208 | + if (($type = $this->getValue($list, 'media.type')) && !isset($this->types[$type])) |
|
| 209 | 209 | { |
| 210 | - $msg = sprintf( 'Invalid type "%1$s" (%2$s)', $type, 'media' ); |
|
| 211 | - throw new \Aimeos\Controller\Common\Exception( $msg ); |
|
| 210 | + $msg = sprintf('Invalid type "%1$s" (%2$s)', $type, 'media'); |
|
| 211 | + throw new \Aimeos\Controller\Common\Exception($msg); |
|
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | return true; |
@@ -81,8 +81,7 @@ discard block |
||
| 81 | 81 | foreach( $manager->searchItems( $search ) as $item ) { |
| 82 | 82 | $this->listTypes[$item->getCode()] = $item->getCode(); |
| 83 | 83 | } |
| 84 | - } |
|
| 85 | - else |
|
| 84 | + } else |
|
| 86 | 85 | { |
| 87 | 86 | $this->listTypes = array_flip( $this->listTypes ); |
| 88 | 87 | } |
@@ -141,8 +140,7 @@ discard block |
||
| 141 | 140 | $listItem = $listMap[$url][$type][$listtype]; |
| 142 | 141 | $refItem = $listItem->getRefItem(); |
| 143 | 142 | unset( $listItems[ $listItem->getId() ] ); |
| 144 | - } |
|
| 145 | - else |
|
| 143 | + } else |
|
| 146 | 144 | { |
| 147 | 145 | $listItem = $listManager->createItem( $listtype, 'media' ); |
| 148 | 146 | $refItem = $manager->createItem( $type, 'catalog' ); |
@@ -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\Catalog\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\Catalog\Import\Csv\Processor\Iface $object = null ) |
|
| 46 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
| 47 | + \Aimeos\Controller\Common\Catalog\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/catalog/import/csv/processor/text/listtypes |
| 52 | 52 | * Names of the catalog list types for texts that are updated or removed |
@@ -68,32 +68,32 @@ discard block |
||
| 68 | 68 | * @see controller/common/catalog/import/csv/processor/catalog/listtypes |
| 69 | 69 | */ |
| 70 | 70 | $key = 'controller/common/catalog/import/csv/processor/text/listtypes'; |
| 71 | - $this->listTypes = $context->getConfig()->get( $key ); |
|
| 71 | + $this->listTypes = $context->getConfig()->get($key); |
|
| 72 | 72 | |
| 73 | - if( $this->listTypes === null ) |
|
| 73 | + if ($this->listTypes === null) |
|
| 74 | 74 | { |
| 75 | 75 | $this->listTypes = []; |
| 76 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'catalog/lists/type' ); |
|
| 76 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'catalog/lists/type'); |
|
| 77 | 77 | |
| 78 | - $search = $manager->createSearch()->setSlice( 0, 0x7fffffff ); |
|
| 79 | - $search->setConditions( $search->compare( '==', 'catalog.lists.type.domain', 'text' ) ); |
|
| 78 | + $search = $manager->createSearch()->setSlice(0, 0x7fffffff); |
|
| 79 | + $search->setConditions($search->compare('==', 'catalog.lists.type.domain', 'text')); |
|
| 80 | 80 | |
| 81 | - foreach( $manager->searchItems( $search ) as $item ) { |
|
| 81 | + foreach ($manager->searchItems($search) as $item) { |
|
| 82 | 82 | $this->listTypes[$item->getCode()] = $item->getCode(); |
| 83 | 83 | } |
| 84 | 84 | } |
| 85 | 85 | else |
| 86 | 86 | { |
| 87 | - $this->listTypes = array_flip( $this->listTypes ); |
|
| 87 | + $this->listTypes = array_flip($this->listTypes); |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | |
| 91 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'text/type' ); |
|
| 91 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'text/type'); |
|
| 92 | 92 | |
| 93 | - $search = $manager->createSearch()->setSlice( 0, 0x7fffffff ); |
|
| 94 | - $search->setConditions( $search->compare( '==', 'text.type.domain', 'catalog' ) ); |
|
| 93 | + $search = $manager->createSearch()->setSlice(0, 0x7fffffff); |
|
| 94 | + $search->setConditions($search->compare('==', 'text.type.domain', 'catalog')); |
|
| 95 | 95 | |
| 96 | - foreach( $manager->searchItems( $search ) as $item ) { |
|
| 96 | + foreach ($manager->searchItems($search) as $item) { |
|
| 97 | 97 | $this->types[$item->getCode()] = $item->getCode(); |
| 98 | 98 | } |
| 99 | 99 | } |
@@ -106,53 +106,53 @@ discard block |
||
| 106 | 106 | * @param array $data List of CSV fields with position as key and data as value |
| 107 | 107 | * @return array List of data which hasn't been imported |
| 108 | 108 | */ |
| 109 | - public function process( \Aimeos\MShop\Catalog\Item\Iface $catalog, array $data ) |
|
| 109 | + public function process(\Aimeos\MShop\Catalog\Item\Iface $catalog, array $data) |
|
| 110 | 110 | { |
| 111 | - $listManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'catalog/lists' ); |
|
| 112 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'text' ); |
|
| 111 | + $listManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'catalog/lists'); |
|
| 112 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'text'); |
|
| 113 | 113 | |
| 114 | 114 | $listMap = []; |
| 115 | - $map = $this->getMappedChunk( $data, $this->getMapping() ); |
|
| 116 | - $listItems = $catalog->getListItems( 'text', $this->listTypes ); |
|
| 115 | + $map = $this->getMappedChunk($data, $this->getMapping()); |
|
| 116 | + $listItems = $catalog->getListItems('text', $this->listTypes); |
|
| 117 | 117 | |
| 118 | - foreach( $listItems as $listItem ) |
|
| 118 | + foreach ($listItems as $listItem) |
|
| 119 | 119 | { |
| 120 | - if( ( $refItem = $listItem->getRefItem() ) !== null ) { |
|
| 121 | - $listMap[ $refItem->getContent() ][ $refItem->getType() ][ $listItem->getType() ] = $listItem; |
|
| 120 | + if (($refItem = $listItem->getRefItem()) !== null) { |
|
| 121 | + $listMap[$refItem->getContent()][$refItem->getType()][$listItem->getType()] = $listItem; |
|
| 122 | 122 | } |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - foreach( $map as $pos => $list ) |
|
| 125 | + foreach ($map as $pos => $list) |
|
| 126 | 126 | { |
| 127 | - if( $this->checkEntry( $list ) === false ) { |
|
| 127 | + if ($this->checkEntry($list) === false) { |
|
| 128 | 128 | continue; |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - $type = $this->getValue( $list, 'text.type', 'name' ); |
|
| 132 | - $listtype = $this->getValue( $list, 'catalog.lists.type', 'default' ); |
|
| 133 | - $content = $this->getValue( $list, 'text.content', '' ); |
|
| 131 | + $type = $this->getValue($list, 'text.type', 'name'); |
|
| 132 | + $listtype = $this->getValue($list, 'catalog.lists.type', 'default'); |
|
| 133 | + $content = $this->getValue($list, 'text.content', ''); |
|
| 134 | 134 | |
| 135 | - if( isset( $listMap[$content][$type][$listtype] ) ) |
|
| 135 | + if (isset($listMap[$content][$type][$listtype])) |
|
| 136 | 136 | { |
| 137 | 137 | $listItem = $listMap[$content][$type][$listtype]; |
| 138 | 138 | $refItem = $listItem->getRefItem(); |
| 139 | - unset( $listItems[ $listItem->getId() ] ); |
|
| 139 | + unset($listItems[$listItem->getId()]); |
|
| 140 | 140 | } |
| 141 | 141 | else |
| 142 | 142 | { |
| 143 | - $listItem = $listManager->createItem( $listtype, 'text' ); |
|
| 144 | - $refItem = $manager->createItem( $type, 'catalog' ); |
|
| 143 | + $listItem = $listManager->createItem($listtype, 'text'); |
|
| 144 | + $refItem = $manager->createItem($type, 'catalog'); |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - $refItem->fromArray( $this->addItemDefaults( $list ) ); |
|
| 148 | - $listItem->fromArray( $this->addListItemDefaults( $list, $pos ) ); |
|
| 147 | + $refItem->fromArray($this->addItemDefaults($list)); |
|
| 148 | + $listItem->fromArray($this->addListItemDefaults($list, $pos)); |
|
| 149 | 149 | |
| 150 | - $catalog->addListItem( 'text', $listItem, $refItem ); |
|
| 150 | + $catalog->addListItem('text', $listItem, $refItem); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - $catalog->deleteListItems( $listItems, true ); |
|
| 153 | + $catalog->deleteListItems($listItems, true); |
|
| 154 | 154 | |
| 155 | - return $this->getObject()->process( $catalog, $data ); |
|
| 155 | + return $this->getObject()->process($catalog, $data); |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | |
@@ -162,13 +162,13 @@ discard block |
||
| 162 | 162 | * @param array $list Associative list of domain item keys and their values, e.g. "text.status" => 1 |
| 163 | 163 | * @return array Given associative list enriched by default values if they were not already set |
| 164 | 164 | */ |
| 165 | - protected function addItemDefaults( array $list ) |
|
| 165 | + protected function addItemDefaults(array $list) |
|
| 166 | 166 | { |
| 167 | - if( !isset( $list['text.label'] ) ) { |
|
| 168 | - $list['text.label'] = mb_strcut( trim( $list['text.content'] ), 0, 255 ); |
|
| 167 | + if (!isset($list['text.label'])) { |
|
| 168 | + $list['text.label'] = mb_strcut(trim($list['text.content']), 0, 255); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - if( !isset( $list['text.status'] ) ) { |
|
| 171 | + if (!isset($list['text.status'])) { |
|
| 172 | 172 | $list['text.status'] = 1; |
| 173 | 173 | } |
| 174 | 174 | |
@@ -182,22 +182,22 @@ discard block |
||
| 182 | 182 | * @param array $list Associative list of key/value pairs from the mapping |
| 183 | 183 | * @return boolean True if valid, false if not |
| 184 | 184 | */ |
| 185 | - protected function checkEntry( array $list ) |
|
| 185 | + protected function checkEntry(array $list) |
|
| 186 | 186 | { |
| 187 | - if( $this->getValue( $list, 'text.content' ) === null ) { |
|
| 187 | + if ($this->getValue($list, 'text.content') === null) { |
|
| 188 | 188 | return false; |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | - if( ( $type = $this->getValue( $list, 'catalog.lists.type' ) ) && !isset( $this->listTypes[$type] ) ) |
|
| 191 | + if (($type = $this->getValue($list, 'catalog.lists.type')) && !isset($this->listTypes[$type])) |
|
| 192 | 192 | { |
| 193 | - $msg = sprintf( 'Invalid type "%1$s" (%2$s)', $type, 'catalog list' ); |
|
| 194 | - throw new \Aimeos\Controller\Common\Exception( $msg ); |
|
| 193 | + $msg = sprintf('Invalid type "%1$s" (%2$s)', $type, 'catalog list'); |
|
| 194 | + throw new \Aimeos\Controller\Common\Exception($msg); |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | - if( ( $type = $this->getValue( $list, 'text.type' ) ) && !isset( $this->types[$type] ) ) |
|
| 197 | + if (($type = $this->getValue($list, 'text.type')) && !isset($this->types[$type])) |
|
| 198 | 198 | { |
| 199 | - $msg = sprintf( 'Invalid type "%1$s" (%2$s)', $type, 'text' ); |
|
| 200 | - throw new \Aimeos\Controller\Common\Exception( $msg ); |
|
| 199 | + $msg = sprintf('Invalid type "%1$s" (%2$s)', $type, 'text'); |
|
| 200 | + throw new \Aimeos\Controller\Common\Exception($msg); |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | return true; |
@@ -81,8 +81,7 @@ discard block |
||
| 81 | 81 | foreach( $manager->searchItems( $search ) as $item ) { |
| 82 | 82 | $this->listTypes[$item->getCode()] = $item->getCode(); |
| 83 | 83 | } |
| 84 | - } |
|
| 85 | - else |
|
| 84 | + } else |
|
| 86 | 85 | { |
| 87 | 86 | $this->listTypes = array_flip( $this->listTypes ); |
| 88 | 87 | } |
@@ -137,8 +136,7 @@ discard block |
||
| 137 | 136 | $listItem = $listMap[$content][$type][$listtype]; |
| 138 | 137 | $refItem = $listItem->getRefItem(); |
| 139 | 138 | unset( $listItems[ $listItem->getId() ] ); |
| 140 | - } |
|
| 141 | - else |
|
| 139 | + } else |
|
| 142 | 140 | { |
| 143 | 141 | $listItem = $listManager->createItem( $listtype, 'text' ); |
| 144 | 142 | $refItem = $manager->createItem( $type, 'catalog' ); |
@@ -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/media/listtypes |
| 52 | 52 | * Names of the product list types for media that are updated or removed |
@@ -68,32 +68,32 @@ discard block |
||
| 68 | 68 | * @see controller/common/product/import/csv/processor/text/listtypes |
| 69 | 69 | */ |
| 70 | 70 | $key = 'controller/common/product/import/csv/processor/media/listtypes'; |
| 71 | - $this->listTypes = $context->getConfig()->get( $key ); |
|
| 71 | + $this->listTypes = $context->getConfig()->get($key); |
|
| 72 | 72 | |
| 73 | - if( $this->listTypes === null ) |
|
| 73 | + if ($this->listTypes === null) |
|
| 74 | 74 | { |
| 75 | 75 | $this->listTypes = []; |
| 76 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'product/lists/type' ); |
|
| 76 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'product/lists/type'); |
|
| 77 | 77 | |
| 78 | - $search = $manager->createSearch()->setSlice( 0, 0x7fffffff ); |
|
| 79 | - $search->setConditions( $search->compare( '==', 'product.lists.type.domain', 'media' ) ); |
|
| 78 | + $search = $manager->createSearch()->setSlice(0, 0x7fffffff); |
|
| 79 | + $search->setConditions($search->compare('==', 'product.lists.type.domain', 'media')); |
|
| 80 | 80 | |
| 81 | - foreach( $manager->searchItems( $search ) as $item ) { |
|
| 81 | + foreach ($manager->searchItems($search) as $item) { |
|
| 82 | 82 | $this->listTypes[$item->getCode()] = $item->getCode(); |
| 83 | 83 | } |
| 84 | 84 | } |
| 85 | 85 | else |
| 86 | 86 | { |
| 87 | - $this->listTypes = array_flip( $this->listTypes ); |
|
| 87 | + $this->listTypes = array_flip($this->listTypes); |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | |
| 91 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'media/type' ); |
|
| 91 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'media/type'); |
|
| 92 | 92 | |
| 93 | - $search = $manager->createSearch()->setSlice( 0, 0x7fffffff ); |
|
| 94 | - $search->setConditions( $search->compare( '==', 'media.type.domain', 'product' ) ); |
|
| 93 | + $search = $manager->createSearch()->setSlice(0, 0x7fffffff); |
|
| 94 | + $search->setConditions($search->compare('==', 'media.type.domain', 'product')); |
|
| 95 | 95 | |
| 96 | - foreach( $manager->searchItems( $search ) as $item ) { |
|
| 96 | + foreach ($manager->searchItems($search) as $item) { |
|
| 97 | 97 | $this->types[$item->getCode()] = $item->getCode(); |
| 98 | 98 | } |
| 99 | 99 | } |
@@ -106,62 +106,62 @@ discard block |
||
| 106 | 106 | * @param array $data List of CSV fields with position as key and data as value |
| 107 | 107 | * @return array List of data which hasn't been imported |
| 108 | 108 | */ |
| 109 | - public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data ) |
|
| 109 | + public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data) |
|
| 110 | 110 | { |
| 111 | 111 | $context = $this->getContext(); |
| 112 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'media' ); |
|
| 113 | - $listManager = \Aimeos\MShop\Factory::createManager( $context, 'product/lists' ); |
|
| 114 | - $separator = $context->getConfig()->get( 'controller/common/product/import/csv/separator', "\n" ); |
|
| 112 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'media'); |
|
| 113 | + $listManager = \Aimeos\MShop\Factory::createManager($context, 'product/lists'); |
|
| 114 | + $separator = $context->getConfig()->get('controller/common/product/import/csv/separator', "\n"); |
|
| 115 | 115 | |
| 116 | 116 | $listMap = []; |
| 117 | - $map = $this->getMappedChunk( $data, $this->getMapping() ); |
|
| 118 | - $listItems = $product->getListItems( 'media', $this->listTypes ); |
|
| 117 | + $map = $this->getMappedChunk($data, $this->getMapping()); |
|
| 118 | + $listItems = $product->getListItems('media', $this->listTypes); |
|
| 119 | 119 | |
| 120 | - foreach( $listItems as $listItem ) |
|
| 120 | + foreach ($listItems as $listItem) |
|
| 121 | 121 | { |
| 122 | - if( ( $refItem = $listItem->getRefItem() ) !== null ) { |
|
| 123 | - $listMap[ $refItem->getUrl() ][ $refItem->getType() ][ $listItem->getType() ] = $listItem; |
|
| 122 | + if (($refItem = $listItem->getRefItem()) !== null) { |
|
| 123 | + $listMap[$refItem->getUrl()][$refItem->getType()][$listItem->getType()] = $listItem; |
|
| 124 | 124 | } |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - foreach( $map as $pos => $list ) |
|
| 127 | + foreach ($map as $pos => $list) |
|
| 128 | 128 | { |
| 129 | - if( $this->checkEntry( $list ) === false ) { |
|
| 129 | + if ($this->checkEntry($list) === false) { |
|
| 130 | 130 | continue; |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - $type = $this->getValue( $list, 'media.type', 'default' ); |
|
| 134 | - $typecode = $this->getValue( $list, 'product.lists.type', 'default' ); |
|
| 135 | - $urls = explode( $separator, $this->getValue( $list, 'media.url', '' ) ); |
|
| 133 | + $type = $this->getValue($list, 'media.type', 'default'); |
|
| 134 | + $typecode = $this->getValue($list, 'product.lists.type', 'default'); |
|
| 135 | + $urls = explode($separator, $this->getValue($list, 'media.url', '')); |
|
| 136 | 136 | |
| 137 | - foreach( $urls as $url ) |
|
| 137 | + foreach ($urls as $url) |
|
| 138 | 138 | { |
| 139 | - $url = trim( $url ); |
|
| 139 | + $url = trim($url); |
|
| 140 | 140 | |
| 141 | - if( isset( $listMap[$url][$type][$typecode] ) ) |
|
| 141 | + if (isset($listMap[$url][$type][$typecode])) |
|
| 142 | 142 | { |
| 143 | 143 | $listItem = $listMap[$url][$type][$typecode]; |
| 144 | 144 | $refItem = $listItem->getRefItem(); |
| 145 | - unset( $listItems[ $listItem->getId() ] ); |
|
| 145 | + unset($listItems[$listItem->getId()]); |
|
| 146 | 146 | } |
| 147 | 147 | else |
| 148 | 148 | { |
| 149 | - $listItem = $listManager->createItem( $typecode, 'media' ); |
|
| 150 | - $refItem = $manager->createItem( $type, 'product' ); |
|
| 149 | + $listItem = $listManager->createItem($typecode, 'media'); |
|
| 150 | + $refItem = $manager->createItem($type, 'product'); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | $list['media.url'] = $url; |
| 154 | 154 | |
| 155 | - $refItem->fromArray( $this->addItemDefaults( $list ) ); |
|
| 156 | - $listItem->fromArray( $this->addListItemDefaults( $list, $pos++ ) ); |
|
| 155 | + $refItem->fromArray($this->addItemDefaults($list)); |
|
| 156 | + $listItem->fromArray($this->addListItemDefaults($list, $pos++)); |
|
| 157 | 157 | |
| 158 | - $product->addListItem( 'media', $listItem, $refItem ); |
|
| 158 | + $product->addListItem('media', $listItem, $refItem); |
|
| 159 | 159 | } |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - $product->deleteListItems( $listItems, true ); |
|
| 162 | + $product->deleteListItems($listItems, true); |
|
| 163 | 163 | |
| 164 | - return $this->getObject()->process( $product, $data ); |
|
| 164 | + return $this->getObject()->process($product, $data); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | |
@@ -171,17 +171,17 @@ discard block |
||
| 171 | 171 | * @param array $list Associative list of domain item keys and their values, e.g. "media.status" => 1 |
| 172 | 172 | * @return array Given associative list enriched by default values if they were not already set |
| 173 | 173 | */ |
| 174 | - protected function addItemDefaults( array $list ) |
|
| 174 | + protected function addItemDefaults(array $list) |
|
| 175 | 175 | { |
| 176 | - if( !isset( $list['media.label'] ) ) { |
|
| 176 | + if (!isset($list['media.label'])) { |
|
| 177 | 177 | $list['media.label'] = $list['media.url']; |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - if( !isset( $list['media.preview'] ) ) { |
|
| 180 | + if (!isset($list['media.preview'])) { |
|
| 181 | 181 | $list['media.preview'] = $list['media.url']; |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - if( !isset( $list['media.status'] ) ) { |
|
| 184 | + if (!isset($list['media.status'])) { |
|
| 185 | 185 | $list['media.status'] = 1; |
| 186 | 186 | } |
| 187 | 187 | |
@@ -195,22 +195,22 @@ discard block |
||
| 195 | 195 | * @param array $list Associative list of key/value pairs from the mapping |
| 196 | 196 | * @return boolean True if valid, false if not |
| 197 | 197 | */ |
| 198 | - protected function checkEntry( array $list ) |
|
| 198 | + protected function checkEntry(array $list) |
|
| 199 | 199 | { |
| 200 | - if( $this->getValue( $list, 'media.url' ) === null ) { |
|
| 200 | + if ($this->getValue($list, 'media.url') === null) { |
|
| 201 | 201 | return false; |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | - if( ( $type = $this->getValue( $list, 'product.lists.type' ) ) && !isset( $this->listTypes[$type] ) ) |
|
| 204 | + if (($type = $this->getValue($list, 'product.lists.type')) && !isset($this->listTypes[$type])) |
|
| 205 | 205 | { |
| 206 | - $msg = sprintf( 'Invalid type "%1$s" (%2$s)', $type, 'product list' ); |
|
| 207 | - throw new \Aimeos\Controller\Common\Exception( $msg ); |
|
| 206 | + $msg = sprintf('Invalid type "%1$s" (%2$s)', $type, 'product list'); |
|
| 207 | + throw new \Aimeos\Controller\Common\Exception($msg); |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | - if( ( $type = $this->getValue( $list, 'media.type' ) ) && !isset( $this->types[$type] ) ) |
|
| 210 | + if (($type = $this->getValue($list, 'media.type')) && !isset($this->types[$type])) |
|
| 211 | 211 | { |
| 212 | - $msg = sprintf( 'Invalid type "%1$s" (%2$s)', $type, 'media' ); |
|
| 213 | - throw new \Aimeos\Controller\Common\Exception( $msg ); |
|
| 212 | + $msg = sprintf('Invalid type "%1$s" (%2$s)', $type, 'media'); |
|
| 213 | + throw new \Aimeos\Controller\Common\Exception($msg); |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | return true; |
@@ -81,8 +81,7 @@ discard block |
||
| 81 | 81 | foreach( $manager->searchItems( $search ) as $item ) { |
| 82 | 82 | $this->listTypes[$item->getCode()] = $item->getCode(); |
| 83 | 83 | } |
| 84 | - } |
|
| 85 | - else |
|
| 84 | + } else |
|
| 86 | 85 | { |
| 87 | 86 | $this->listTypes = array_flip( $this->listTypes ); |
| 88 | 87 | } |
@@ -143,8 +142,7 @@ discard block |
||
| 143 | 142 | $listItem = $listMap[$url][$type][$typecode]; |
| 144 | 143 | $refItem = $listItem->getRefItem(); |
| 145 | 144 | unset( $listItems[ $listItem->getId() ] ); |
| 146 | - } |
|
| 147 | - else |
|
| 145 | + } else |
|
| 148 | 146 | { |
| 149 | 147 | $listItem = $listManager->createItem( $typecode, 'media' ); |
| 150 | 148 | $refItem = $manager->createItem( $type, 'product' ); |
@@ -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/catalog/listtypes |
| 52 | 52 | * Names of the catalog list types that are updated or removed |
@@ -68,26 +68,26 @@ discard block |
||
| 68 | 68 | * @see controller/common/product/import/csv/processor/text/listtypes |
| 69 | 69 | */ |
| 70 | 70 | $key = 'controller/common/product/import/csv/processor/catalog/listtypes'; |
| 71 | - $this->listTypes = $context->getConfig()->get( $key ); |
|
| 71 | + $this->listTypes = $context->getConfig()->get($key); |
|
| 72 | 72 | |
| 73 | - if( $this->listTypes === null ) |
|
| 73 | + if ($this->listTypes === null) |
|
| 74 | 74 | { |
| 75 | 75 | $this->listTypes = []; |
| 76 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'catalog/lists/type' ); |
|
| 76 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'catalog/lists/type'); |
|
| 77 | 77 | |
| 78 | - $search = $manager->createSearch()->setSlice( 0, 0x7fffffff ); |
|
| 79 | - $search->setConditions( $search->compare( '==', 'catalog.lists.type.domain', 'product' ) ); |
|
| 78 | + $search = $manager->createSearch()->setSlice(0, 0x7fffffff); |
|
| 79 | + $search->setConditions($search->compare('==', 'catalog.lists.type.domain', 'product')); |
|
| 80 | 80 | |
| 81 | - foreach( $manager->searchItems( $search ) as $item ) { |
|
| 81 | + foreach ($manager->searchItems($search) as $item) { |
|
| 82 | 82 | $this->listTypes[$item->getCode()] = $item->getCode(); |
| 83 | 83 | } |
| 84 | 84 | } |
| 85 | 85 | else |
| 86 | 86 | { |
| 87 | - $this->listTypes = array_flip( $this->listTypes ); |
|
| 87 | + $this->listTypes = array_flip($this->listTypes); |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - $this->cache = $this->getCache( 'catalog' ); |
|
| 90 | + $this->cache = $this->getCache('catalog'); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | |
@@ -98,11 +98,11 @@ discard block |
||
| 98 | 98 | * @param array $data List of CSV fields with position as key and data as value |
| 99 | 99 | * @return array List of data which hasn't been imported |
| 100 | 100 | */ |
| 101 | - public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data ) |
|
| 101 | + public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data) |
|
| 102 | 102 | { |
| 103 | 103 | $context = $this->getContext(); |
| 104 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'catalog' ); |
|
| 105 | - $listManager = \Aimeos\MShop\Factory::createManager( $context, 'catalog/lists' ); |
|
| 104 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'catalog'); |
|
| 105 | + $listManager = \Aimeos\MShop\Factory::createManager($context, 'catalog/lists'); |
|
| 106 | 106 | |
| 107 | 107 | /** controller/common/product/import/csv/separator |
| 108 | 108 | * Single separator character for multiple entries in one field of the import file |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | * @category Developer |
| 123 | 123 | * @see controller/common/product/import/csv/domains |
| 124 | 124 | */ |
| 125 | - $separator = $context->getConfig()->get( 'controller/common/product/import/csv/separator', "\n" ); |
|
| 125 | + $separator = $context->getConfig()->get('controller/common/product/import/csv/separator', "\n"); |
|
| 126 | 126 | |
| 127 | 127 | $manager->begin(); |
| 128 | 128 | |
@@ -130,57 +130,57 @@ discard block |
||
| 130 | 130 | { |
| 131 | 131 | $listMap = []; |
| 132 | 132 | $prodid = $product->getId(); |
| 133 | - $map = $this->getMappedChunk( $data, $this->getMapping() ); |
|
| 134 | - $listItems = $this->getListItems( $prodid, $this->listTypes ); |
|
| 133 | + $map = $this->getMappedChunk($data, $this->getMapping()); |
|
| 134 | + $listItems = $this->getListItems($prodid, $this->listTypes); |
|
| 135 | 135 | |
| 136 | - foreach( $listItems as $listItem ) { |
|
| 137 | - $listMap[ $listItem->getParentId() ][ $listItem->getType() ] = $listItem; |
|
| 136 | + foreach ($listItems as $listItem) { |
|
| 137 | + $listMap[$listItem->getParentId()][$listItem->getType()] = $listItem; |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | - foreach( $map as $pos => $list ) |
|
| 140 | + foreach ($map as $pos => $list) |
|
| 141 | 141 | { |
| 142 | - if( $this->checkEntry( $list ) === false ) { |
|
| 142 | + if ($this->checkEntry($list) === false) { |
|
| 143 | 143 | continue; |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - $codes = explode( $separator, $this->getValue( $list, 'catalog.code', '' ) ); |
|
| 147 | - $listtype = $this->getValue( $list, 'catalog.lists.type', 'default' ); |
|
| 146 | + $codes = explode($separator, $this->getValue($list, 'catalog.code', '')); |
|
| 147 | + $listtype = $this->getValue($list, 'catalog.lists.type', 'default'); |
|
| 148 | 148 | |
| 149 | - foreach( $codes as $code ) |
|
| 149 | + foreach ($codes as $code) |
|
| 150 | 150 | { |
| 151 | - $code = trim( $code ); |
|
| 151 | + $code = trim($code); |
|
| 152 | 152 | |
| 153 | - if( ( $catid = $this->cache->get( $code ) ) === null ) |
|
| 153 | + if (($catid = $this->cache->get($code)) === null) |
|
| 154 | 154 | { |
| 155 | 155 | $msg = 'No category for code "%1$s" available when importing product with code "%2$s"'; |
| 156 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( $msg, $code, $product->getCode() ) ); |
|
| 156 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf($msg, $code, $product->getCode())); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | $list['catalog.lists.parentid'] = $catid; |
| 160 | 160 | $list['catalog.lists.refid'] = $prodid; |
| 161 | 161 | $list['catalog.lists.domain'] = 'product'; |
| 162 | 162 | |
| 163 | - if( isset( $listMap[$catid][$listtype] ) ) |
|
| 163 | + if (isset($listMap[$catid][$listtype])) |
|
| 164 | 164 | { |
| 165 | 165 | $listItem = $listMap[$catid][$listtype]; |
| 166 | - unset( $listItems[ $listItem->getId() ] ); |
|
| 166 | + unset($listItems[$listItem->getId()]); |
|
| 167 | 167 | } |
| 168 | 168 | else |
| 169 | 169 | { |
| 170 | - $listItem = $listManager->createItem( $listtype, 'product' ); |
|
| 170 | + $listItem = $listManager->createItem($listtype, 'product'); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | - $listItem->fromArray( $this->addListItemDefaults( $list, $pos++ ) ); |
|
| 174 | - $listManager->saveItem( $listItem, false ); |
|
| 173 | + $listItem->fromArray($this->addListItemDefaults($list, $pos++)); |
|
| 174 | + $listManager->saveItem($listItem, false); |
|
| 175 | 175 | } |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | - $listManager->deleteItems( array_keys( $listItems ) ); |
|
| 179 | - $data = $this->getObject()->process( $product, $data ); |
|
| 178 | + $listManager->deleteItems(array_keys($listItems)); |
|
| 179 | + $data = $this->getObject()->process($product, $data); |
|
| 180 | 180 | |
| 181 | 181 | $manager->commit(); |
| 182 | 182 | } |
| 183 | - catch( \Exception $e ) |
|
| 183 | + catch (\Exception $e) |
|
| 184 | 184 | { |
| 185 | 185 | $manager->rollback(); |
| 186 | 186 | throw $e; |
@@ -197,13 +197,13 @@ discard block |
||
| 197 | 197 | * @param integer $pos Computed position of the list item in the associated list of items |
| 198 | 198 | * @return array Given associative list enriched by default values if they were not already set |
| 199 | 199 | */ |
| 200 | - protected function addListItemDefaults( array $list, $pos ) |
|
| 200 | + protected function addListItemDefaults(array $list, $pos) |
|
| 201 | 201 | { |
| 202 | - if( !isset( $list['catalog.lists.position'] ) ) { |
|
| 202 | + if (!isset($list['catalog.lists.position'])) { |
|
| 203 | 203 | $list['catalog.lists.position'] = $pos; |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | - if( !isset( $list['catalog.lists.status'] ) ) { |
|
| 206 | + if (!isset($list['catalog.lists.status'])) { |
|
| 207 | 207 | $list['catalog.lists.status'] = 1; |
| 208 | 208 | } |
| 209 | 209 | |
@@ -217,16 +217,16 @@ discard block |
||
| 217 | 217 | * @param array $list Associative list of key/value pairs from the mapped data |
| 218 | 218 | * @return boolean True if the entry is valid, false if not |
| 219 | 219 | */ |
| 220 | - protected function checkEntry( array $list ) |
|
| 220 | + protected function checkEntry(array $list) |
|
| 221 | 221 | { |
| 222 | - if( $this->getValue( $list, 'catalog.code' ) === null ) { |
|
| 222 | + if ($this->getValue($list, 'catalog.code') === null) { |
|
| 223 | 223 | return false; |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | - if( ( $type = $this->getValue( $list, 'catalog.lists.type' ) ) && !isset( $this->listTypes[$type] ) ) |
|
| 226 | + if (($type = $this->getValue($list, 'catalog.lists.type')) && !isset($this->listTypes[$type])) |
|
| 227 | 227 | { |
| 228 | - $msg = sprintf( 'Invalid type "%1$s" (%2$s)', $type, 'catalog list' ); |
|
| 229 | - throw new \Aimeos\Controller\Common\Exception( $msg ); |
|
| 228 | + $msg = sprintf('Invalid type "%1$s" (%2$s)', $type, 'catalog list'); |
|
| 229 | + throw new \Aimeos\Controller\Common\Exception($msg); |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | return true; |
@@ -240,24 +240,24 @@ discard block |
||
| 240 | 240 | * @param array|null $types List of catalog list types |
| 241 | 241 | * @return array List of catalog list items |
| 242 | 242 | */ |
| 243 | - protected function getListItems( $prodid, $types ) |
|
| 243 | + protected function getListItems($prodid, $types) |
|
| 244 | 244 | { |
| 245 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'catalog/lists' ); |
|
| 245 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'catalog/lists'); |
|
| 246 | 246 | $search = $manager->createSearch(); |
| 247 | 247 | |
| 248 | 248 | $expr = array( |
| 249 | - $search->compare( '==', 'catalog.lists.domain', 'product' ), |
|
| 250 | - $search->compare( '==', 'catalog.lists.refid', $prodid ), |
|
| 249 | + $search->compare('==', 'catalog.lists.domain', 'product'), |
|
| 250 | + $search->compare('==', 'catalog.lists.refid', $prodid), |
|
| 251 | 251 | ); |
| 252 | 252 | |
| 253 | - if( $types !== null ) { |
|
| 254 | - $expr[] = $search->compare( '==', 'catalog.lists.type', $types ); |
|
| 253 | + if ($types !== null) { |
|
| 254 | + $expr[] = $search->compare('==', 'catalog.lists.type', $types); |
|
| 255 | 255 | } |
| 256 | 256 | |
| 257 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 258 | - $search->setSortations( array( $search->sort( '+', 'catalog.lists.position' ) ) ); |
|
| 259 | - $search->setSlice( 0, 0x7FFFFFFF ); |
|
| 257 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 258 | + $search->setSortations(array($search->sort('+', 'catalog.lists.position'))); |
|
| 259 | + $search->setSlice(0, 0x7FFFFFFF); |
|
| 260 | 260 | |
| 261 | - return $manager->searchItems( $search ); |
|
| 261 | + return $manager->searchItems($search); |
|
| 262 | 262 | } |
| 263 | 263 | } |
@@ -81,8 +81,7 @@ discard block |
||
| 81 | 81 | foreach( $manager->searchItems( $search ) as $item ) { |
| 82 | 82 | $this->listTypes[$item->getCode()] = $item->getCode(); |
| 83 | 83 | } |
| 84 | - } |
|
| 85 | - else |
|
| 84 | + } else |
|
| 86 | 85 | { |
| 87 | 86 | $this->listTypes = array_flip( $this->listTypes ); |
| 88 | 87 | } |
@@ -164,8 +163,7 @@ discard block |
||
| 164 | 163 | { |
| 165 | 164 | $listItem = $listMap[$catid][$listtype]; |
| 166 | 165 | unset( $listItems[ $listItem->getId() ] ); |
| 167 | - } |
|
| 168 | - else |
|
| 166 | + } else |
|
| 169 | 167 | { |
| 170 | 168 | $listItem = $listManager->createItem( $listtype, 'product' ); |
| 171 | 169 | } |
@@ -179,8 +177,7 @@ discard block |
||
| 179 | 177 | $data = $this->getObject()->process( $product, $data ); |
| 180 | 178 | |
| 181 | 179 | $manager->commit(); |
| 182 | - } |
|
| 183 | - catch( \Exception $e ) |
|
| 180 | + } catch( \Exception $e ) |
|
| 184 | 181 | { |
| 185 | 182 | $manager->rollback(); |
| 186 | 183 | throw $e; |
@@ -42,15 +42,15 @@ 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 | - $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 |
||
| 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 |
||
| 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 | } |
@@ -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/product/listtypes |
| 52 | 52 | * Names of the product list types that are updated or removed |
@@ -74,26 +74,26 @@ discard block |
||
| 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 |
||
| 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( $listtype, 'product' ); |
|
| 134 | + if (($listItem = $product->getListItem('product', $listtype, $prodid)) === null) { |
|
| 135 | + $listItem = $manager->createItem($listtype, 'product'); |
|
| 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 |
||
| 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; |
@@ -87,8 +87,7 @@ |
||
| 87 | 87 | foreach( $manager->searchItems( $search ) as $item ) { |
| 88 | 88 | $this->listTypes[$item->getCode()] = $item->getCode(); |
| 89 | 89 | } |
| 90 | - } |
|
| 91 | - else |
|
| 90 | + } else |
|
| 92 | 91 | { |
| 93 | 92 | $this->listTypes = array_flip( $this->listTypes ); |
| 94 | 93 | } |
@@ -44,10 +44,10 @@ discard block |
||
| 44 | 44 | * @param array $mapping Associative list of field position in CSV as key and domain item key as value |
| 45 | 45 | * @param \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object Decorated processor |
| 46 | 46 | */ |
| 47 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
| 48 | - \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null ) |
|
| 47 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
| 48 | + \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null) |
|
| 49 | 49 | { |
| 50 | - parent::__construct( $context, $mapping, $object ); |
|
| 50 | + parent::__construct($context, $mapping, $object); |
|
| 51 | 51 | |
| 52 | 52 | /** controller/common/product/import/csv/processor/attribute/listtypes |
| 53 | 53 | * Names of the product list types for attributes that are updated or removed |
@@ -69,37 +69,37 @@ discard block |
||
| 69 | 69 | * @see controller/common/product/import/csv/processor/text/listtypes |
| 70 | 70 | */ |
| 71 | 71 | $key = 'controller/common/product/import/csv/processor/attribute/listtypes'; |
| 72 | - $this->listTypes = $context->getConfig()->get( $key ); |
|
| 72 | + $this->listTypes = $context->getConfig()->get($key); |
|
| 73 | 73 | |
| 74 | - if( $this->listTypes === null ) |
|
| 74 | + if ($this->listTypes === null) |
|
| 75 | 75 | { |
| 76 | 76 | $this->listTypes = []; |
| 77 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'product/lists/type' ); |
|
| 77 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'product/lists/type'); |
|
| 78 | 78 | |
| 79 | - $search = $manager->createSearch()->setSlice( 0, 0x7fffffff ); |
|
| 80 | - $search->setConditions( $search->compare( '==', 'product.lists.type.domain', 'attribute' ) ); |
|
| 79 | + $search = $manager->createSearch()->setSlice(0, 0x7fffffff); |
|
| 80 | + $search->setConditions($search->compare('==', 'product.lists.type.domain', 'attribute')); |
|
| 81 | 81 | |
| 82 | - foreach( $manager->searchItems( $search ) as $item ) { |
|
| 82 | + foreach ($manager->searchItems($search) as $item) { |
|
| 83 | 83 | $this->listTypes[$item->getCode()] = $item->getCode(); |
| 84 | 84 | } |
| 85 | 85 | } |
| 86 | 86 | else |
| 87 | 87 | { |
| 88 | - $this->listTypes = array_flip( $this->listTypes ); |
|
| 88 | + $this->listTypes = array_flip($this->listTypes); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | |
| 92 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'attribute/type' ); |
|
| 92 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'attribute/type'); |
|
| 93 | 93 | |
| 94 | - $search = $manager->createSearch()->setSlice( 0, 0x7fffffff ); |
|
| 95 | - $search->setConditions( $search->compare( '==', 'attribute.type.domain', 'product' ) ); |
|
| 94 | + $search = $manager->createSearch()->setSlice(0, 0x7fffffff); |
|
| 95 | + $search->setConditions($search->compare('==', 'attribute.type.domain', 'product')); |
|
| 96 | 96 | |
| 97 | - foreach( $manager->searchItems( $search ) as $item ) { |
|
| 97 | + foreach ($manager->searchItems($search) as $item) { |
|
| 98 | 98 | $this->types[$item->getCode()] = $item->getCode(); |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | |
| 102 | - $this->cache = $this->getCache( 'attribute' ); |
|
| 102 | + $this->cache = $this->getCache('attribute'); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | |
@@ -110,59 +110,59 @@ discard block |
||
| 110 | 110 | * @param array $data List of CSV fields with position as key and data as value |
| 111 | 111 | * @return array List of data which hasn't been imported |
| 112 | 112 | */ |
| 113 | - public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data ) |
|
| 113 | + public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data) |
|
| 114 | 114 | { |
| 115 | 115 | $context = $this->getContext(); |
| 116 | - $listManager = \Aimeos\MShop\Factory::createManager( $context, 'product/lists' ); |
|
| 117 | - $separator = $context->getConfig()->get( 'controller/common/product/import/csv/separator', "\n" ); |
|
| 116 | + $listManager = \Aimeos\MShop\Factory::createManager($context, 'product/lists'); |
|
| 117 | + $separator = $context->getConfig()->get('controller/common/product/import/csv/separator', "\n"); |
|
| 118 | 118 | |
| 119 | 119 | $listMap = []; |
| 120 | - $map = $this->getMappedChunk( $data, $this->getMapping() ); |
|
| 121 | - $listItems = $product->getListItems( 'attribute', $this->listTypes ); |
|
| 120 | + $map = $this->getMappedChunk($data, $this->getMapping()); |
|
| 121 | + $listItems = $product->getListItems('attribute', $this->listTypes); |
|
| 122 | 122 | |
| 123 | - foreach( $listItems as $listItem ) |
|
| 123 | + foreach ($listItems as $listItem) |
|
| 124 | 124 | { |
| 125 | - if( ( $refItem = $listItem->getRefItem() ) !== null ) { |
|
| 126 | - $listMap[ $refItem->getCode() ][ $listItem->getType() ] = $listItem; |
|
| 125 | + if (($refItem = $listItem->getRefItem()) !== null) { |
|
| 126 | + $listMap[$refItem->getCode()][$listItem->getType()] = $listItem; |
|
| 127 | 127 | } |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - foreach( $map as $pos => $list ) |
|
| 130 | + foreach ($map as $pos => $list) |
|
| 131 | 131 | { |
| 132 | - if( $this->checkEntry( $list ) === false ) { |
|
| 132 | + if ($this->checkEntry($list) === false) { |
|
| 133 | 133 | continue; |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - $codes = explode( $separator, $this->getValue( $list, 'attribute.code', '' ) ); |
|
| 136 | + $codes = explode($separator, $this->getValue($list, 'attribute.code', '')); |
|
| 137 | 137 | |
| 138 | - foreach( $codes as $code ) |
|
| 138 | + foreach ($codes as $code) |
|
| 139 | 139 | { |
| 140 | - $code = trim( $code ); |
|
| 141 | - $typecode = $this->getValue( $list, 'product.lists.type', 'default' ); |
|
| 140 | + $code = trim($code); |
|
| 141 | + $typecode = $this->getValue($list, 'product.lists.type', 'default'); |
|
| 142 | 142 | |
| 143 | - if( isset( $listMap[$code][$typecode] ) ) |
|
| 143 | + if (isset($listMap[$code][$typecode])) |
|
| 144 | 144 | { |
| 145 | 145 | $listItem = $listMap[$code][$typecode]; |
| 146 | - unset( $listItems[ $listItem->getId() ] ); |
|
| 146 | + unset($listItems[$listItem->getId()]); |
|
| 147 | 147 | } |
| 148 | 148 | else |
| 149 | 149 | { |
| 150 | - $listItem = $listManager->createItem( $typecode, 'attribute' ); |
|
| 150 | + $listItem = $listManager->createItem($typecode, 'attribute'); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - $attrItem = $this->getAttributeItem( $code, $this->getValue( $list, 'attribute.type' ) ); |
|
| 154 | - $attrItem->fromArray( $list ); |
|
| 155 | - $attrItem->setCode( $code ); |
|
| 153 | + $attrItem = $this->getAttributeItem($code, $this->getValue($list, 'attribute.type')); |
|
| 154 | + $attrItem->fromArray($list); |
|
| 155 | + $attrItem->setCode($code); |
|
| 156 | 156 | |
| 157 | - $listItem->fromArray( $this->addListItemDefaults( $list, $pos ) ); |
|
| 157 | + $listItem->fromArray($this->addListItemDefaults($list, $pos)); |
|
| 158 | 158 | |
| 159 | - $product->addListItem( 'attribute', $listItem, $attrItem ); |
|
| 159 | + $product->addListItem('attribute', $listItem, $attrItem); |
|
| 160 | 160 | } |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - $product->deleteListItems( $listItems ); |
|
| 163 | + $product->deleteListItems($listItems); |
|
| 164 | 164 | |
| 165 | - return $this->getObject()->process( $product, $data ); |
|
| 165 | + return $this->getObject()->process($product, $data); |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | |
@@ -172,22 +172,22 @@ discard block |
||
| 172 | 172 | * @param array $list Associative list of key/value pairs from the mapped data |
| 173 | 173 | * @return boolean True if the entry is valid, false if not |
| 174 | 174 | */ |
| 175 | - protected function checkEntry( array $list ) |
|
| 175 | + protected function checkEntry(array $list) |
|
| 176 | 176 | { |
| 177 | - if( $this->getValue( $list, 'attribute.code' ) === null ) { |
|
| 177 | + if ($this->getValue($list, 'attribute.code') === null) { |
|
| 178 | 178 | return false; |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - if( ( $type = $this->getValue( $list, 'product.lists.type' ) ) && !isset( $this->listTypes[$type] ) ) |
|
| 181 | + if (($type = $this->getValue($list, 'product.lists.type')) && !isset($this->listTypes[$type])) |
|
| 182 | 182 | { |
| 183 | - $msg = sprintf( 'Invalid type "%1$s" (%2$s)', $type, 'product list' ); |
|
| 184 | - throw new \Aimeos\Controller\Common\Exception( $msg ); |
|
| 183 | + $msg = sprintf('Invalid type "%1$s" (%2$s)', $type, 'product list'); |
|
| 184 | + throw new \Aimeos\Controller\Common\Exception($msg); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - if( ( $type = $this->getValue( $list, 'attribute.type' ) ) && !isset( $this->types[$type] ) ) |
|
| 187 | + if (($type = $this->getValue($list, 'attribute.type')) && !isset($this->types[$type])) |
|
| 188 | 188 | { |
| 189 | - $msg = sprintf( 'Invalid type "%1$s" (%2$s)', $type, 'attribute' ); |
|
| 190 | - throw new \Aimeos\Controller\Common\Exception( $msg ); |
|
| 189 | + $msg = sprintf('Invalid type "%1$s" (%2$s)', $type, 'attribute'); |
|
| 190 | + throw new \Aimeos\Controller\Common\Exception($msg); |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | return true; |
@@ -201,22 +201,22 @@ discard block |
||
| 201 | 201 | * @param string $type Attribute type |
| 202 | 202 | * @return \Aimeos\MShop\Attribute\Item\Iface Attribute item object |
| 203 | 203 | */ |
| 204 | - protected function getAttributeItem( $code, $type ) |
|
| 204 | + protected function getAttributeItem($code, $type) |
|
| 205 | 205 | { |
| 206 | - if( ( $item = $this->cache->get( $code, $type ) ) === null ) |
|
| 206 | + if (($item = $this->cache->get($code, $type)) === null) |
|
| 207 | 207 | { |
| 208 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' ); |
|
| 208 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute'); |
|
| 209 | 209 | |
| 210 | 210 | $item = $manager->createItem(); |
| 211 | - $item->setType( $type ); |
|
| 212 | - $item->setDomain( 'product' ); |
|
| 213 | - $item->setLabel( $code ); |
|
| 214 | - $item->setCode( $code ); |
|
| 215 | - $item->setStatus( 1 ); |
|
| 211 | + $item->setType($type); |
|
| 212 | + $item->setDomain('product'); |
|
| 213 | + $item->setLabel($code); |
|
| 214 | + $item->setCode($code); |
|
| 215 | + $item->setStatus(1); |
|
| 216 | 216 | |
| 217 | - $item = $manager->saveItem( $item ); |
|
| 217 | + $item = $manager->saveItem($item); |
|
| 218 | 218 | |
| 219 | - $this->cache->set( $item ); |
|
| 219 | + $this->cache->set($item); |
|
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | return $item; |
@@ -82,8 +82,7 @@ discard block |
||
| 82 | 82 | foreach( $manager->searchItems( $search ) as $item ) { |
| 83 | 83 | $this->listTypes[$item->getCode()] = $item->getCode(); |
| 84 | 84 | } |
| 85 | - } |
|
| 86 | - else |
|
| 85 | + } else |
|
| 87 | 86 | { |
| 88 | 87 | $this->listTypes = array_flip( $this->listTypes ); |
| 89 | 88 | } |
@@ -144,8 +143,7 @@ discard block |
||
| 144 | 143 | { |
| 145 | 144 | $listItem = $listMap[$code][$typecode]; |
| 146 | 145 | unset( $listItems[ $listItem->getId() ] ); |
| 147 | - } |
|
| 148 | - else |
|
| 146 | + } else |
|
| 149 | 147 | { |
| 150 | 148 | $listItem = $listManager->createItem( $typecode, 'attribute' ); |
| 151 | 149 | } |
@@ -42,15 +42,15 @@ 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 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'product/property/type' ); |
|
| 51 | - $search = $manager->createSearch()->setSlice( 0, 0x7fffffff ); |
|
| 50 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'product/property/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,47 +63,47 @@ discard block |
||
| 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(), 'product/property' ); |
|
| 68 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/property'); |
|
| 69 | 69 | |
| 70 | 70 | $propMap = []; |
| 71 | - $items = $product->getPropertyItems( null, false ); |
|
| 72 | - $map = $this->getMappedChunk( $data, $this->getMapping() ); |
|
| 71 | + $items = $product->getPropertyItems(null, false); |
|
| 72 | + $map = $this->getMappedChunk($data, $this->getMapping()); |
|
| 73 | 73 | |
| 74 | - foreach( $items as $item ) { |
|
| 75 | - $propMap[ $item->getValue() ][ $item->getType() ] = $item; |
|
| 74 | + foreach ($items as $item) { |
|
| 75 | + $propMap[$item->getValue()][$item->getType()] = $item; |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - foreach( $map as $list ) |
|
| 78 | + foreach ($map as $list) |
|
| 79 | 79 | { |
| 80 | - if( ( $value = $this->getValue( $list, 'product.property.value' ) ) === null ) { |
|
| 80 | + if (($value = $this->getValue($list, 'product.property.value')) === null) { |
|
| 81 | 81 | continue; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - if( ( $type = $this->getValue( $list, 'product.property.type' ) ) && !isset( $this->types[$type] ) ) |
|
| 84 | + if (($type = $this->getValue($list, 'product.property.type')) && !isset($this->types[$type])) |
|
| 85 | 85 | { |
| 86 | - $msg = sprintf( 'Invalid type "%1$s" (%2$s)', $type, 'product property' ); |
|
| 87 | - throw new \Aimeos\Controller\Common\Exception( $msg ); |
|
| 86 | + $msg = sprintf('Invalid type "%1$s" (%2$s)', $type, 'product property'); |
|
| 87 | + throw new \Aimeos\Controller\Common\Exception($msg); |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - if( isset( $propMap[$value][$type] ) ) |
|
| 90 | + if (isset($propMap[$value][$type])) |
|
| 91 | 91 | { |
| 92 | 92 | $item = $propMap[$value][$type]; |
| 93 | - unset( $items[ $item->getId() ] ); |
|
| 93 | + unset($items[$item->getId()]); |
|
| 94 | 94 | } |
| 95 | 95 | else |
| 96 | 96 | { |
| 97 | - $item = $manager->createItem( $type, 'product' ); |
|
| 97 | + $item = $manager->createItem($type, 'product'); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - $item->fromArray( $list ); |
|
| 100 | + $item->fromArray($list); |
|
| 101 | 101 | |
| 102 | - $product->addPropertyItem( $item ); |
|
| 102 | + $product->addPropertyItem($item); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - $product->deletePropertyItems( $items ); |
|
| 105 | + $product->deletePropertyItems($items); |
|
| 106 | 106 | |
| 107 | - return $this->getObject()->process( $product, $data ); |
|
| 107 | + return $this->getObject()->process($product, $data); |
|
| 108 | 108 | } |
| 109 | 109 | } |
@@ -91,8 +91,7 @@ |
||
| 91 | 91 | { |
| 92 | 92 | $item = $propMap[$value][$type]; |
| 93 | 93 | unset( $items[ $item->getId() ] ); |
| 94 | - } |
|
| 95 | - else |
|
| 94 | + } else |
|
| 96 | 95 | { |
| 97 | 96 | $item = $manager->createItem( $type, 'product' ); |
| 98 | 97 | } |
@@ -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/text/listtypes |
| 52 | 52 | * Names of the product list types for texts that are updated or removed |
@@ -68,32 +68,32 @@ discard block |
||
| 68 | 68 | * @see controller/common/product/import/csv/processor/product/listtypes |
| 69 | 69 | */ |
| 70 | 70 | $key = 'controller/common/product/import/csv/processor/text/listtypes'; |
| 71 | - $this->listTypes = $context->getConfig()->get( $key ); |
|
| 71 | + $this->listTypes = $context->getConfig()->get($key); |
|
| 72 | 72 | |
| 73 | - if( $this->listTypes === null ) |
|
| 73 | + if ($this->listTypes === null) |
|
| 74 | 74 | { |
| 75 | 75 | $this->listTypes = []; |
| 76 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'product/lists/type' ); |
|
| 76 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'product/lists/type'); |
|
| 77 | 77 | |
| 78 | - $search = $manager->createSearch()->setSlice( 0, 0x7fffffff ); |
|
| 79 | - $search->setConditions( $search->compare( '==', 'product.lists.type.domain', 'text' ) ); |
|
| 78 | + $search = $manager->createSearch()->setSlice(0, 0x7fffffff); |
|
| 79 | + $search->setConditions($search->compare('==', 'product.lists.type.domain', 'text')); |
|
| 80 | 80 | |
| 81 | - foreach( $manager->searchItems( $search ) as $item ) { |
|
| 81 | + foreach ($manager->searchItems($search) as $item) { |
|
| 82 | 82 | $this->listTypes[$item->getCode()] = $item->getCode(); |
| 83 | 83 | } |
| 84 | 84 | } |
| 85 | 85 | else |
| 86 | 86 | { |
| 87 | - $this->listTypes = array_flip( $this->listTypes ); |
|
| 87 | + $this->listTypes = array_flip($this->listTypes); |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | |
| 91 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'text/type' ); |
|
| 91 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'text/type'); |
|
| 92 | 92 | |
| 93 | - $search = $manager->createSearch()->setSlice( 0, 0x7fffffff ); |
|
| 94 | - $search->setConditions( $search->compare( '==', 'text.type.domain', 'product' ) ); |
|
| 93 | + $search = $manager->createSearch()->setSlice(0, 0x7fffffff); |
|
| 94 | + $search->setConditions($search->compare('==', 'text.type.domain', 'product')); |
|
| 95 | 95 | |
| 96 | - foreach( $manager->searchItems( $search ) as $item ) { |
|
| 96 | + foreach ($manager->searchItems($search) as $item) { |
|
| 97 | 97 | $this->types[$item->getCode()] = $item->getCode(); |
| 98 | 98 | } |
| 99 | 99 | } |
@@ -106,53 +106,53 @@ discard block |
||
| 106 | 106 | * @param array $data List of CSV fields with position as key and data as value |
| 107 | 107 | * @return array List of data which hasn't been imported |
| 108 | 108 | */ |
| 109 | - public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data ) |
|
| 109 | + public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data) |
|
| 110 | 110 | { |
| 111 | - $listManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/lists' ); |
|
| 112 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'text' ); |
|
| 111 | + $listManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/lists'); |
|
| 112 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'text'); |
|
| 113 | 113 | |
| 114 | 114 | $listMap = []; |
| 115 | - $map = $this->getMappedChunk( $data, $this->getMapping() ); |
|
| 116 | - $listItems = $product->getListItems( 'text', $this->listTypes ); |
|
| 115 | + $map = $this->getMappedChunk($data, $this->getMapping()); |
|
| 116 | + $listItems = $product->getListItems('text', $this->listTypes); |
|
| 117 | 117 | |
| 118 | - foreach( $listItems as $listItem ) |
|
| 118 | + foreach ($listItems as $listItem) |
|
| 119 | 119 | { |
| 120 | - if( ( $refItem = $listItem->getRefItem() ) !== null ) { |
|
| 121 | - $listMap[ $refItem->getContent() ][ $refItem->getType() ][ $listItem->getType() ] = $listItem; |
|
| 120 | + if (($refItem = $listItem->getRefItem()) !== null) { |
|
| 121 | + $listMap[$refItem->getContent()][$refItem->getType()][$listItem->getType()] = $listItem; |
|
| 122 | 122 | } |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - foreach( $map as $pos => $list ) |
|
| 125 | + foreach ($map as $pos => $list) |
|
| 126 | 126 | { |
| 127 | - if( $this->checkEntry( $list ) === false ) { |
|
| 127 | + if ($this->checkEntry($list) === false) { |
|
| 128 | 128 | continue; |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - $type = $this->getValue( $list, 'text.type', 'name' ); |
|
| 132 | - $listtype = $this->getValue( $list, 'product.lists.type', 'default' ); |
|
| 133 | - $content = $this->getValue( $list, 'text.content', '' ); |
|
| 131 | + $type = $this->getValue($list, 'text.type', 'name'); |
|
| 132 | + $listtype = $this->getValue($list, 'product.lists.type', 'default'); |
|
| 133 | + $content = $this->getValue($list, 'text.content', ''); |
|
| 134 | 134 | |
| 135 | - if( isset( $listMap[$content][$type][$listtype] ) ) |
|
| 135 | + if (isset($listMap[$content][$type][$listtype])) |
|
| 136 | 136 | { |
| 137 | 137 | $listItem = $listMap[$content][$type][$listtype]; |
| 138 | 138 | $refItem = $listItem->getRefItem(); |
| 139 | - unset( $listItems[ $listItem->getId() ] ); |
|
| 139 | + unset($listItems[$listItem->getId()]); |
|
| 140 | 140 | } |
| 141 | 141 | else |
| 142 | 142 | { |
| 143 | - $listItem = $listManager->createItem( $listtype, 'text' ); |
|
| 144 | - $refItem = $manager->createItem( $type, 'product' ); |
|
| 143 | + $listItem = $listManager->createItem($listtype, 'text'); |
|
| 144 | + $refItem = $manager->createItem($type, 'product'); |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - $refItem->fromArray( $this->addItemDefaults( $list ) ); |
|
| 148 | - $listItem->fromArray( $this->addListItemDefaults( $list, $pos ) ); |
|
| 147 | + $refItem->fromArray($this->addItemDefaults($list)); |
|
| 148 | + $listItem->fromArray($this->addListItemDefaults($list, $pos)); |
|
| 149 | 149 | |
| 150 | - $product->addListItem( 'text', $listItem, $refItem ); |
|
| 150 | + $product->addListItem('text', $listItem, $refItem); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - $product->deleteListItems( $listItems, true ); |
|
| 153 | + $product->deleteListItems($listItems, true); |
|
| 154 | 154 | |
| 155 | - return $this->getObject()->process( $product, $data ); |
|
| 155 | + return $this->getObject()->process($product, $data); |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | |
@@ -162,13 +162,13 @@ discard block |
||
| 162 | 162 | * @param array $list Associative list of domain item keys and their values, e.g. "text.status" => 1 |
| 163 | 163 | * @return array Given associative list enriched by default values if they were not already set |
| 164 | 164 | */ |
| 165 | - protected function addItemDefaults( array $list ) |
|
| 165 | + protected function addItemDefaults(array $list) |
|
| 166 | 166 | { |
| 167 | - if( !isset( $list['text.label'] ) ) { |
|
| 168 | - $list['text.label'] = mb_strcut( trim( $list['text.content'] ), 0, 255 ); |
|
| 167 | + if (!isset($list['text.label'])) { |
|
| 168 | + $list['text.label'] = mb_strcut(trim($list['text.content']), 0, 255); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - if( !isset( $list['text.status'] ) ) { |
|
| 171 | + if (!isset($list['text.status'])) { |
|
| 172 | 172 | $list['text.status'] = 1; |
| 173 | 173 | } |
| 174 | 174 | |
@@ -182,22 +182,22 @@ discard block |
||
| 182 | 182 | * @param array $list Associative list of key/value pairs from the mapping |
| 183 | 183 | * @return boolean True if valid, false if not |
| 184 | 184 | */ |
| 185 | - protected function checkEntry( array $list ) |
|
| 185 | + protected function checkEntry(array $list) |
|
| 186 | 186 | { |
| 187 | - if( $this->getValue( $list, 'text.content' ) === null ) { |
|
| 187 | + if ($this->getValue($list, 'text.content') === null) { |
|
| 188 | 188 | return false; |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | - if( ( $type = $this->getValue( $list, 'product.lists.type' ) ) && !isset( $this->listTypes[$type] ) ) |
|
| 191 | + if (($type = $this->getValue($list, 'product.lists.type')) && !isset($this->listTypes[$type])) |
|
| 192 | 192 | { |
| 193 | - $msg = sprintf( 'Invalid type "%1$s" (%2$s)', $type, 'product list' ); |
|
| 194 | - throw new \Aimeos\Controller\Common\Exception( $msg ); |
|
| 193 | + $msg = sprintf('Invalid type "%1$s" (%2$s)', $type, 'product list'); |
|
| 194 | + throw new \Aimeos\Controller\Common\Exception($msg); |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | - if( ( $type = $this->getValue( $list, 'text.type' ) ) && !isset( $this->types[$type] ) ) |
|
| 197 | + if (($type = $this->getValue($list, 'text.type')) && !isset($this->types[$type])) |
|
| 198 | 198 | { |
| 199 | - $msg = sprintf( 'Invalid type "%1$s" (%2$s)', $type, 'text' ); |
|
| 200 | - throw new \Aimeos\Controller\Common\Exception( $msg ); |
|
| 199 | + $msg = sprintf('Invalid type "%1$s" (%2$s)', $type, 'text'); |
|
| 200 | + throw new \Aimeos\Controller\Common\Exception($msg); |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | return true; |
@@ -81,8 +81,7 @@ discard block |
||
| 81 | 81 | foreach( $manager->searchItems( $search ) as $item ) { |
| 82 | 82 | $this->listTypes[$item->getCode()] = $item->getCode(); |
| 83 | 83 | } |
| 84 | - } |
|
| 85 | - else |
|
| 84 | + } else |
|
| 86 | 85 | { |
| 87 | 86 | $this->listTypes = array_flip( $this->listTypes ); |
| 88 | 87 | } |
@@ -137,8 +136,7 @@ discard block |
||
| 137 | 136 | $listItem = $listMap[$content][$type][$listtype]; |
| 138 | 137 | $refItem = $listItem->getRefItem(); |
| 139 | 138 | unset( $listItems[ $listItem->getId() ] ); |
| 140 | - } |
|
| 141 | - else |
|
| 139 | + } else |
|
| 142 | 140 | { |
| 143 | 141 | $listItem = $listManager->createItem( $listtype, 'text' ); |
| 144 | 142 | $refItem = $manager->createItem( $type, 'product' ); |