|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
|
5
|
|
|
* @copyright Aimeos (aimeos.org), 2019 |
|
6
|
|
|
* @package Controller |
|
7
|
|
|
* @subpackage Common |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
|
|
11
|
|
|
namespace Aimeos\Controller\Common\Common\Import\Xml\Processor\Lists\Text; |
|
12
|
|
|
|
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Text list processor for XML imports |
|
16
|
|
|
* |
|
17
|
|
|
* @package Controller |
|
18
|
|
|
* @subpackage Common |
|
19
|
|
|
*/ |
|
20
|
|
|
class Standard |
|
21
|
|
|
extends \Aimeos\Controller\Common\Common\Import\Xml\Processor\Base |
|
22
|
|
|
implements \Aimeos\Controller\Common\Common\Import\Xml\Processor\Iface |
|
23
|
|
|
{ |
|
24
|
|
|
use \Aimeos\Controller\Common\Common\Import\Xml\Traits; |
|
25
|
|
|
|
|
26
|
|
|
|
|
27
|
|
|
/** controller/common/common/import/xml/processor/lists/text/name |
|
28
|
|
|
* Name of the lists processor implementation |
|
29
|
|
|
* |
|
30
|
|
|
* Use "Myname" if your class is named "\Aimeos\Controller\Common\Common\Import\Xml\Processor\Lists\Text\Myname". |
|
31
|
|
|
* The name is case-sensitive and you should avoid camel case names like "MyName". |
|
32
|
|
|
* |
|
33
|
|
|
* @param string Last part of the processor class name |
|
34
|
|
|
* @since 2019.04 |
|
35
|
|
|
* @category Developer |
|
36
|
|
|
*/ |
|
37
|
|
|
|
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Updates the given item using the data from the DOM node |
|
41
|
|
|
* |
|
42
|
|
|
* @param \Aimeos\MShop\Common\Item\Iface $item Item which should be updated |
|
43
|
|
|
* @param \DOMNode $node XML document node containing a list of nodes to process |
|
44
|
|
|
* @return \Aimeos\MShop\Common\Item\Iface Updated item |
|
45
|
|
|
*/ |
|
46
|
|
|
public function process( \Aimeos\MShop\Common\Item\Iface $item, \DOMNode $node ) |
|
47
|
|
|
{ |
|
48
|
|
|
\Aimeos\MW\Common\Base::checkClass( \Aimeos\MShop\Common\Item\ListRef\Iface::class, $item ); |
|
49
|
|
|
|
|
50
|
|
|
$listItems = array_reverse( $item->getListItems( 'text', null, null, false ), true ); |
|
51
|
|
|
$resource = $item->getResourceType(); |
|
52
|
|
|
$context = $this->getContext(); |
|
53
|
|
|
|
|
54
|
|
|
$listManager = \Aimeos\MShop::create( $context, $resource . '/lists' ); |
|
55
|
|
|
$manager = \Aimeos\MShop::create( $context, 'text' ); |
|
56
|
|
|
|
|
57
|
|
|
foreach( $node->childNodes as $refNode ) |
|
58
|
|
|
{ |
|
59
|
|
|
if( $refNode->nodeName !== 'textitem' ) { |
|
60
|
|
|
continue; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
if( ( $listItem = array_pop( $listItems ) ) === null ) { |
|
64
|
|
|
$listItem = $listManager->createItem(); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
if( ( $refItem = $listItem->getRefItem() ) === null ) { |
|
|
|
|
|
|
68
|
|
|
$refItem = $manager->createItem(); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
$list = []; |
|
72
|
|
|
|
|
73
|
|
|
foreach( $refNode->childNodes as $tagNode ) { |
|
74
|
|
|
$list[$tagNode->nodeName] = $tagNode->nodeValue; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
$refItem = $refItem->fromArray( $list ); |
|
78
|
|
|
|
|
79
|
|
|
foreach( $refNode->attributes as $attrName => $attrNode ) { |
|
80
|
|
|
$list[$resource . '.' . $attrName] = $attrNode->nodeValue; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
$listItem = $listItem->fromArray( $list ); |
|
84
|
|
|
|
|
85
|
|
|
$item->addListItem( 'text', $listItem, $refItem ); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
return $item->deleteListItems( $listItems ); |
|
89
|
|
|
} |
|
90
|
|
|
} |
|
91
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.