Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ To localize the button, add a lang file in `/resources/lang` with the name match
}
```

**Two ways to get that URL:**
**Getting the Review URL:**

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")
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")
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")

**Please note**:

Expand Down
5 changes: 1 addition & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@
"autoload": {
"psr-4": {
"TransformStudios\\Review\\": "src"
},
"files": [
"src/helpers.php"
]
}
},
"config": {
"allow-plugins": {
Expand Down
42 changes: 0 additions & 42 deletions src/Actions/OpenReview.php

This file was deleted.

20 changes: 18 additions & 2 deletions src/Fieldtypes/Review.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
namespace TransformStudios\Review\Fieldtypes;

use Statamic\Entries\Collection;
use Statamic\Entries\Entry;
use Statamic\Facades\Token as TokenFacade;
use Statamic\Fields\Fieldtype;
use TransformStudios\Review\Support\URL;
use Statamic\Tokens\Token;
use TransformStudios\Review\TokenHandler;

class Review extends Fieldtype
{
Expand Down Expand Up @@ -33,6 +36,19 @@ public function preload()
return [];
}

return ['site_url' => review_url($entry)];
return ['site_url' => $this->url($entry)];
}

private function url(Entry $entry): string
{
/** @var \Statamic\Tokens\Token */
if (! $token = TokenFacade::find($entry->id())) {
$token = tap(
TokenFacade::make(token: $entry->id(), handler: TokenHandler::class),
fn (Token $token) => $token->expireAt(now()->addMonths(6))->save()
);
}

return $entry->absoluteUrl().'?token='.$token->token();
}
}
21 changes: 0 additions & 21 deletions src/helpers.php

This file was deleted.

Loading