Skip to content

Commit

Permalink
Merge branch '0.8' into it-translation
Browse files Browse the repository at this point in the history
  • Loading branch information
glennjacobs committed May 6, 2024
2 parents 838b25e + 6e0752a commit 6e36d0f
Show file tree
Hide file tree
Showing 23 changed files with 55 additions and 53 deletions.
1 change: 1 addition & 0 deletions packages/core/resources/lang/en/exceptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
'cart_line_id_mismatch' => 'This cart line does not belong to this cart',
'invalid_cart_line_quantity' => 'Expected quantity to be at least "1", ":quantity" found.',
'maximum_cart_line_quantity' => 'Quantity cannot exceed :quantity.',
'carts.invalid_action' => 'The cart action was invalid',
'carts.shipping_missing' => 'A shipping address is required',
'carts.billing_missing' => 'A billing address is required',
'carts.billing_incomplete' => 'The billing address is incomplete',
Expand Down
5 changes: 2 additions & 3 deletions packages/core/src/Exceptions/CartLineIdMismatchException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

namespace Lunar\Exceptions;

use Exception;

class CartLineIdMismatchException extends Exception
class CartLineIdMismatchException extends LunarException
{
//
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@

class BillingAddressIncompleteException extends CartException
{
//
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@

class BillingAddressMissingException extends CartException
{
//
}
23 changes: 12 additions & 11 deletions packages/core/src/Exceptions/Carts/CartException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,32 @@

namespace Lunar\Exceptions\Carts;

use Exception;
use Illuminate\Contracts\Support\MessageBag;
use Lunar\Exceptions\LunarException;

class CartException extends Exception
class CartException extends LunarException
{
/**
* The cart exception message bag
* The cart exception message bag.
*/
protected MessageBag $messageBag;

public function __construct(MessageBag $messageBag = null)
public function __construct(MessageBag $messageBag)
{
parent::__construct(static::summarize($messageBag));

$this->messageBag = $messageBag;
}

/**
* Create an error message summary from the validation errors.
*
* @param \Illuminate\Contracts\Validation\Validator $validator
* @return string
* Create a summary from the error messages.
*/
protected static function summarize($messageBag)
protected static function summarize(MessageBag $messageBag): string
{
$messages = $messageBag->all();

if (! count($messages) || ! is_string($messages[0])) {
return 'The cart action was invalid';
return __('lunar::exceptions.carts.invalid_action');
}

$message = array_shift($messages);
Expand All @@ -43,7 +41,10 @@ protected static function summarize($messageBag)
return $message;
}

public function errors()
/**
* Get the error message bag.
*/
public function errors(): MessageBag
{
return $this->messageBag;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@

class OrderExistsException extends CartException
{
//
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@

class ShippingAddressIncompleteException extends CartException
{
//
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@

class ShippingAddressMissingException extends CartException
{
//
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@

class ShippingOptionMissingException extends CartException
{
//
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

namespace Lunar\Exceptions;

use Exception;

class CustomerNotBelongsToUserException extends Exception
class CustomerNotBelongsToUserException extends LunarException
{
//
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

namespace Lunar\Exceptions;

use Exception;

class DisallowMultipleCartOrdersException extends Exception
class DisallowMultipleCartOrdersException extends LunarException
{
public function __construct()
{
Expand Down
5 changes: 2 additions & 3 deletions packages/core/src/Exceptions/FieldTypeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

namespace Lunar\Exceptions;

use Exception;

class FieldTypeException extends Exception
class FieldTypeException extends LunarException
{
//
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace Lunar\Exceptions\FieldTypes;

use Exception;
use Lunar\Exceptions\LunarException;

class FieldTypeMissingException extends Exception
class FieldTypeMissingException extends LunarException
{
public function __construct($classname)
public function __construct(string $classname)
{
$this->message = __('lunar::exceptions.fieldtype_missing', [
'class' => $classname,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace Lunar\Exceptions\FieldTypes;

use Exception;
use Lunar\Exceptions\LunarException;

class InvalidFieldTypeException extends Exception
class InvalidFieldTypeException extends LunarException
{
public function __construct($classname)
public function __construct(string $classname)
{
$this->message = __('lunar::exceptions.invalid_fieldtype', [
'class' => $classname,
Expand Down
5 changes: 2 additions & 3 deletions packages/core/src/Exceptions/FingerprintMismatchException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

namespace Lunar\Exceptions;

use Exception;

class FingerprintMismatchException extends Exception
class FingerprintMismatchException extends LunarException
{
//
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

namespace Lunar\Exceptions;

use Exception;

class InvalidCartLineQuantityException extends Exception
class InvalidCartLineQuantityException extends LunarException
{
//
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

namespace Lunar\Exceptions;

use Exception;

class InvalidDataTypeValueException extends Exception
class InvalidDataTypeValueException extends LunarException
{
//
}
5 changes: 2 additions & 3 deletions packages/core/src/Exceptions/InvalidPaymentTypeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

namespace Lunar\Exceptions;

use Exception;

class InvalidPaymentTypeException extends Exception
class InvalidPaymentTypeException extends LunarException
{
//
}
8 changes: 8 additions & 0 deletions packages/core/src/Exceptions/LunarException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace Lunar\Exceptions;

class LunarException extends \Exception
{
//
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

namespace Lunar\Exceptions;

use Exception;

class MaximumCartLineQuantityException extends Exception
class MaximumCartLineQuantityException extends LunarException
{
//
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

namespace Lunar\Exceptions;

use Exception;

class MissingCurrencyPriceException extends Exception
class MissingCurrencyPriceException extends LunarException
{
//
}
4 changes: 1 addition & 3 deletions packages/core/src/Exceptions/NonPurchasableItemException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

namespace Lunar\Exceptions;

use Exception;

class NonPurchasableItemException extends Exception
class NonPurchasableItemException extends LunarException
{
public function __construct(string $classname)
{
Expand Down
5 changes: 2 additions & 3 deletions packages/core/src/Exceptions/SchedulingException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

namespace Lunar\Exceptions;

use Exception;

class SchedulingException extends Exception
class SchedulingException extends LunarException
{
//
}

0 comments on commit 6e36d0f

Please sign in to comment.