diff --git a/composer.json b/composer.json index 0c23877..156128c 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ } }, "require": { - "php": ">=7.4", + "php": ">=8.0", "guzzlehttp/guzzle": "^7.3", "php-arsenal/salesforce-soap-client": "^2.0", "symfony/console": "^5.2", diff --git a/src/Command/RefreshWsdlCommand.php b/src/Command/RefreshWsdlCommand.php index eab23f4..7a0fd25 100644 --- a/src/Command/RefreshWsdlCommand.php +++ b/src/Command/RefreshWsdlCommand.php @@ -1,4 +1,5 @@ */ 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,7 +47,7 @@ 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'); @@ -63,13 +55,10 @@ protected function execute(InputInterface $input, OutputInterface $output) 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()); } -} - +} \ No newline at end of file diff --git a/src/DependencyInjection/SalesforceExtension.php b/src/DependencyInjection/SalesforceExtension.php index 024184d..d1f53d6 100644 --- a/src/DependencyInjection/SalesforceExtension.php +++ b/src/DependencyInjection/SalesforceExtension.php @@ -22,10 +22,15 @@ public function load(array $configs, ContainerBuilder $container) $configuration = new Configuration(); $processedConfiguration = $this->processConfiguration($configuration, $configs); - $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); + $fileLocator = new FileLocator(__DIR__.'/../Resources/config'); + + $xmlLoader = new Loader\XmlFileLoader($container, $fileLocator); + $xmlLoader->load('soap_client.xml'); + $xmlLoader->load('rest_client.xml'); + + $yamlLoader = new Loader\YamlFileLoader($container, $fileLocator); + $yamlLoader->load('services.yaml'); - $loader->load('soap_client.xml'); - $loader->load('rest_client.xml'); foreach ($processedConfiguration as $key => $value) { $container->setParameter('salesforce.soap_client.' . $key, $value); } diff --git a/src/Resources/config/services.yaml b/src/Resources/config/services.yaml new file mode 100644 index 0000000..544685a --- /dev/null +++ b/src/Resources/config/services.yaml @@ -0,0 +1,4 @@ +services: + PhpArsenal\SalesforceBundle\Command\RefreshWsdlCommand: + autoconfigure: true + arguments: ['@salesforce.soap_client', '%salesforce.soap_client.wsdl%'] \ No newline at end of file