Completed
Pull Request — master (#168)
by Franco
02:41
created

code/cms/DMSUploadField_ItemHandler.php (1 issue)

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
class DMSUploadField_ItemHandler extends UploadField_ItemHandler
4
{
5
    private static $allowed_actions = array(
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...
6
        'delete',
7
        'edit',
8
        'EditForm',
9
    );
10
11
    /**
12
     * Gets a DMS document by its ID
13
     *
14
     * @return DMSDocument
15
     */
16
    public function getItem()
17
    {
18
        return DMSDocument::get()->byId($this->itemID);
19
    }
20
21
    /**
22
     * @return Form
23
     */
24
    public function EditForm()
25
    {
26
        $file = $this->getItem();
27
28
        // Get form components
29
        $fields = $this->parent->getDMSFileEditFields($file);
30
        $actions = $this->parent->getDMSFileEditActions($file);
31
        $validator = $this->parent->getDMSFileEditValidator($file);
32
        $form = new Form(
33
            $this,
34
            __FUNCTION__,
35
            $fields,
36
            $actions,
37
            $validator
38
        );
39
        $form->loadDataFrom($file);
40
41
        return $form;
42
    }
43
}
44