Skip to content

Commit aa9ceec

Browse files
authored
Remove Open Review action (#67)
1 parent 62c2d6f commit aa9ceec

5 files changed

Lines changed: 21 additions & 72 deletions

File tree

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ To localize the button, add a lang file in `/resources/lang` with the name match
1212
}
1313
```
1414

15-
**Two ways to get that URL:**
15+
**Getting the Review URL:**
1616

17-
1. The entry listing via the entry's Open Review action: ![screenshot of review action](https://github.com/transformstudios/statamic-review/raw/main/img/Open%20Review%20Action.png "Review Action")
18-
2. The Review fieldtype; I'd recommend adding to the top of the sidebar of any entry blueprint: ![screenshot of copy review url button](https://github.com/transformstudios/statamic-review/raw/main/img/Copy%20URL%20Button.png "Copy Review URL Button")
17+
Review fieldtype: Recommend adding it to the top of the sidebar of any entry blueprint: ![screenshot of copy review url button](https://github.com/transformstudios/statamic-review/raw/main/img/Copy%20URL%20Button.png "Copy Review URL Button")
1918

2019
**Please note**:
2120

composer.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@
2323
"autoload": {
2424
"psr-4": {
2525
"TransformStudios\\Review\\": "src"
26-
},
27-
"files": [
28-
"src/helpers.php"
29-
]
26+
}
3027
},
3128
"config": {
3229
"allow-plugins": {

src/Actions/OpenReview.php

Lines changed: 0 additions & 42 deletions
This file was deleted.

src/Fieldtypes/Review.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@
33
namespace TransformStudios\Review\Fieldtypes;
44

55
use Statamic\Entries\Collection;
6+
use Statamic\Entries\Entry;
7+
use Statamic\Facades\Token as TokenFacade;
68
use Statamic\Fields\Fieldtype;
7-
use TransformStudios\Review\Support\URL;
9+
use Statamic\Tokens\Token;
10+
use TransformStudios\Review\TokenHandler;
811

912
class Review extends Fieldtype
1013
{
@@ -33,6 +36,19 @@ public function preload()
3336
return [];
3437
}
3538

36-
return ['site_url' => review_url($entry)];
39+
return ['site_url' => $this->url($entry)];
40+
}
41+
42+
private function url(Entry $entry): string
43+
{
44+
/** @var \Statamic\Tokens\Token */
45+
if (! $token = TokenFacade::find($entry->id())) {
46+
$token = tap(
47+
TokenFacade::make(token: $entry->id(), handler: TokenHandler::class),
48+
fn (Token $token) => $token->expireAt(now()->addMonths(6))->save()
49+
);
50+
}
51+
52+
return $entry->absoluteUrl().'?token='.$token->token();
3753
}
3854
}

src/helpers.php

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)