note 119085 deleted from soapclient.soapclient by crell

From: Date: Mon, 04 Apr 2022 16:50:06 +0000
Subject: note 119085 deleted from soapclient.soapclient by crell
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-218083@lists.php.net to get a copy of this message
Note Submitter: cdesully at webslicer dot com ---- I found a good use for typemap. When using classmap any xml tags that had attributes, attribute values were not captured, so a typemap allows you to override how a class gets implemented and being able to get any attributes not previously captured. <ItemList> <Item productId="1234"> <feature>red</feature> </Item> <Item productId="5678"> <feature>blue</feature> </Item> </ItemList> <?php //semi-pseudo code namespace ExampleNS; class ItemList { public $item = []; } class Item { public $productId; public $feature; } class Service { public function __construct(){ $options = [ 'classmap' => [ 'ItemList' => 'ExampleNS\ItemList', 'Item' => 'ExampleNS\Item' ], 'typemap'=>[ 'type_ns' => 'http://some.wsdl.ns/sdo', 'type_name' => 'Item', 'from_xml' => [__CLASS__,'newConversion'] ] ]; } public function newConversion($xml){ return simplexml_load_string($xml); //or more appropriately dig into the simplexml object and //instantiate the correct classes intended to be defined and //return those } } ?>

« previous php.notes (#218083) next »