Completed
Push — master ( a743e8...453823 )
by Florian
01:45
created

SectionIOSiteTreeExtension::onAfterUnpublish()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 0
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
class SectionIOSiteTreeExtension extends SiteTreeExtension
4
{
5
    public function onAfterPublish(&$original)
6
    {
7
        $strategy = SectionIO::SITETREE_STRATEGY_SINGLE;
8
        if (
9
            $this->owner->URLSegment != $original->URLSegment || // the slug has been altered
0 ignored issues
show
Bug introduced by
The property URLSegment does not seem to exist in SS_Object.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
10
            $this->owner->MenuTitle != $original->MenuTitle || // the navigation label has been altered
0 ignored issues
show
Bug introduced by
The property MenuTitle does not seem to exist in SS_Object.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
11
            $this->owner->Title != $original->Title // the title has been altered
0 ignored issues
show
Bug introduced by
The property Title does not seem to exist in SS_Object.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
12
        ) {
13
            $strategy = SectionIO::SITETREE_STRATEGY_ALL;
14
        } else if (
15
            $this->owner->getParent()
16
        ) {
17
            $strategy = SectionIO::SITETREE_STRATEGY_PARENTS;
18
        }
19
        
20
        SectionIO::flushSiteTree($this->owner->ID, $strategy);
0 ignored issues
show
Bug introduced by
The property ID does not seem to exist in SS_Object.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
21
        
22
        parent::onAfterPublish($original);
23
    }
24
    
25
    public function onAfterUnpublish()
26
    {
27
        SectionIO::flushAll();
28
        
29
        parent::onBeforeUnpublish();
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (onBeforeUnpublish() instead of onAfterUnpublish()). Are you sure this is correct? If so, you might want to change this to $this->onBeforeUnpublish().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
30
    }
31
}
32