ProductPageController   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 4
eloc 14
c 2
b 1
f 0
dl 0
loc 38
ccs 0
cts 12
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 18 3
A PurchaseForm() 0 7 1
1
<?php
2
3
namespace Dynamic\FoxyStripe\Page;
4
5
use Dynamic\FoxyStripe\Form\FoxyStripePurchaseForm;
6
use SilverStripe\View\Requirements;
7
8
/**
9
 * Class ProductPageController
10
 * @package Dynamic\FoxyStripe\Page
11
 *
12
 * @mixin ProductPage
13
 */
14
class ProductPageController extends \PageController
15
{
16
    private static $allowed_actions = array(
0 ignored issues
show
introduced by
The private property $allowed_actions is not used, and could be removed.
Loading history...
17
        'PurchaseForm',
18
    );
19
20
    public function init()
21
    {
22
        parent::init();
23
        Requirements::javascript('silverstripe/admin: thirdparty/jquery/jquery.js');
24
        if ($this->data()->Available && $this->ProductOptions()->exists()) {
0 ignored issues
show
Bug introduced by
The method ProductOptions() does not exist on Dynamic\FoxyStripe\Page\ProductPageController. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

24
        if ($this->data()->Available && $this->/** @scrutinizer ignore-call */ ProductOptions()->exists()) {
Loading history...
25
            $formName = $this->PurchaseForm()->FormName();
0 ignored issues
show
Unused Code introduced by
The assignment to $formName is dead and can be removed.
Loading history...
26
            /*Requirements::javascriptTemplate(
27
                'dynamic/foxystripe: javascript/out_of_stock.js',
28
                [
29
                    'FormName' => $formName,
30
                ],
31
                'foxystripe.out_of_stock'
32
            );*/
33
            Requirements::javascript('dynamic/foxystripe: javascript/product_options.js');
34
        }
35
36
        Requirements::customScript(<<<JS
37
		var productID = {$this->data()->ID};
38
JS
39
        );
40
    }
41
42
    /**
43
     * @return FoxyStripePurchaseForm
44
     */
45
    public function PurchaseForm()
46
    {
47
        $form = FoxyStripePurchaseForm::create($this, __FUNCTION__, null, null, null, $this->data());
48
49
        $this->extend('updateFoxyStripePurchaseForm', $form);
50
51
        return $form;
52
    }
53
}
54