-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathReview.php
More file actions
38 lines (30 loc) · 966 Bytes
/
Review.php
File metadata and controls
38 lines (30 loc) · 966 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
namespace TransformStudios\Review\Fieldtypes;
use Statamic\Entries\Collection;
use Statamic\Fields\Fieldtype;
use TransformStudios\Review\Support\URL;
class Review extends Fieldtype
{
protected $component = 'copy_review_url';
public function icon()
{
return file_get_contents(__DIR__.'/../../resources/svg/review-icon.svg');
}
public function preload()
{
if (! $entry = $this->field->parent()) {
return [];
}
// when it's a new entry the "parent" might be a collection
// in this case, we can't show it anyway so return empty
if ($entry instanceof Collection) {
return [];
}
// if there's a computed field in the entry's collection that uses augmentation,
// this maybe be an empty entry, without an id
if (is_null($entry->id())) {
return [];
}
return ['site_url' => review_url($entry)];
}
}