forked from comsave/salesforce-bundle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
28 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<?php | ||
|
||
namespace PhpArsenal\SalesforceBundle\Command; | ||
|
||
use PhpArsenal\SoapClient\Client; | ||
|
@@ -10,34 +11,25 @@ | |
|
||
/** | ||
* Fetch latest WSDL from Salesforce and store it locally | ||
* | ||
* @author David de Boer <[email protected]> | ||
*/ | ||
class RefreshWsdlCommand extends Command | ||
{ | ||
/** @var Client */ | ||
private $soapClient; | ||
|
||
private const COMMAND_NAME = 'salesforce:wsdl:refresh'; | ||
protected static $defaultName = 'salesforce:wsdl:refresh'; | ||
|
||
/** | ||
* RefreshWsdlCommand constructor. | ||
* @param Client $soapClient | ||
*/ | ||
public function __construct(Client $soapClient) | ||
public function __construct( | ||
private Client $soapClient, | ||
private string $wsdlPath | ||
) | ||
{ | ||
parent::__construct(self::COMMAND_NAME); | ||
|
||
$this->soapClient = $soapClient; | ||
parent::__construct(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function configure() | ||
protected function configure(): void | ||
{ | ||
$this | ||
->setName(self::COMMAND_NAME) | ||
->setDescription('Refresh Salesforce WSDL') | ||
->setHelp( | ||
'Refreshing the WSDL itself requires a WSDL, so when using this' | ||
|
@@ -55,21 +47,18 @@ protected function configure() | |
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function execute(InputInterface $input, OutputInterface $output) | ||
protected function execute(InputInterface $input, OutputInterface $output): int | ||
{ | ||
$output->writeln('Updating the WSDL file'); | ||
|
||
$this->downloadWsdl(); | ||
|
||
if (!$input->getOption('no-cache-clear')) { | ||
$command = $this->getApplication()->find('cache:clear'); | ||
|
||
$arguments = array( | ||
'command' => 'cache:clear', | ||
); | ||
$input = new ArrayInput($arguments); | ||
$command->run($input, $output); | ||
$command->run(new ArrayInput(['command' => 'cache:clear']), $output); | ||
} | ||
|
||
return Command::SUCCESS; | ||
} | ||
|
||
public function downloadWsdl(): void | ||
|
@@ -95,13 +84,10 @@ public function downloadWsdl(): void | |
] | ||
]); | ||
|
||
$wsdlFile = $this->getContainer()->getParameter('salesforce.soap_client.wsdl'); | ||
|
||
if(!\simplexml_load_string((string)$response->getBody())) { | ||
if (!\simplexml_load_string((string)$response->getBody())) { | ||
throw new \Exception('The downloaded WSDL is invalid. ' . sprintf('`%s`', (string)$response->getBody())); | ||
} | ||
|
||
file_put_contents($wsdlFile, (string)$response->getBody()); | ||
file_put_contents($this->wsdlPath, (string)$response->getBody()); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
services: | ||
PhpArsenal\SalesforceBundle\Command\RefreshWsdlCommand: | ||
autoconfigure: true | ||
arguments: ['@salesforce.soap_client', '%salesforce.soap_client.wsdl%'] |