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

code/models/ElementVirtualLinked.php (1 issue)

PSR1 classes have a namespace declaration.

Coding Style Compatibility Minor

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 {
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...
15
16
    private static $has_one = array(
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