Skip to content
Snippets Groups Projects

Issue #3452425 by 4kant, TomTech: Logging doesn´t work for Drupal 10 Version

2 files
+ 9
9
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 7
7
@@ -96,14 +96,14 @@ class UPSSdk implements UPSSdkInterface {
/**
* {@inheritdoc}
*/
public function setClient(ClientInterface $client) {
public function setClient(ClientInterface $client): void {
$this->client = $client;
}
/**
* {@inheritdoc}
*/
public function setConfiguration(array $config) {
public function setConfiguration(array $config): void {
$this->config = $config;
}
@@ -178,7 +178,7 @@ class UPSSdk implements UPSSdkInterface {
$response = $this->client->post(self::UPS_API_SHOP_RATE_URL, ['body' => Json::encode($params)]);
$rates = Json::decode($response->getBody());
if ($this->logResponse) {
$this->log("Received UPS rate response", $rates);
$this->log('Received UPS rate response', $rates);
}
if (!empty($rates['RateResponse']['RatedShipment'])) {
$expires = time() + self::RATE_CACHE_DURATION;
@@ -222,7 +222,7 @@ class UPSSdk implements UPSSdkInterface {
protected function getShipment(): array {
$shipment = [];
/** @var \CommerceGuys\Addressing\AddressInterface $address_from */
$address_from = $this->shipment->getOrder()->getStore()->getAddress();
$address_from = $this->shipment->getOrder()?->getStore()?->getAddress();
/** @var \CommerceGuys\Addressing\AddressInterface $address_to */
$address_to = $this->shipment->getShippingProfile()->get('address')->first();
@@ -286,7 +286,7 @@ class UPSSdk implements UPSSdkInterface {
// Set package weight.
$weight_unit = $country_code === 'US' ? WeightUnit::POUND : WeightUnit::KILOGRAM;
$weight = $this->shipment->getWeight()->convert($weight_unit);
$weight = $this->shipment->getWeight()?->convert($weight_unit);
$weight_unit = match ($weight->getUnit()) {
'lb' => 'LBS',
'kg' => 'KGS',
@@ -348,9 +348,9 @@ class UPSSdk implements UPSSdkInterface {
*/
protected function log(string $message, $data = NULL): void {
if ($data) {
$this->logger->info("@message <br /><pre>@dat</pre>", [
$this->logger->info('@message <br /><pre>@data</pre>', [
'@message' => $message,
'@data' => var_export($data, TRUE),
'@data' => json_encode($data, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT | JSON_PRETTY_PRINT),
]);
}
else {
Loading