Issues (11)

src/Plugin/ForceGuestCart.php (5 issues)

1
<?php
2
declare(strict_types=1);
3
4
namespace IntegerNet\AddToCartGraphQl\Plugin;
5
6
use Magento\Checkout\Model\Session;
0 ignored issues
show
The type Magento\Checkout\Model\Session was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use Magento\Quote\Model\QuoteManagement;
0 ignored issues
show
The type Magento\Quote\Model\QuoteManagement was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
9
/**
10
 * Force setting cart id for guests - this is required for graphql add to cart to work
11
 */
12
class ForceGuestCart
13
{
14
    private QuoteManagement $quoteManagement;
0 ignored issues
show
PHP syntax error: syntax error, unexpected 'QuoteManagement' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST)
Loading history...
15
16
    public function __construct(
17
        QuoteManagement $quoteManagement)
0 ignored issues
show
The closing parenthesis of a multi-line function declaration must be on a new line
Loading history...
18
    {
0 ignored issues
show
The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line
Loading history...
19
        $this->quoteManagement = $quoteManagement;
20
    }
21
22
    public function beforeGetQuote(Session $subject)
23
    {
24
        if (!($subject->getQuoteId())) {
25
            $quoteId = $this->quoteManagement->createEmptyCart();
26
            $subject->setQuoteId($quoteId);
27
        }
28
    }
29
}
30