Completed
Push — master ( 3b65eb...dc665d )
by Nicolaas
11:00 queued 02:51
created

code/cms/CMSPageAddController_Products.php (7 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
4
class CMSPageAddController_Products extends CMSPageAddController
5
{
6
    private static $url_segment = 'addproductorproductgroup';
0 ignored issues
show
The property $url_segment is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
7
8
    private static $url_rule = '/$Action/$ID/$OtherID';
0 ignored issues
show
The property $url_rule is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
9
10
    private static $url_priority = 41;
0 ignored issues
show
The property $url_priority is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
11
12
    private static $menu_title = 'Add Product';
0 ignored issues
show
The property $menu_title is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
13
14
    private static $required_permission_codes = 'CMS_ACCESS_CMSMain';
0 ignored issues
show
The property $required_permission_codes is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
15
16
    private static $allowed_actions = array(
0 ignored issues
show
The property $allowed_actions is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
17
        'AddForm',
18
        'doAdd',
19
        'doCancel',
20
    );
21
22
23
    /**
24
     * the class of the page that is the root parent for the shop.
25
     *
26
     * @var string
27
     */
28
    private static $root_parent_class_for_adding_page = 'ProductGroupSearchPage';
0 ignored issues
show
The property $root_parent_class_for_adding_page is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
29
30
31
    public function doCancel($data, $form)
32
    {
33
        return $this->redirect(singleton('ProductsAndGroupsModelAdmin')->Link());
34
    }
35
36
37
    /**
38
     * @return ArrayList
39
     */
40
    public function PageTypes()
41
    {
42
        $pageTypes = parent::PageTypes();
43
        $result = new ArrayList();
44
        $productClass = Object::getCustomClass('Product');
45
        $productGroupClass = Object::getCustomClass('ProductGroup');
46
47
        $acceptedClasses1 = ClassInfo::subclassesFor($productClass);
48
        $acceptedClasses1[$productClass] = $productClass;
49
50
        $acceptedClasses2 = ClassInfo::subclassesFor($productGroupClass);
51
        $acceptedClasses2[$productGroupClass] = $productGroupClass;
52
53
        $acceptedClasses = array_merge($acceptedClasses1, $acceptedClasses2);
54
        foreach ($pageTypes as $type) {
55
            if (in_array($type->ClassName, $acceptedClasses)) {
56
                $result->push($type);
57
            }
58
        }
59
60
        return $result;
61
    }
62
}
63