Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Magento{
- private $proxy, $sessionId;
- public function __construct(){
- $this->proxy = new SoapClient('http://magentohost/index.php/api/v2_soap/?wsdl');
- $this->sessionId = $this->proxy->login('username', 'passwd');
- }
- public function __call($name, $arguments){
- array_unshift($arguments, $this->sessionId);
- return call_user_func_array(array($this->proxy, $name), $arguments);
- }
- }
- class MagentoWorker extends Worker {
- private $magento;
- public function __construct() {
- $this->magento = new Magento();
- }
- public function getMagento(){
- return $this->magento;
- }
- }
- class MyPool extends Pool{
- }
- function createPool($workerClass){
- return new Pool(3, $workerClass);
- }
- function submitTask($pool, $run, $data = null){
- $retVal = Collectable::from(function(){
- try{
- $action = $this->action;
- $action($this);
- }finally{
- $this->setGarbage();
- }
- }, function ($arg, $run){
- $this->action = $run;
- $this->action_data = $arg;
- }, [$data, $run]);
- $pool->submit($retVal);
- return $retVal;
- }
- function cleanupPool($pool){
- $pool->shutdown();
- $pool->collect(function($work){
- waitForWork($work);
- return $work->isGarbage();
- });
- }
- $magento = createPool('MagentoWorker');
- $productListTask = submitTask($magento, function($worker) {
- try{
- $magento = $worker->worker->getMagento();
- // This call fails with:
- // Error finding "uri" property
- // #0 [internal function]: SoapClient->__call('catalogProductL...', Array)
- // #1 [internal function]: SoapClient->catalogProductList('88762fc08a29593...')
- // #2 /root/xero/mageno.php(11): call_user_func_array(Array, Array)
- // #3 /root/xero/test.php(121): Magento->__call('catalogProductL...', Array)
- // #4 /root/xero/test.php(121): Magento->catalogProductList()
- // #5 /root/xero/pool.php(37): CollectableClosure@0x7f37cf52b6c0->{closur}(Object(CollectableClosure@0x7f37cf52b6c0))
- // #6 {main}something went wrong
- $magento->catalogProductList();
- }catch(Exception $e){
- echo $e->getMessage() . "\n";
- echo ($e->getTraceAsString());
- }finally{
- echo "something went wrong\n";
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement