Completed
Push — master ( 59c799...149ad0 )
by Will
02:15
created

code/models/ElementVirtualLinked.php (2 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
 * Virtual Linked Element.
5
 *
6
 * As elemental is based on widgets which have a natural has_one relation to an
7
 * object, this is a workaround for allowing the same element to be linked to
8
 * multiple pages.
9
 *
10
 * {@see ElementalGridFieldAddExistingAutocompleter}
11
 *
12
 * @package elemental
13
 */
14
class ElementVirtualLinked extends BaseElement {
15
16
    private static $has_one = 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...
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...
17
        'LinkedElement' => 'BaseElement'
18
    );
19
20
    public function getTitle()
21
    {
22
        return $this->LinkedElement()->getTitle();
23
    }
24
25
    public function i18n_singular_name()
26
    {
27
        return _t(__CLASS__, $this->LinkedElement()->config()->title);
28
    }
29
30
    public function getCMSFields() {
31
        $message = sprintf('<p>%s</p><p><a href="%2$s">%2$s</a></p>',
32
             _t('ElementVirtualLinked.DESCRIBE', 'This is a virtual copy of a block. To edit, visit'),
33
             $this->LinkedElement()->getEditLink()
34
        );
35
36
        $fields = new FieldList(
37
            new LiteralField('Existing', $message)
38
        );
39
40
        $this->extend('updateCMSFields', $fields);
41
42
        return $fields;
43
    }
44
}
45