Completed
Push — master ( c0fbe9...e7535a )
by Robbie
13s
created

code/cms/DMSGridFieldDetailForm.php (1 issue)

overwriting of private properties.

Comprehensibility Informational

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
 * Custom ItemRequest class the provides custom delete behaviour for the CMSFields of DMSDocument
5
 */
6
class DMSGridFieldDetailForm_ItemRequest extends GridFieldDetailForm_ItemRequest
7
{
8
    private static $allowed_actions = array('ItemEditForm');
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
9
10
    public function ItemEditForm()
11
    {
12
        $form = parent::ItemEditForm();
13
14
        //add a data attribute specifying how many pages this document is referenced on
15
        if ($record = $this->record) {
16
            $numberOfPageRelations = $record->getRelatedPages()->count();
17
            $relations = new ShortCodeRelationFinder();
18
            $numberOfInlineRelations = $relations->findPageCount($record->ID);
19
20
            //add the number of pages attached to this field as a data-attribute
21
            $form->setAttribute('data-pages-count', $numberOfPageRelations);
22
            $form->setAttribute('data-relation-count', $numberOfInlineRelations);
23
        }
24
        return $form;
25
    }
26
}
27