AddToCartExtension   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 5
Bugs 1 Features 1
Metric Value
eloc 11
c 5
b 1
f 1
dl 0
loc 20
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A AddToCartForm() 0 14 1
1
<?php
2
3
namespace SilverCommerce\CatalogueFrontend\Extensions;
4
5
use SilverStripe\Forms\Form;
6
use SilverStripe\Core\Extension;
7
use SilverStripe\Forms\FieldList;
8
use SilverStripe\Forms\FormAction;
9
use SilverStripe\Forms\HiddenField;
10
use SilverStripe\Core\Config\Config;
11
use SilverStripe\Forms\NumericField;
12
use SilverStripe\ORM\ValidationResult;
13
use SilverStripe\Forms\RequiredFields;
14
use SilverCommerce\OrdersAdmin\Model\LineItem;
0 ignored issues
show
Bug introduced by
The type SilverCommerce\OrdersAdmin\Model\LineItem 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...
15
use SilverCommerce\QuantityField\Forms\QuantityField;
16
use SilverCommerce\ShoppingCart\Forms\AddToCartForm;
0 ignored issues
show
Bug introduced by
The type SilverCommerce\ShoppingCart\Forms\AddToCartForm 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...
17
18
/**
19
 * Add an add to cart form that generates a {@link LineItem} for
20
 * this object and then adds it to the shopping cart 
21
 *
22
 * @author  i-lateral (http://www.i-lateral.com)
23
 * @package cataloge-frontend
24
 */
25
class AddToCartExtension extends Extension
26
{
27
    private static $allowed_actions = [
0 ignored issues
show
introduced by
The private property $allowed_actions is not used, and could be removed.
Loading history...
28
        "AddToCartForm"
29
    ];
30
    
31
    public function AddToCartForm()
32
    {
33
        $object = $this->owner->dataRecord;
34
35
        $form = AddToCartForm::create(
36
            $this->owner,
37
            "AddToCartForm"
38
        );
39
40
        $form
41
            ->setProductClass($object->ClassName)
42
            ->setProductID($object->ID);
43
44
        return $form;
45
    }
46
47
}