Skip to content

Commit

Permalink
PT-13155 - Fix cs
Browse files Browse the repository at this point in the history
  • Loading branch information
DennisGarding committed Jun 14, 2024
1 parent 4fc8087 commit 2481a8d
Show file tree
Hide file tree
Showing 28 changed files with 18,506 additions and 18,474 deletions.
1 change: 1 addition & 0 deletions Components/TransactionReport/TransactionReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public function reportOrder($orderId)

/**
* @param string $shopwareVersion
* @param string $instanceId
*
* @return void
*/
Expand Down
2 changes: 1 addition & 1 deletion Setup/Assets/tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ CREATE TABLE IF NOT EXISTS `swag_payment_paypal_unified_transaction_report`

CREATE TABLE IF NOT EXISTS `swag_payment_paypal_unified_instance`
(
`instance_id` VARCHAR(255) NOT NULL
`instance_id` VARCHAR(36) NOT NULL
) ENGINE = InnoDB
DEFAULT CHARSET = utf8
COLLATE = utf8_unicode_ci;
7 changes: 4 additions & 3 deletions Setup/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace SwagPaymentPayPalUnified\Setup;

use Doctrine\DBAL\Connection;
use Exception;
use Shopware\Bundle\AttributeBundle\Service\CrudService;
use Shopware\Bundle\AttributeBundle\Service\CrudServiceInterface;
use Shopware\Bundle\AttributeBundle\Service\TypeMapping;
Expand Down Expand Up @@ -87,9 +88,9 @@ public function __construct(
}

/**
* @return bool
* @throws InstallationException
*
* @return bool
*/
public function install()
{
Expand All @@ -111,8 +112,8 @@ public function install()
try {
// call the instance id service to create the instance id
(new InstanceIdService($this->connection))->getInstanceId();
} catch (\Exception $e) {
throw new InstallationException($e->getMessage());
} catch (Exception $exception) {
// no need to handle this exception
}

return true;
Expand Down
3 changes: 2 additions & 1 deletion Setup/InstanceIdService.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace SwagPaymentPayPalUnified\Setup;

use Doctrine\DBAL\Connection;
use RuntimeException;
use SwagPaymentPayPalUnified\Components\Uuid;

final class InstanceIdService
Expand Down Expand Up @@ -69,7 +70,7 @@ private function create()
->execute();

if ($instanceId !== $this->get()) {
throw new \RuntimeException('Could not create instance id');
throw new RuntimeException('Could not create instance id');
}

return $instanceId;
Expand Down
14 changes: 12 additions & 2 deletions Setup/Versions/UpdateTo618.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@
namespace SwagPaymentPayPalUnified\Setup\Versions;

use Doctrine\DBAL\Connection;
use Exception;
use SwagPaymentPayPalUnified\Setup\InstanceIdService;

class UpdateTo618
{
/**
* @var Connection
*/
private $connection;

public function __construct(Connection $connection)
{
$this->connection = $connection;
Expand All @@ -25,7 +31,11 @@ public function update()
{
$this->createInstanceTable();

(new InstanceIdService($this->connection))->getInstanceId();
try {
(new InstanceIdService($this->connection))->getInstanceId();
} catch (Exception $e) {
// no need to handle this exception
}
}

/**
Expand All @@ -37,7 +47,7 @@ private function createInstanceTable()
'
CREATE TABLE IF NOT EXISTS `swag_payment_paypal_unified_instance`
(
`instance_id` VARCHAR(255) NOT NULL
`instance_id` VARCHAR(36) NOT NULL
) ENGINE = InnoDB
DEFAULT CHARSET = utf8
COLLATE = utf8_unicode_ci;'
Expand Down
9 changes: 8 additions & 1 deletion Subscriber/TransactionReportSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

use Doctrine\DBAL\Connection;
use Enlight\Event\SubscriberInterface;
use Exception;
use GuzzleHttp\Client;
use Shopware;
use SwagPaymentPayPalUnified\Components\TransactionReport\TransactionReport;
Expand Down Expand Up @@ -53,9 +54,15 @@ public function onTransactionReport()
$shopwareVersion = $this->container->getParameter('shopware.release.version');
}

try {
$instanceId = (new InstanceIdService($this->connection))->getInstanceId();
} catch (Exception $exception) {
$instanceId = '';
}

(new TransactionReport($this->connection))->report(
$shopwareVersion,
(new InstanceIdService($this->connection))->getInstanceId(),
$instanceId,
new Client(['base_uri' => TransactionReport::POST_URL])
);
}
Expand Down
3 changes: 1 addition & 2 deletions SwagPaymentPayPalUnified.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@ public function update(UpdateContext $context)
$this->getPaymentMethodProvider(),
new PaymentModelFactory($context->getPlugin()),
$this->getTranslation(),
new TranslationTransformer($this->container->get('models')),
$this->getPath()
new TranslationTransformer($this->container->get('models'))
);
$updater->update($context->getCurrentVersion());

Expand Down
Loading

0 comments on commit 2481a8d

Please sign in to comment.