Skip to content

Commit

Permalink
updating to Laravel 4.2 and above
Browse files Browse the repository at this point in the history
  • Loading branch information
davispeixoto committed Aug 12, 2014
1 parent 9568d63 commit 6f84b77
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 17 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
],
"require": {
"php": ">=5.3.0",
"illuminate/support": "4.1.*",
"illuminate/support": "4.*",
"davispeixoto/force-dot-com-toolkit-for-php": "1.0.3"
},
"autoload": {
Expand Down
35 changes: 21 additions & 14 deletions src/Davispeixoto/LaravelSalesforce/Salesforce.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use Davispeixoto\ForceDotComToolkitForPhp\SforceEnterpriseClient as Client;
use Illuminate\Config\Repository;
use Illuminate\Filesystem\Filesystem as File;

class Salesforce {
public $sfh;
Expand All @@ -12,18 +13,24 @@ public function __construct(Repository $configExternal)
$this->sfh = new Client();

$wsdl = $configExternal->get('laravel-salesforce::wsdl');
$filePointer = new File();

if (empty($wsdl)) {
$wsdl = __DIR__.'/Wsdl/enterprise.wsdl.xml';
if (!empty($wsdl) && $filePointer->exists($wsdl)) {
$this->sfh->createConnection($configExternal->get('laravel-salesforce::wsdl'));
} else {
$this->sfh->createConnection(__DIR__.'/Wsdl/enterprise.wsdl.xml');
}

$this->sfh->createConnection($wsdl);
$endpoint = $configExternal->get('laravel-salesforce::endpoint');
if (!empty($endpoint)) {
$this->sfh->setEndpoint($endpoint);
}

$this->sfh->login($configExternal->get('laravel-salesforce::username') , $configExternal->get('laravel-salesforce::password') . $configExternal->get('laravel-salesforce::token'));
return $this;
} catch (Exception $e) {
} catch (\Exception $e) {
Log::error($e->getMessage());
throw new Exception('Exception no Construtor' . $e->getMessage() . "\n\n" . $e->getTraceAsString());
throw new \Exception('Exception in Construtor' . $e->getMessage() . PHP_EOL . $e->getTraceAsString());
}
}

Expand All @@ -35,14 +42,14 @@ public function create($sObjects, $type)
return $this->sfh->create($sObjects, $type);
}

public function update($sObjects, $type, $assignment_header = NULL, $mru_header = NULL)
public function update($sObjects, $type, $assignmentHeader = NULL, $mruHeader = NULL)
{
return $this->sfh->update($sObjects, $type, $assignment_header, $mru_header);
return $this->sfh->update($sObjects, $type, $assignmentHeader, $mruHeader);
}

public function upsert($ext_Id, $sObjects, $type = 'Contact')
public function upsert($extId, $sObjects, $type = 'Contact')
{
return $this->sfh->upsert($ext_Id, $sObjects, $type);
return $this->sfh->upsert($extId, $sObjects, $type);
}

public function merge($mergeRequest, $type)
Expand All @@ -63,9 +70,9 @@ public function printDebugInfo()
return $this->sfh->printDebugInfo();
}

public function createConnection($wsdl, $proxy = NULL, $soap_options = array())
public function createConnection($wsdl, $proxy = NULL, $soapOptions = array())
{
return $this->sfh->createConnection($wsdl, $proxy, $soap_options);
return $this->sfh->createConnection($wsdl, $proxy, $soapOptions);
}

public function setCallOptions($header)
Expand Down Expand Up @@ -113,9 +120,9 @@ public function setMruHeader($header)
return $this->sfh->setMruHeader($header);
}

public function setSessionHeader($id)
public function setSessionHeader($sessionId)
{
return $this->sfh->setSessionHeader($id);
return $this->sfh->setSessionHeader($sessionId);
}

public function setUserTerritoryDeleteHeader($header)
Expand Down Expand Up @@ -324,7 +331,7 @@ public function resetPassword($userId)
public function dump()
{
$str = print_r($this , true);
//$str .= print_r($this->sfh , true);
return $str;
}
}
?>
6 changes: 4 additions & 2 deletions src/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@
'username' => '',
'password' => '',
'token' => '',
'wsdl' => app_path() . '/wsdl/enterprise.wsdl.xml',
'endpoint' => null,
'wsdl' => null,


// sandbox
// 'username' => '',
// 'password' => '',
// 'token' => '',
// 'wsdl' => app_path() . '/wsdl/enterprise.sandbox.wsdl.xml',
// 'endpoint' => 'https://test.salesforce.com/services/Soap/c/27.0',
// 'wsdl' => null,
);

0 comments on commit 6f84b77

Please sign in to comment.