Completed
Push — master ( 18f749...9fc766 )
by Gordon
17:08 queued 02:10
created

AttachedGalleryExtension::InlineGalleries()   A

Complexity

Conditions 4
Paths 6

Size

Total Lines 17
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 4
Metric Value
dl 0
loc 17
ccs 11
cts 11
cp 1
rs 9.2
cc 4
eloc 8
nc 6
nop 0
crap 4
1
<?php
2
3
class AttachedGalleryExtension extends DataExtension
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
4
{
5
    private static $has_one = array(
0 ignored issues
show
Unused Code introduced by
The property $has_one 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...
6
        'AttachedGallery' => 'GalleryPage',
7
    );
8
9 1
    public function updateCMSFields(FieldList $fields)
10
    {
11 1
        $galleryField = new TreeDropdownField(
12 1
            'AttachedGalleryID',
13 1
            _t('AttachedGalleryExtension.CHOOSE_A_GALLERY', 'Choose another gallery to show on this page'),
14
            'GalleryPage'
15 1
        );
16
17 1
        $fields->addFieldToTab('Root.'._t('AttachedGalleryExtension.ATTACHED_GALLERY', 'Attached Gallery'), $galleryField);
18 1
    }
19
20
    /*
21
    Return a list of the attached gallery and any child galleries
22
    */
23 1
    public function InlineGalleries()
0 ignored issues
show
Coding Style introduced by
Method name "AttachedGalleryExtension::InlineGalleries" is not in camel caps format
Loading history...
24
    {
25 1
        $result = new ArrayList();
26
27
        // find child galleries
28 1
        foreach ($this->owner->AllChildren() as $child) {
29 1
            if ($child->ClassName == 'GalleryPage') {
30 1
                $result->push($child);
31 1
            }
32 1
        }
33
34 1
        if ($this->owner->AttachedGalleryID != 0) {
35 1
            $result->push($this->owner->AttachedGallery());
36 1
        }
37
38 1
        return $result;
39
    }
40
}
41